:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #0f766e;
  --accent-2: #115e59;
  --accent-soft: #ccfbf1;
  --bubble-in: #ffffff;
  --bubble-out: #d9f5ef;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --shopee: #ee4d2d;
  --tiktok: #111111;
  --zalo: #0068ff;
  --facebook: #1877f2;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14; --panel: #12171e; --panel-2: #171d26; --line: #232b36; --line-2: #2f3946;
    --text: #e5e7eb; --muted: #9aa4b2; --faint: #6b7686; --accent: #2dd4bf; --accent-2: #5eead4;
    --accent-soft: #0f3b37; --bubble-in: #1b222c; --bubble-out: #12372f; --danger: #f87171;
    --danger-soft: #3b1414; --warn: #fbbf24; --warn-soft: #3a2a07; --ok: #4ade80; --ok-soft: #0f2e1a;
    --tiktok: #fe2c55; --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f14; --panel: #12171e; --panel-2: #171d26; --line: #232b36; --line-2: #2f3946;
  --text: #e5e7eb; --muted: #9aa4b2; --faint: #6b7686; --accent: #2dd4bf; --accent-2: #5eead4;
  --accent-soft: #0f3b37; --bubble-in: #1b222c; --bubble-out: #12372f; --danger: #f87171;
  --danger-soft: #3b1414; --warn: #fbbf24; --warn-soft: #3a2a07; --ok: #4ade80; --ok-soft: #0f2e1a;
  --tiktok: #fe2c55; --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Khung chính ---------- */
/* 100dvh: chiều cao thật trên điện thoại (100vh tính cả phần thanh địa chỉ che mất → ô gõ tin bị che). */
.shell { display: grid; grid-template-columns: 64px 1fr; height: 100vh; height: 100dvh; }
.rail {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px;
}
.rail .logo { width: 36px; height: 36px; margin-bottom: 10px; }
.rail button {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--muted); position: relative;
}
.rail button:hover { background: var(--panel-2); color: var(--text); }
.rail button.on { background: var(--accent-soft); color: var(--accent); }
.rail button svg { width: 22px; height: 22px; }
.rail .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; font-weight: 700; }
.rail .spacer { flex: 1; }
.rail button.bell-on { color: var(--accent); }
/* Dòng nhắc bật thông báo đầu Hộp thư (chỉ hiện trên điện thoại khi máy chưa bật). */
.push-hint { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--accent-soft); color: var(--text); font-size: 13px; border-bottom: 1px solid var(--line); }
.push-hint .btn { flex: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar .away-dot { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel); background: var(--warn); }
.view { min-width: 0; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Hộp thư: 3 cột ---------- */
.inbox { display: grid; grid-template-columns: 290px minmax(360px, 1fr) 400px; height: 100%; }
.pane { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tabs .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; }
.search { position: relative; }
.search input { width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--faint); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; cursor: pointer;
  font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip .pdot { width: 8px; height: 8px; border-radius: 50%; }
select.chip { padding-right: 6px; }

.conv-list { overflow-y: auto; flex: 1; }
.conv {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--line); position: relative;
}
.conv:hover { background: var(--panel-2); }
.conv.on { background: var(--accent-soft); }
.conv .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .who { font-weight: 800; }
.conv .sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-width: 0; }
.conv .preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .preview { color: var(--text); }
.conv .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--faint); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.waiting { color: var(--warn); font-weight: 600; }
.viewing { font-size: 11px; color: var(--accent); }
.plat { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; color: #fff; }
.plat.shopee { background: var(--shopee); } .plat.tiktok { background: var(--tiktok); }
.plat.zalo { background: var(--zalo); } .plat.facebook { background: var(--facebook); }
.conv .avatar-wrap { position: relative; }
.conv .avatar-wrap .plat-dot { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--panel); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Khung chat ---------- */
.chat-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 61px; }
.chat-head .title { font-weight: 700; font-size: 15px; }
.chat-head .sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chat-head .actions { margin-left: auto; display: flex; gap: 6px; }
.notice { margin: 8px 16px 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--accent-soft); color: var(--accent-2); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.day { align-self: center; font-size: 11px; color: var(--faint); margin: 10px 0 4px; }
.msg { max-width: 72%; display: flex; flex-direction: column; gap: 2px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 14px; background: var(--bubble-in); box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; }
.msg.out .bubble { background: var(--bubble-out); }
.msg.in .bubble { border-bottom-left-radius: 4px; }
.msg.out .bubble { border-bottom-right-radius: 4px; }
.msg img.media { max-width: 260px; max-height: 260px; border-radius: 12px; display: block; cursor: zoom-in; box-shadow: var(--shadow); background: var(--panel); }
.msg .time { font-size: 11px; color: var(--faint); padding: 0 4px; }
.msg.failed .bubble { outline: 1.5px solid var(--danger); }
.msg .err { font-size: 12px; color: var(--danger); }
.media-gone { font-size: 12px; color: var(--muted); font-style: italic; }
/* Nhóm "Cần xử lý gấp" + gắn cờ (13/10) */
.group-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 14px 4px; display: flex; justify-content: space-between; gap: 8px; }
.group-head.urgent { color: var(--danger); background: var(--danger-soft); }
.conv.urgent { background: var(--danger-soft); }
.conv.urgent.on { outline: 2px solid var(--danger); outline-offset: -2px; }
.conv .wait { color: var(--danger); font-weight: 700; font-size: 11px; white-space: nowrap; }
.conv .flag-ic { color: var(--warn); }
.conv .flag-note { font-size: 12px; color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.danger { border-color: var(--danger); color: var(--danger); }
.rail .dot:not(.urgent) { background: var(--accent); } /* đỏ chỉ khi có khách chờ quá 1 giờ */
.btn.flagged { color: var(--warn); border-color: var(--warn); }
/* Nút "✓ Xong" (29/10, anh Tuyến): cạnh "Gắn cờ" ở đầu khung chat + nút nhỏ trên hội thoại "Cần xử lý gấp" ở danh sách. */
.btn.done-btn { color: var(--ok); border-color: var(--ok); }
.conv .quick-done { border: 1px solid var(--ok); background: var(--panel); color: var(--ok); border-radius: 2px; padding: 1px 6px; font-size: 11px; line-height: 1.4; cursor: pointer; white-space: nowrap; }
.conv .quick-done:hover { background: var(--ok-soft); }
.conv .quick-done:disabled { opacity: .5; cursor: default; }
.flag-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 16px; background: var(--warn-soft); color: var(--warn); font-size: 13px; border-bottom: 1px solid var(--line); }
.flag-bar .minor { color: var(--warn); }
.flag-bar input { flex: 1; min-width: 160px; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 8px; background: var(--panel); color: var(--text); }
/* AI soạn sẵn câu trả lời (giai đoạn 3) */
/* Bản nháp AI: bong bóng xám nét đứt cuối đoạn chat, bên phải (19/10, anh Tuyến chọn kiểu đơn giản). */
.ai-slot { display: contents; }
.ai-draft { align-self: flex-end; max-width: 72%; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
.ai-label { font-size: 12px; font-weight: 700; color: var(--muted); cursor: help; }
.ai-part { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'%3E%3Crect x='.5' y='.5' width='calc(100% - 1px)' height='calc(100% - 1px)' rx='10' ry='10' fill='none' stroke='%238b93a1' stroke-width='1' stroke-dasharray='9 7'/%3E%3C/svg%3E") no-repeat center / 100% 100% var(--line); color: var(--text); border: 0; border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; align-self: stretch; }
.ai-draft .need { color: var(--warn); font-weight: 600; font-size: 12px; }
.ai-foot { font-size: 12px; color: var(--muted); text-align: right; }
.ai-foot a { margin-left: 8px; color: var(--accent); cursor: pointer; text-decoration: underline; }
/* Nháp nhiều ý, mỗi ý trả lời 1 tin khách (21/10, anh Tuyến) */
.ai-draft.multi { gap: 8px; }
.ai-item { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ai-quote { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-right: 3px solid var(--accent); padding-right: 6px; }
/* Nút của nháp nhiều ý là nút thật (anh Tuyến 21/10: chữ gạch chân nhỏ khó thấy) */
.ai-draft.multi .ai-foot { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.ai-draft.multi .ai-foot a { margin: 0; text-decoration: none; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 10px; font-weight: 600; background: var(--panel, #fff); }
.ai-draft.multi .ai-foot a[data-act="ai-send-merged"] { background: var(--accent); color: #fff; }
.ai-part-edit { align-self: stretch; font: inherit; font-size: 14px; padding: 8px 12px; border: 2px solid var(--accent); border-radius: 10px; resize: vertical; background: var(--panel, #fff); color: var(--text); }
.ai-pending { font-size: 12px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 8px; padding: 4px 10px; }
.ai-fixed { font-size: 12px; color: var(--accent); font-weight: 600; }
.ai-draft.muted { align-items: flex-end; font-size: 13px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 10px; padding: 6px 12px; background: transparent; }
.sys-note { align-self: center; max-width: 80%; text-align: center; font-size: 11px; color: var(--faint); background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 4px 10px; white-space: pre-wrap; }
.order-card {background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 240px; box-shadow: var(--shadow); }
.order-card .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.order-card .v { font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.composer { margin: 8px 12px 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 12px; }
.composer-label { font-size: 12px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: .03em; }
.composer-row { display: flex; justify-content: space-between; align-items: center; }
.composer textarea { width: 100%; resize: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; max-height: 160px; min-height: 60px; background: var(--panel); color: var(--text); }
.composer textarea:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.typing { font-size: 12px; color: var(--accent); padding: 0 16px 6px; min-height: 18px; background: var(--bg); }

/* ---------- Nút ---------- */
.btn {
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer;
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 8px; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--danger); }

/* ---------- Cột phải: khách + phiếu bảo hành ---------- */
.side { overflow-y: auto; border-right: 0; }
.section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.section h3 .right { margin-left: auto; text-transform: none; letter-spacing: 0; }
.order { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.order .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.order .id { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.order .items { color: var(--muted); font-size: 12px; margin-top: 2px; }
.order.used { border-color: var(--accent); background: var(--accent-soft); }

/* Thẻ đơn TikTok — giống cột "Đơn hàng" của TikTok Seller Center (19/10, anh Tuyến). Shopee vẫn dùng .order. */
.tt-orders { background: var(--bg); padding: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.tt-order { background: var(--panel); padding: 0 16px; border-left: 3px solid transparent; }
.tt-order.used { border-left-color: var(--accent); }
.tt-head { padding: 14px 0 12px; border-bottom: 1px solid var(--line); }
.tt-status { font-size: 16px; font-weight: 600; }
.tt-idrow { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.tt-id { font-variant-numeric: tabular-nums; }
.tt-copy { border: 0; background: none; padding: 0 2px; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
.tt-copy:hover { color: var(--text); }
.tt-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.tt-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tt-btn { border: 0; border-radius: 4px; padding: 6px 10px; font-size: 13px; font-weight: 600; background: var(--line); color: var(--text); cursor: pointer; }
.tt-btn:hover { background: var(--line-2); }
.tt-btn.primary { background: #0e8a85; color: #fff; }
.tt-btn.primary:hover { background: #0b706c; }
.tt-btn.on { background: var(--accent-soft); color: var(--accent); }
.tt-items { padding: 12px 0; border-bottom: 1px solid var(--line); }
.tt-item { display: flex; gap: 10px; margin-bottom: 10px; }
.tt-img { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; background: var(--panel-2); flex: none; }
.tt-info { flex: 1; min-width: 0; }
.tt-name-row { display: flex; gap: 8px; align-items: flex-start; }
.tt-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tt-qty { font-size: 14px; font-weight: 600; flex: none; }
.tt-variant { font-size: 13px; color: var(--muted); margin-top: 2px; text-transform: uppercase; }
.tt-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tt-sum { text-align: right; font-size: 14px; }
.tt-bar { color: var(--line-2); margin: 0 4px; }
.tt-row { display: flex; gap: 12px; padding: 12px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.tt-row:last-child { border-bottom: 0; }
.tt-k { color: var(--muted); width: 110px; flex: none; }
.tt-v { flex: 1; min-width: 0; text-align: right; }
.tt-muted { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tt-links { margin-top: 4px; font-size: 13px; }
.tt-links a { color: #0e8a85; text-decoration: none; }
.tt-links a:hover { text-decoration: underline; }

.side .tabs button { padding: 6px 4px; font-size: 13px; }
.shop-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.shop-item:last-child { border-bottom: 0; }
.si-img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex: none; }
.si-icon { width: 40px; height: 40px; border-radius: 8px; background: var(--warn-soft); display: grid; place-items: center; font-size: 20px; flex: none; }
.si-main { flex: 1; min-width: 0; }
.si-title { font-size: 13px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.si-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 9px; background: var(--panel); width: 100%; min-width: 0;
}
.field textarea { resize: vertical; min-height: 60px; }
.field.bad input, .field.bad select, .field.bad .combo input { border-color: var(--danger); }
.field .hint { font-size: 11px; color: var(--faint); }
.field .error { font-size: 11px; color: var(--danger); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
details.more { grid-column: 1 / -1; border: 1px dashed var(--line-2); border-radius: 8px; padding: 6px 10px; }
details.more summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
details.more .form { margin-top: 10px; }
.combo { position: relative; }
.combo .list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow);
}
.combo .opt { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.combo .opt:hover, .combo .opt.hi { background: var(--accent-soft); }
.combo .opt .sku { font-family: ui-monospace, Consolas, monospace; font-weight: 700; margin-right: 6px; }
.combo .opt .b { font-size: 11px; color: var(--muted); margin-left: 6px; }
.pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pic { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: var(--panel-2); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic.on { border-color: var(--accent); }
.pic .tick { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 12px; color: #fff; }
.pic.on .tick { background: var(--accent); border-color: var(--accent); }
.pic .pic-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(0 0 0 / .6); color: #fff; font-size: 12px; line-height: 22px; padding: 0;
}
.pic .pic-x:hover { background: var(--danger); }
.paste-zone {
  margin-top: 6px; border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 10px; text-align: center;
  font-size: 12px; color: var(--muted); cursor: text; background: var(--panel-2);
}
.paste-zone:focus, .paste-zone.over { outline: none; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.dup { grid-column: 1 / -1; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.dup ul { margin: 4px 0 0; padding-left: 18px; }
/* Tra đơn trên bảng theo dõi bảo hành: kết quả + chế độ bổ sung vào phiếu đã có */
.lookup { grid-column: 1 / -1; border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.lookup.found { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); }
.lookup.missing { background: var(--warn-soft); color: var(--warn); }
.lookup ul { margin: 4px 0 0; padding-left: 18px; }
.lookup li.on { font-weight: 700; }
.lookup .quick { margin-top: 6px; }
.field input:disabled, .field select:disabled, .field textarea:disabled, .combo input:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
.check.locked { color: var(--muted); }
.check-cell { display: flex; align-items: center; padding-top: 18px; font-weight: 600; }
.check-cell.full { grid-column: 1 / -1; padding-top: 0; }
.note-old { white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-size: 12px; color: var(--muted); }
.ticket { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.ticket .row1 { display: flex; gap: 8px; align-items: center; }
.status { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.status.created { background: var(--ok-soft); color: var(--ok); }
.status.dry-run { background: var(--accent-soft); color: var(--accent-2); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
pre.payload { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; margin: 6px 0 0; }

/* ---------- Trang danh sách / quản trị ---------- */
.page { height: 100%; overflow-y: auto; padding: 24px 28px; }
.page h1 { margin: 0 0 4px; font-size: 22px; }
.page .lead { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card > h2 { margin: 0; padding: 14px 16px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card > h2 .right { margin-left: auto; }
.card .body { padding: 14px 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
td .mono, .mono { font-family: ui-monospace, Consolas, monospace; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.offline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); margin-right: 6px; }

/* ---------- Trang Đơn hàng ---------- */
.page-head { display: flex; gap: 8px 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .lead { margin-bottom: 0; }
.page-head > div:first-child { flex: 1 1 420px; min-width: 0; }
.page-head .tools { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.page-head select { border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--panel); }
.orders .notice { margin: 0 0 12px; }
.minor { color: var(--muted); font-size: 12px; font-weight: 400; }
.card > h2 .minor { margin-left: 2px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.period-modes { flex: 0 0 auto; }
.period-modes button { flex: 0 0 auto; padding: 6px 16px; }
.pnav { display: flex; align-items: center; gap: 8px; }
.pnav .btn { min-width: 34px; font-size: 16px; line-height: 1; padding: 5px 0; }
.pnav .btn:disabled { opacity: .4; cursor: default; }
.plabel { font-size: 15px; min-width: 190px; text-align: center; font-variant-numeric: tabular-nums; }
.period-bar input[type="date"] { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .val { font-size: 28px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat .delta { font-size: 12px; margin-top: 6px; color: var(--muted); }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--danger); }
.stats-note { margin: 8px 0 18px; }
.n { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.n.has { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.urgent-note { margin: 0 0 12px; }
.ugrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 18px 28px; }
.ugroup h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ugroup .hint { margin: 2px 0 8px; font-size: 12px; color: var(--muted); }
.ugroup .none { font-size: 13px; color: var(--faint); padding: 6px 0; }
.urow { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto 70px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.urow .main { min-width: 0; }
.urow .shop { color: var(--muted); font-size: 12px; margin-left: 6px; }
.urow .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urow .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.urow .act { text-align: right; }
.due { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); text-align: center; white-space: nowrap; }
.due.soon { background: var(--warn-soft); color: var(--warn); }
.due.late { background: var(--danger-soft); color: var(--danger); }
.linkish { border: 0; background: none; padding: 0; color: var(--text); cursor: copy; font-size: 13px; }
.linkish:hover { color: var(--accent); text-decoration: underline; }
.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .yt { fill: var(--muted); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; }
.chart .x { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart .v { fill: var(--text); font-size: 12px; font-weight: 700; text-anchor: middle; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .col.on .bar { fill: var(--accent-2); }
.chart .col.on .hit { fill: var(--panel-2); }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 6px 10px; font-size: 12px; white-space: nowrap; z-index: 2; }
.chart .tip[hidden] { display: none; }
.orders details { margin-top: 10px; }
.orders details summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; }
.orders details table { margin-top: 6px; }
.rep-chart .bar { fill: var(--line-2); }
.rep-chart .bar.ai { fill: var(--accent); }
.rep-chart .legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.rep-chart .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--line-2); margin-right: 6px; vertical-align: -1px; }
.rep-chart .sw.ai { background: var(--accent); }
.reports td.ai-col, .reports th.ai-col { background: var(--accent-soft); }
.reports tr.total td { border-top: 2px solid var(--line-2); }
.reports th { white-space: nowrap; }
.pipe { display: grid; gap: 10px; }
.prow { display: grid; grid-template-columns: 170px minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 13px; }
.prow .pb { height: 14px; }
.prow .pb span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 0; }
.prow .pv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pipe + .minor { margin: 14px 0 0; }

/* ---------- Phiếu nhanh + cửa sổ nổi ---------- */
.quick-page { max-width: 600px; }
.pip-wrap { padding: 12px 14px 24px; min-height: 100vh; background: var(--panel); }
.pip-wrap[hidden], .pip-bubble[hidden] { display: none; }
.pip-bubble { height: 100vh; display: grid; place-items: center; background: var(--bg); }
.bubble-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer; background: var(--accent); color: #fff;
  font-size: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 6px 18px rgb(15 118 110 / .45); transition: transform .12s;
}
.bubble-btn span { font-size: 12px; font-weight: 700; }
.bubble-btn:hover { transform: scale(1.06); }
.pip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.pip-head span { font-size: 11px; color: var(--muted); }
.pip-wrap .form { grid-template-columns: 1fr 1fr; }
.field.smart textarea { min-height: 64px; background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Đăng nhập ---------- */
.login { display: grid; place-items: center; height: 100vh; padding: 16px; }
.login .box { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login h1 { margin: 12px 0 4px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 20px; }
.login .btn { width: 100%; justify-content: center; padding: 10px; }
.pw-login { display: grid; gap: 10px; }
.pw-login .field input { padding: 9px 10px; font-size: 15px; }
.pw-login .err { color: var(--danger); font-size: 13px; min-height: 0; }
.pw-login .err:empty { display: none; }
.login .or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--faint); font-size: 12px; }
.login .or::before, .login .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
.pw-view { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--muted); }
.pw-view .mono { color: var(--text); font-size: 13px; user-select: all; }
.pw-reset { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.pw-reset input { border: 1px solid var(--line-2); border-radius: 7px; padding: 4px 8px; background: var(--panel); color: var(--text); width: 180px; min-width: 0; font-size: 12px; }
.pw-wrap { position: relative; display: flex; min-width: 0; }
.pw-wrap input { padding-right: 52px !important; }
.pw-eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); border: 0; background: var(--panel-2); color: var(--muted); border-radius: 5px; padding: 3px 7px; font-size: 11px; font-weight: 600; cursor: pointer; }
.pw-eye:hover, .pw-eye[aria-pressed="true"] { color: var(--accent); }
.form.new-user { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ai-try { display: flex; gap: 8px; }
.ai-try input { flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--panel); color: var(--text); }
.ai-hit { border-top: 1px solid var(--line); padding: 8px 0; font-size: 13px; white-space: pre-wrap; }
.ai-hit .minor { white-space: normal; }
#ai-results { margin-top: 8px; }
.ai-sub { margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.ai-try select { border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 8px; background: var(--panel); color: var(--text); max-width: 180px; }
.ai-answer { margin-top: 10px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.ai-answer.warn { border-left-color: var(--warn); }
.ai-answer .reply { font-size: 14px; margin-top: 4px; white-space: pre-wrap; }
.ai-answer .need { margin-top: 6px; color: var(--warn); font-weight: 600; font-size: 13px; }
.login .dev { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line-2); display: grid; gap: 8px; }
.login .dev .lbl { font-size: 12px; color: var(--muted); }

/* ---------- Hộp thoại + thông báo ---------- */
.modal-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal .body { padding: 16px 18px; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.lightbox { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
#toast .t { background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
#toast .t.err { background: var(--danger); }

/* ---------- Màn hình hẹp ---------- */
/* Phải đứng TRƯỚC khối @media bên dưới: 2 dòng cùng !important thì dòng sau thắng, nên trước 13/10 nút "quay lại" và
   "Phiếu BH" trên điện thoại luôn bị ẩn. */
.mobile-only { display: none !important; }
@media (max-width: 1200px) {
  .inbox { grid-template-columns: 300px 1fr 360px; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; padding-top: env(safe-area-inset-top); }
  .rail { flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); order: 2; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .rail .logo, .rail .spacer, .rail #me-avatar { display: none; }
  .rail { gap: 0; }
  .rail button { width: 38px; height: 40px; }
  .view { height: auto; min-height: 0; }
  /* iPhone tự phóng to trang khi bấm vào ô chữ nhỏ hơn 16px. */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  /* Đầu khung chat: hàng 1 = quay lại + tên khách, hàng 2 = các nút. */
  .chat-head { flex-wrap: wrap; padding: 8px 10px; gap: 6px 8px; min-height: 0; }
  .chat-head .who { flex: 1; }
  .chat-head .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-head .sub { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  .chat-head .actions { margin-left: 0; flex-basis: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .inbox { grid-template-columns: 1fr; }
  .inbox > .pane { display: none; }
  .inbox[data-show="list"] > .list-pane, .inbox[data-show="chat"] > .chat-pane, .inbox[data-show="side"] > .side { display: flex; }
  .mobile-only { display: inline-flex !important; }
  .page { padding: 16px; }
  .kv { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .val { font-size: 22px; }
  .form.new-user { grid-template-columns: minmax(0, 1fr); }
  .ai-try { flex-wrap: wrap; }
  .ai-try select { max-width: none; flex: 1 1 100%; }
  .pnav { flex: 1 1 100%; order: 2; }
  .plabel { flex: 1; min-width: 0; }
  .grid2, .ugrid { grid-template-columns: minmax(0, 1fr); }
  .urow { grid-template-columns: 100px minmax(0, 1fr) auto; }
  .urow .act:empty { display: none; }
  .urow .amt { display: none; }
  .prow { grid-template-columns: 130px minmax(0, 1fr) 40px; }
}

/* Thẻ đơn Shopee — giống Shopee Seller Chat, màu cam (19/10, anh Tuyến). */
.sp-filters { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; }
.sp-filters button { border: 0; background: none; color: var(--muted); padding: 2px 0; cursor: pointer; border-bottom: 2px solid transparent; }
.sp-filters button.on { color: var(--shopee); border-bottom-color: var(--shopee); font-weight: 600; }
.sp-orders { background: var(--bg); padding: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.sp-order { background: var(--panel); padding: 12px 16px; font-size: 13px; }
.sp-top { display: flex; justify-content: space-between; gap: 8px; }
.sp-st { font-weight: 700; }
.sp-st.good .sp-ic { color: var(--ok); }
.sp-st.bad, .sp-st.bad .sp-ic { color: var(--danger); }
.sp-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sp-sn { margin-top: 4px; font-size: 12px; color: var(--text); }
.sp-muted { color: var(--muted); font-size: 12px; }
.sp-item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sp-img { width: 52px; height: 52px; border-radius: 4px; object-fit: cover; background: var(--panel-2); flex: none; }
.sp-info { flex: 1; min-width: 0; }
.sp-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sp-sku { font-size: 12px; color: #2563eb; margin-top: 2px; }
.sp-price { text-align: right; flex: none; }
.sp-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0 0; }
.sp-k { color: var(--muted); }
.sp-total { color: var(--shopee); font-size: 14px; }
.sp-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sp-btn { border: 1px solid var(--shopee); color: var(--shopee); background: transparent; border-radius: 3px; padding: 5px 12px; font-size: 12px; cursor: pointer; text-decoration: none; }
.sp-btn.solid { background: var(--shopee); color: #fff; }
.sp-btn:hover { opacity: .85; }

/* Bảng chọn biểu tượng cảm xúc ở ô gõ tin. */
.composer { position: relative; }
.emoji-pop { position: absolute; left: 0; bottom: calc(100% + 6px); width: 300px; max-width: 100%; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); z-index: 20; }
.emoji-pop button { border: 0; background: none; font-size: 20px; line-height: 1; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-pop button:hover { background: var(--line); }
.composer-tools { display: flex; gap: 2px; }

/* Form phiếu bảo hành: 1 cột, nhãn bên trái – ô nhập bên phải cho dễ nhìn (19/10, anh Tuyến). Ô nhiều nội dung (ảnh căn cứ, dán thông tin) giữ nhãn ở trên. */
.form[data-form] { grid-template-columns: 1fr; gap: 8px; }
.form[data-form] .field { display: grid; grid-template-columns: 108px minmax(0, 1fr); column-gap: 10px; row-gap: 2px; align-items: center; }
.form[data-form] .field > label { font-size: 13px; font-weight: 500; color: var(--muted); }
.form[data-form] .field > :not(label) { grid-column: 2; }
.form[data-form] .field:has(textarea) > label { align-self: start; padding-top: 8px; }
.form[data-form] .field:has(.quick), .form[data-form] .field.smart { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.form[data-form] .field:has(.quick) > label, .form[data-form] .field.smart > label { font-weight: 600; }
.form[data-form] .check-cell { padding-top: 0; }

.ev-auto { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: 8px; padding: 6px 10px; }
.tt-acts.end { display: flex; justify-content: flex-end; padding: 10px 0 14px; margin-top: 0; }

/* Cột phải thu nhỏ chữ một chút (19/10, anh Tuyến). */
#side > * { zoom: .93; }

/* Nhãn thương hiệu (CWELL / GOODFIT) ở góc trái trên avatar trong danh sách hội thoại (19/10, anh Tuyến). */
.conv .avatar-wrap .brand-tag { position: absolute; left: -6px; top: -7px; padding: 1px 5px; border-radius: 6px; font-size: 9px; font-weight: 400; letter-spacing: .02em; color: #fff; background: #4b5563; border: 2px solid var(--panel); line-height: 1.2; }
.conv .avatar-wrap .brand-tag.cwell { background: #f5d0fe; color: #86198f; }
.conv .avatar-wrap .brand-tag.goodfit { background: #fecaca; color: #b91c1c; }

/* Thanh menu trái đổ màu đen (19/10, anh Tuyến — đã thử cam rồi đổi sang đen): nền đen, biểu tượng trắng, mục đang mở nền trắng mờ. */
.rail { background: #111827; border-right-color: #000; }
.rail button { color: rgba(255, 255, 255, .8); }
.rail button:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.rail button.on { background: rgba(255, 255, 255, .95); color: #111827; }
.rail button.bell-on { color: #fff; }
.rail .dot:not(.urgent) { background: #fff; color: #111827; }

.fail-table td { vertical-align: top; max-width: 280px; white-space: pre-wrap; word-break: break-word; }
.fail-table td:nth-child(1) { min-width: 120px; }
/* Cột Nạp rule ngay trên báo cáo (27/10, tối giản): chưa có rule → 1 ô gõ (Enter nạp); đã nạp → chỉ chữ rule; "Sửa" nhỏ dưới dấu ✕. */
.fail-table td.fail-rule { min-width: 220px; white-space: normal; }
.fail-table .fr-line { white-space: pre-line; }
.fail-table .fr-line + .fr-line, .fail-table .fr-line + .fr-input, .fail-table .fr-input + .fr-line { margin-top: 6px; }
.fail-table td.fail-act { text-align: center; }
.fail-table .fr-edit { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.fail-table .fr-edit:hover { color: var(--accent); }
.fail-table .fr-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 6px; resize: vertical; }

/* Bộ lọc ngày của Báo cáo: nút hiện khoảng ngày + lịch 2 tháng (19/10, anh Tuyến). */
.rep-picker { position: relative; display: inline-block; margin: 10px 0 14px; }
.rep-trigger { border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; color: var(--text); }
.cal-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; display: flex; width: max-content; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgb(0 0 0 / .18); max-width: calc(100vw - 24px); }
.cal-side { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; border-right: 1px solid var(--line); min-width: 120px; }
.cal-side button { border: 0; background: none; text-align: left; padding: 6px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.cal-side button:hover { background: var(--panel-2); }
.cal-main { padding: 12px 14px; }
.cal-tabs { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; margin-bottom: 10px; }
.cal-tabs button { border: 0; background: none; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--text); border-right: 1px solid var(--line-2); }
.cal-tabs button:last-child { border-right: 0; }
.cal-tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cal-months { display: flex; gap: 18px; flex-wrap: wrap; }
.cal-m { width: 252px; }
.cal-h { display: grid; grid-template-columns: 24px 24px 1fr 24px 24px; align-items: center; text-align: center; margin-bottom: 6px; font-size: 13px; }
.cal-nv { border: 0; background: none; cursor: pointer; font-size: 15px; color: var(--muted); padding: 0; }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-w { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 0; }
.cal-d { height: 32px; border: 0; background: none; font-size: 13px; text-align: center; line-height: 32px; color: var(--text); padding: 0; }
button.cal-d { cursor: pointer; }
button.cal-d:hover { background: var(--panel-2); border-radius: 4px; }
.cal-d.out { color: var(--faint); opacity: .5; }
.cal-d.future { color: var(--faint); background: var(--panel-2); }
.cal-d.in { background: var(--accent-soft); }
.cal-d.edge { background: var(--accent); color: #fff; font-weight: 700; border-radius: 4px; }
@media (max-width: 720px) { .cal-pop { flex-direction: column; } .cal-side { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; } .cal-m { width: 100%; } }

/* Nút "Sửa" của thanh cờ: nằm cuối dòng, nền vàng (19/10, anh Tuyến). */
.flag-bar > b { flex: 1; min-width: 0; }
.flag-edit-btn { margin-left: auto; border: 0; background: #fcd34d; color: #78350f; font-weight: 700; font-size: 12px; padding: 4px 14px; border-radius: 6px; cursor: pointer; }
.flag-edit-btn:hover { background: #fbbf24; }

/* Bộ lọc danh sách hội thoại: chỉ 3 màu xanh (teal của logo) – trắng – đen, chữ đậm (19/10, anh Tuyến). Ô đang bật = nền xanh chữ trắng. */
#list-tabs { background: var(--accent-soft); border-color: var(--accent); }
#list-tabs button { color: #111827; font-weight: 800; }
#list-tabs button.on { background: var(--accent); color: #fff; box-shadow: none; }
#list-filters .chip { font-weight: 800; font-size: 12.5px; background: #fff; color: #111827; border: 1.5px solid var(--accent); }
#list-filters .chip.danger { color: #111827; border-color: var(--accent); }
#list-filters .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Số đếm nổi ở góc phải trên của ô (kiểu huy hiệu), không ghi trong chữ của ô (19/10, anh Tuyến). */
#list-filters { padding-top: 8px; }
#list-filters .chip { position: relative; }
.fb, #list-tabs .n { position: absolute; top: -8px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; margin: 0; box-shadow: 0 0 0 2px var(--panel); }
#list-tabs button { position: relative; overflow: visible; }
#list-tabs .n { right: 10px; }

/* Chữ ô lọc + tab danh sách: IN HOA, KHÔNG in đậm (19/10, anh Tuyến — đã thử đậm rồi bỏ). */
#list-tabs button, #list-filters .chip { text-transform: uppercase; font-weight: 400 !important; letter-spacing: .02em; }
#list-filters .chip { font-size: 12px; }
#list-tabs button.on { font-weight: 400 !important; }
/* Ô lọc + tab: viền vuông (góc gần như không bo), không bo tròn (19/10, anh Tuyến). */
#list-filters .chip, #list-tabs, #list-tabs button { border-radius: 2px; }

/* Bộ lọc báo cáo: ngày + kênh + thương hiệu nằm cùng 1 hàng (19/10, anh Tuyến). */
.reports .rep-picker { margin-right: 8px; vertical-align: middle; }
.rep-sel { border: 1px solid var(--line-2); background: var(--panel); border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--text); margin: 10px 8px 14px 0; vertical-align: middle; }

#list-filters [data-change="statusFilter"] { min-width: 120px; }

/* Số đếm nổi: chỉ con số đỏ nhẹ, không nền / không viền tròn (19/10, anh Tuyến — bản tròn đỏ đặc bị nặng). */
.fb, #list-tabs .n { background: transparent; box-shadow: none; color: #ef4444; min-width: 0; height: auto; padding: 0; border-radius: 0; font-size: 12px; font-weight: 700; line-height: 1; top: -7px; right: -3px; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
#list-tabs .n { right: 12px; top: -6px; }

/* Nhóm "Cần xử lý gấp": nền cam nhạt (hơi ngả đào, không ngả vàng) thay cho đỏ (19/10, anh Tuyến — đỏ gây áp lực). */
.conv.urgent { background: #fff0e8; }
.conv.urgent:hover { background: #ffe6d8; }
.conv.urgent.on { background: #ffe6d8; outline: 2px solid var(--accent); }
.group-head.urgent { background: #fff0e8; }

/* Khung soạn tin: viền vuông, nền xanh nhạt thay cho vàng (19/10, anh Tuyến). */
.composer { background: #e6f7f4; border: 1px solid var(--accent); border-radius: 2px; }
.composer-label { color: var(--accent-2); }
.composer textarea { border-radius: 2px; border-color: var(--accent); }
.composer .btn.primary { border-radius: 2px; }
/* Khung soạn tin: bỏ viền ngoài (màu nền xanh nhạt đóng vai viền), ô gõ viền nhạt (19/10, anh Tuyến). */
.composer { border: 0; }
.composer textarea { border-color: #cfe9e4; }

/* Ô gõ tin trắng chứa luôn nút emoji / ảnh / Gửi bên trong, viền rất nhạt (19/10, anh Tuyến). */
.composer .composer-box { background: #fff; border: 1px solid #e3f1ee; border-radius: 2px; padding: 6px 8px; }
.composer .composer-box:focus-within { border-color: #b7dcd5; }
.composer .composer-box textarea { border: 0; outline: 0; background: transparent; min-height: 52px; padding: 4px 4px; width: 100%; resize: none; }
.composer .composer-box textarea:focus { outline: 0; }
.composer .composer-row { margin-top: 2px; }
/* Viền ô lọc + thanh tab danh sách: mảnh và nhạt hơn (19/10, anh Tuyến). */
#list-tabs { border: 1px solid #a7d9d0; }
#list-filters .chip, #list-filters .chip.danger { border: 1px solid #a7d9d0; }
#list-filters .chip.on { border-color: var(--accent); }
/* Tab CỦA TÔI / TẤT CẢ: trở về kiểu trắng – xám (nền xám nhạt, ô đang chọn nền trắng đổ bóng) (19/10, anh Tuyến). */
#list-tabs { background: var(--panel-2); border: 1px solid var(--line); }
#list-tabs button { color: var(--muted); }
#list-tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
/* Viền ô lọc: màu đen, mảnh 1 px (19/10, anh Tuyến). */
#list-filters .chip, #list-filters .chip.danger, #list-filters .chip.on { border: 1px solid #111827; }
/* Viền ô lọc: xám (không đen) (19/10, anh Tuyến). */
#list-filters .chip, #list-filters .chip.danger, #list-filters .chip.on { border: 1px solid #9ca3af; }

/* Form phiếu BH: ô nhập nhỏ gọn hơn (19/10, anh Tuyến). */
.form[data-form] { gap: 5px; }
.form[data-form] .field input, .form[data-form] .field select, .form[data-form] .combo input { padding: 3px 8px; height: 28px; font-size: 13px; border-radius: 5px; }
.form[data-form] .field textarea { padding: 4px 8px; min-height: 40px; font-size: 13px; border-radius: 5px; }
.form[data-form] .field .btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.form[data-form] .field > label { font-size: 12.5px; }

/* Căn cứ bảo hành: "✓ Đã chụp" nằm cùng hàng với nhãn (19/10, anh Tuyến). */
.form[data-form] .field:has(.ev-auto) { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 6px; align-items: center; }
.form[data-form] .field:has(.ev-auto) > label { grid-column: 1; }
.form[data-form] .field:has(.ev-auto) > .ev-auto { grid-column: 2; background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; font-size: 13px; }
.form[data-form] .field:has(.ev-auto) > :not(label):not(.ev-auto) { grid-column: 1 / -1; }
/* Nút "Tải ảnh từ máy" nằm cuối hàng "Căn cứ bảo hành" (19/10, anh Tuyến). */
.form[data-form] .field:has(.ev-auto) { grid-template-columns: auto 1fr auto; }
.form[data-form] .field:has(.ev-auto) > .quick { grid-column: 3; grid-row: 1; margin: 0 !important; justify-self: end; }
.form[data-form] .field:has(.ev-auto) > .pics { grid-column: 1 / -1; grid-row: 2; }
.form[data-form] .field:has(.ev-auto) > .quick { grid-column: 3 !important; }
.form[data-form] .field:has(.ev-auto) > label, .form[data-form] .field:has(.ev-auto) > .ev-auto { grid-row: 1; }
/* Bốn ô lọc xếp 2 hàng × 2 ô, mỗi ô rộng đều nhau (19/10, anh Tuyến). */
#list-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 8px; }
#list-filters .chip, #list-filters select.chip { width: 100%; min-width: 0 !important; justify-content: center; text-align: center; box-sizing: border-box; padding-left: 6px; padding-right: 6px; }

/* Xem dữ liệu phiếu: bảng tên ô → giá trị (20/10) */
.ticket-kv { grid-template-columns: 170px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ticket-kv > div { padding: 8px 12px; border-bottom: 1px solid var(--line); word-break: break-word; }
.ticket-kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.ticket-kv .k { background: var(--bg, #f4f6f8); }
.new-toggle { all: unset; cursor: pointer; font: inherit; text-transform: inherit; letter-spacing: inherit; color: var(--ink, inherit); }
.new-toggle:hover { color: var(--teal, #0f766e); }
.new-toggle:focus-visible { outline: 2px solid var(--teal, #0f766e); outline-offset: 2px; }

/* Quản trị → AI → câu hỏi nhanh: 2 công tắc rõ ràng (21/10). Phải đè `.field input { width: 100% }` — lỗi 21/10: ô tick bị kéo rộng hết dòng, chữ bị ép vào mép phải. */
.field .quick-opts { display: grid; gap: 8px; margin: 8px 0 10px; }
.field .qopt { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 400; color: var(--ink, inherit); text-transform: none; letter-spacing: 0; cursor: pointer; }
.field .qopt input[type="checkbox"] { width: 16px; height: 16px; min-width: 16px; padding: 0; margin: 2px 0 0; flex: none; }
.field .qopt span { flex: 1; min-width: 0; line-height: 1.45; }

/* ---------- Menu trái hiện tên chức năng, thu gọn được (21/10, anh Tuyến) ----------
   Nút « / » ở đầu menu; mỗi máy tự nhớ (app.js → railWide). Chỉ mở rộng khi màn hình ≥ 1300px: hộp thư 3 cột cần
   ~1.050px, menu có chữ 248px (đủ cho "Danh sách phiếu bảo hành") — màn nhỏ hơn luôn chỉ biểu tượng. Điện thoại (≤ 980px, thanh dưới đáy) không đổi. */
.rail .lbl { display: none; }
.rail-top { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 8px; }
.rail-top .logo { margin-bottom: 0; }
.rail .rail-toggle { width: 36px; height: 28px; border-radius: 8px; }
.rail .rail-toggle svg { width: 18px; height: 18px; }
@media (max-width: 1299px) { .rail .rail-toggle { display: none; } }
@media (max-width: 980px) { .rail-top { display: none; } }
@media (min-width: 1300px) {
  .shell.rail-wide { grid-template-columns: 212px 1fr; }
  .rail-wide .rail { align-items: stretch; padding: 12px 10px; }
  .rail-wide .rail .lbl { display: block; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
  .rail-wide .rail-top { flex-direction: row; gap: 6px; padding: 0 0 0 4px; margin-bottom: 14px; }
  .rail-wide .rail-top .logo { width: 30px; height: 30px; }
  .rail-wide .rail-top .brand { font-weight: 700; font-size: 15px; color: #fff; }
  .rail-wide .rail button:not(.rail-toggle) { width: 100%; height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 12px; font-size: 14px; font-weight: 500; }
  .rail-wide .rail button svg { flex: none; }
  .rail-wide .rail .dot { position: static; flex: none; }
  .rail-wide #me-avatar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 2px; color: rgba(255, 255, 255, .85); font-size: 13px; }
}

/* Trang Sản phẩm (21/10) */
.catalog .cat-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; flex-wrap: wrap; }
.cat-tabs { display: flex; gap: 6px; }
.cat-tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--ink, inherit); }
.cat-tabs button.on { background: #111827; color: #fff; border-color: #111827; }
.cat-tabs button.on .minor { color: #cbd5e1; }
.cat-bar input[type="search"] { width: 320px; max-width: 100%; }
.cat-table td { vertical-align: top; }
.cat-desc { font-size: 13px; line-height: 1.45; color: var(--ink, inherit); }
.cat-prices { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cat-prices td { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.cat-prices tr:last-child td { border-bottom: 0; }
.cat-prices td.num { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 10px; }

/* Tab "Nạp rule" (22/10) */
.rule-form textarea { width: 100%; resize: vertical; min-height: 120px; }
.rule-old { background: var(--panel-2, #f4f6f8); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
.rule-old .old-text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; color: var(--ink, inherit); }
.tabs button[data-tab="rule"] { color: #b45309; font-weight: 700; }

/* Nạp rule theo từng câu hỏi (22/10) */
.rule-item { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line); }
.rule-item:last-child { border-bottom: 0; margin-bottom: 0; }
.rule-q { font-size: 13px; line-height: 1.4; margin-bottom: 8px; padding: 8px 10px; border-left: 3px solid #0f766e; background: var(--panel-2, #f4f6f8); border-radius: 0 8px 8px 0; }
.rule-done { font-size: 13px; color: #047857; padding: 6px 0; }

/* Sửa mô tả sản phẩm ngay trên tab Sản phẩm (22/10) */
.cat-edit { cursor: pointer; font-size: 12px; color: var(--teal, #0f766e); white-space: nowrap; }
.cat-desc textarea { width: 100%; resize: vertical; }
.cat-desc-foot { display: flex; gap: 6px; margin-top: 6px; }

/* Cột "Nhân viên phụ trách" (Cài đặt → 2): ô xổ xuống chọn nhiều người (anh Tuyến 23/10) */
.assign-dd { position: relative; display: inline-block; min-width: 200px; max-width: 320px; }
.assign-dd > summary { list-style: none; cursor: pointer; border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 26px 4px 8px; background: var(--panel); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.assign-dd > summary::-webkit-details-marker { display: none; }
.assign-dd > summary::after { content: '▾'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.assign-dd[open] > summary { border-color: var(--accent, var(--line-2)); }
.assign-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); padding: 6px 10px; display: grid; gap: 6px; }
.assign-menu .check { white-space: nowrap; }

/* Trang Quản trị: CHỈ tiêu đề mục lớn (1. Kết nối sàn, 2. …) nền xanh chữ trắng đậm, giống nút chính (anh Tuyến 23/10).
   Mục con (1.1, 1.2…) và các trang khác giữ kiểu cũ. */
/* Màu cố định #0f766e (= màu nút chính ở giao diện sáng): giao diện tối có --accent sáng, chữ trắng sẽ khó đọc. */
.admin-page > .card > h2 { background: #0f766e; color: #fff; font-weight: 700; border-bottom-color: #0f766e; border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.admin-page > .card > h2 .minor, .admin-page > .card > h2 .hint { color: rgba(255, 255, 255, .85); }
/* Trang Quản trị: nền xanh chỉ dành cho tiêu đề mục lớn → các nút "chính" trong trang về kiểu nút thường. */
.admin-page .btn.primary { background: var(--panel); border-color: var(--line-2); color: var(--text); }
