:root {
  /* Màu thương hiệu Bảo Vy (xanh ngọc trong logo) */
  --brand: #0097ad;
  --brand-dark: #007a8c;
  --brand-soft: #e3f5f8;
  --brand-softer: #f2fafc;
  --bg: #eef2f4;
  --panel: #ffffff;
  --line: #e3e8eb;
  --text: #1c2b33;
  --muted: #66757d;
  --bubble-out: #0097ad;
  --danger: #e0393e;
  --warn-bg: #fff6dd;
  --warn: #8a5a00;
  --msg-color: #2f6fe4;
  --cmt-color: #d6417f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body {
  font: 14.5px/1.5 "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-dark); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd8dc; border-radius: 8px; }

/* ---------- Khung chính ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px auto 1fr; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: linear-gradient(90deg, var(--brand-dark), var(--brand)); color: #fff;
}
.logo { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo img { height: 34px; width: auto; }
.logo .word { font-family: "Playfair Display", Georgia, serif; font-size: 18px; font-weight: 600; letter-spacing: .3px; line-height: 1.1; }
.logo .word small { display: block; font-family: "Be Vietnam Pro", sans-serif; font-size: 10px; letter-spacing: 2.5px; opacity: .8; font-weight: 400; }
.topbar select {
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 6px 12px; max-width: 240px;
}
.topbar select option { color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .btn-top {
  background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 999px; padding: 7px 14px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.topbar .btn-top:hover { background: rgba(255,255,255,.28); }
.unread-pill { background: #fff; color: var(--brand-dark); border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.me-dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.user-menu { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; background: var(--panel); color: var(--text); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.16); min-width: 210px; padding: 6px; z-index: 50;
}
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--bg); }
.menu .who { padding: 8px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.main { display: grid; grid-template-columns: 360px minmax(0, 1fr) 310px; min-height: 0; min-width: 0; }

/* ---------- Danh sách hội thoại ---------- */
.list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.search-row { display: flex; gap: 6px; }
.search {
  flex: 1; min-width: 0; padding: 9px 12px 9px 34px; border: 1px solid transparent; border-radius: 999px; background: var(--bg)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366757d' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.search:focus { outline: none; border-color: var(--brand); background-color: #fff; }
.tag-filter { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 13px; max-width: 130px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: 13px; white-space: nowrap; flex-shrink: 0;
}
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.convs { overflow-y: auto; flex: 1; }
.conv {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 11px; padding: 11px 12px; cursor: pointer; align-items: center;
  border-left: 3px solid transparent; position: relative;
}
.conv + .conv::before { content: ""; position: absolute; top: 0; left: 71px; right: 0; border-top: 1px solid #f0f3f5; }
.conv:hover { background: var(--brand-softer); }
.conv.active { background: var(--brand-soft); border-left-color: var(--brand); }
.conv .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.conv.unread .name { font-weight: 700; }
.conv.unread .last { font-weight: 600; color: var(--text); }
.conv .last { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.conv .meta { text-align: right; font-size: 12px; color: var(--muted); display: grid; gap: 5px; justify-items: end; align-self: start; padding-top: 2px; }
.conv.unread .meta .time { color: var(--brand-dark); font-weight: 600; }
.conv .sub { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 3px; min-width: 0; }
.conv .sub .page { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; font-weight: 700; min-width: 20px; text-align: center; }
.owner { font-size: 11px; background: var(--bg); border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.dots { display: inline-flex; gap: 3px; flex-shrink: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.phone-ic { color: #16a34a; flex-shrink: 0; display: inline-flex; }
.phone-ic svg { width: 13px; height: 13px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.more { margin: 12px auto; display: block; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; }

.av-wrap { position: relative; width: 48px; height: 48px; flex-shrink: 0; }
.av-wrap.sm { width: 38px; height: 38px; }
.av-wrap .kind-ic {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.av-wrap.sm .kind-ic { width: 17px; height: 17px; }
.kind-ic.message { background: var(--msg-color); }
.kind-ic.comment { background: var(--cmt-color); }
.kind-ic svg { width: 10px; height: 10px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #cbd5e1; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}
.avatar.sm { width: 38px; height: 38px; font-size: 13px; }
.avatar.lg { width: 76px; height: 76px; font-size: 26px; }

/* ---------- Khung chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); min-height: 62px;
}
.chat-head .title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 13px; max-width: 170px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.back, .info-btn { display: none; }
.post-box {
  margin: 12px 16px 0; padding: 10px 14px; background: #fff; border: 1px solid #f6d3e3; border-left: 4px solid var(--cmt-color);
  border-radius: 10px; font-size: 13px; color: #5b2140; max-height: 92px; overflow: auto; white-space: pre-wrap;
}
.post-box b { color: var(--cmt-color); }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; background: var(--brand-softer); }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 12px 0 6px; background: #fff; border-radius: 999px; padding: 2px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.msg { max-width: 70%; display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.in .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 6px; }
.msg.out .bubble a { color: #fff; }
.msg.hidden .bubble { opacity: .6; border: 1px dashed #9aa7ae; background: #f7f7f7; }
.msg img.att { max-width: 260px; border-radius: 14px; margin-top: 4px; display: block; border: 1px solid var(--line); }
.msg .info { font-size: 11.5px; color: var(--muted); margin: 3px 8px 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.msg .info button { background: none; border: 0; padding: 0; color: var(--brand-dark); font-size: 11.5px; font-weight: 600; }
.msg .info button:hover { text-decoration: underline; }
.msg .info .hidden-flag { color: var(--danger); font-weight: 600; }
.msg.target .bubble { box-shadow: 0 0 0 2px #f5a524; }

.warn { margin: 0 16px 8px; padding: 8px 12px; background: var(--warn-bg); color: var(--warn); border-radius: 10px; font-size: 13px; }
.composer { border-top: 1px solid var(--line); padding: 10px 16px 12px; position: relative; background: #fff; }
.composer .modes { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.qr-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; }
.qr-chips::-webkit-scrollbar { display: none; }
.qr-chip { border: 1px dashed #9fd3dc; background: var(--brand-softer); color: var(--brand-dark); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }
.qr-chip:hover { background: var(--brand-soft); border-style: solid; }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 1px solid var(--line); border-radius: 22px; padding: 10px 16px; min-height: 44px; max-height: 160px;
  background: var(--bg);
}
.composer textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
.send { background: var(--brand); color: #fff; border: 0; border-radius: 22px; padding: 0 20px; height: 44px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.send svg { width: 16px; height: 16px; }
.send:hover { background: var(--brand-dark); }
.send:disabled { opacity: .5; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.qr-pop {
  position: absolute; bottom: 100%; left: 16px; right: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 -8px 24px rgba(0,0,0,.1); max-height: 260px; overflow: auto; z-index: 10;
}
.qr-pop div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
.qr-pop div.on, .qr-pop div:hover { background: var(--brand-soft); }
.qr-pop b { color: var(--brand-dark); margin-right: 6px; }
.placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-direction: column; gap: 12px; background: var(--brand-softer); }
.placeholder img { width: 84px; opacity: .15; }

/* ---------- Thông tin khách ---------- */
.info-panel { background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px; }
.info-panel .card { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.info-panel .who { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.info-panel .who b { font-size: 16.5px; margin-top: 4px; }
.info-panel h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; display: flex; align-items: center; }
.info-panel .lbl { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.info-panel .lbl.first { margin-top: 0; }
.field { width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.field { min-height: 96px; resize: vertical; }
.phone-row { display: flex; gap: 6px; }
.phone-row a { padding: 8px 12px; border-radius: 9px; background: #e8f7ee; color: #15803d; text-decoration: none; white-space: nowrap; font-weight: 600; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { border-radius: 999px; padding: 4px 11px; font-size: 12.5px; border: 1px solid currentColor; background: var(--panel); }
.tag.on { color: #fff !important; border-color: transparent; }
.other-conv { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: none; margin-bottom: 6px; font-size: 13px; }
.other-conv:hover { border-color: var(--brand); }
.saved { color: #15803d; font-size: 11px; margin-left: auto; text-transform: none; letter-spacing: 0; }

/* ---------- Cài đặt ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12,32,40,.5); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow: auto; }
.modal { background: var(--panel); border-radius: 16px; width: 100%; max-width: 880px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.modal.small { max-width: 420px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; flex: 1; font-size: 18px; }
.x { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 12px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tabs button.on { border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.modal-body { padding: 20px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 14px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.fb { background: #1877f2; border-color: #1877f2; color: #fff; font-weight: 600; text-decoration: none; display: inline-block; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
table.grid select.field { min-width: 110px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; margin-bottom: 16px; padding: 14px; background: var(--brand-softer); border: 1px solid var(--brand-soft); border-radius: var(--radius); }
.form-grid label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.page-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.form-grid .page-checks label, .page-checks label { display: inline-flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; }
.note { color: var(--muted); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #10252d; color: #fff; padding: 10px 18px;
  border-radius: 12px; z-index: 200; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); }
.demo-bar { background: var(--warn-bg); color: var(--warn); padding: 6px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid #f3e1a8; }
.demo-bar b { white-space: nowrap; }
.demo-bar .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-bar .btn { padding: 3px 10px; font-size: 12.5px; white-space: nowrap; }

/* ---------- Máy tính bảng ---------- */
@media (max-width: 1150px) {
  .main { grid-template-columns: 320px minmax(0, 1fr); }
  .info-panel { display: none; position: fixed; right: 0; top: 56px; bottom: 0; width: min(330px, 100vw); z-index: 40; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
  .show-info .info-panel { display: block; }
  .info-btn { display: inline-flex; }
}
/* ---------- Điện thoại ---------- */
@media (max-width: 760px) {
  .app { grid-template-rows: 50px auto 1fr; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .chat { display: none; }
  .has-conv .list { display: none; }
  .has-conv .chat { display: flex; }
  .back { display: inline-flex; }
  .topbar { gap: 8px; padding: 0 10px; }
  .logo img { height: 28px; }
  .logo .word, .hide-sm, #userName { display: none; }
  .topbar > * { flex-shrink: 0; }
  .topbar select { flex-shrink: 1; min-width: 0; }
  .tag-filter { max-width: 100px; }
  .topbar .hide-sm { display: none; }
  .topbar select { max-width: none; flex: 1; }
  .topbar .spacer { display: none; }
  .topbar select { max-width: 120px; padding: 5px 10px; font-size: 13px; }
  .topbar .btn-top { padding: 6px 10px; }
  .info-panel { top: 50px; }
  .list-head { padding: 10px 10px 6px; }
  .conv { padding: 10px; }
  .chat-head { padding: 6px 8px; gap: 8px; min-height: 56px; }
  .chat-head select { max-width: 96px; padding: 5px 8px; font-size: 12px; }
  .chat-head .title { font-size: 15px; }
  .post-box { margin: 8px 10px 0; max-height: 64px; }
  .msgs { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .composer { padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; }   /* tránh iPhone tự phóng to khi gõ */
  .send { padding: 0 15px; }
  .send span { display: none; }
  .hint { display: none; }
  .demo-bar b { white-space: nowrap; }
.demo-bar .txt { display: none; }
  .overlay { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}

/* ---------- Trợ lý AI ---------- */
.human-flag { font-size: 10.5px; font-weight: 600; color: #b45309; background: #fef3c7; border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.msg.out.ai .bubble { background: linear-gradient(135deg, #7c5cff, #5b8def); }
.ai-by { color: #6d5ce8; font-weight: 500; }
.qr-chip.ai { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #c9bfff; background: #f4f1ff; color: #5b45d6; font-weight: 600; }
.qr-chip.ai:hover { background: #ebe5ff; }
.qr-chip.ai svg { width: 13px; height: 13px; }
.qr-chip.ai:disabled { opacity: .7; cursor: wait; }
.ai-toggle { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; white-space: nowrap; }
.ai-toggle svg { width: 15px; height: 15px; }
.ai-toggle.on { border-color: #c9bfff; background: #f4f1ff; color: #5b45d6; font-weight: 600; }
.handoff { margin: 0 16px 8px; padding: 8px 12px; background: #fef3c7; color: #92400e; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.handoff .btn { margin-left: auto; padding: 4px 10px; font-size: 12.5px; }
.ai-status { margin-bottom: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ok-pill, .warn-pill { font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; }
.ok-pill { background: #dcfce7; color: #166534; }
.warn-pill { background: #fef3c7; color: #92400e; }
.ai-explain { background: var(--brand-softer); border: 1px solid var(--brand-soft); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; font-size: 13.5px; margin-bottom: 16px; }
.ai-test { display: flex; gap: 8px; }
.ai-test .field { flex: 1; }
@media (max-width: 760px) { .ai-toggle span { display: none; } .ai-toggle { padding: 6px; } }
.form-grid label.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--text); justify-self: start; }
.form-grid label.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

/* Nút kết nối TikTok */
.btn.tt { background: #000; border-color: #000; color: #fff; font-weight: 600; text-decoration: none; display: inline-block; }

/* Màn hình Kết nối kênh (kiểu Pancake) */
.ch-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.ch-tabs { display: flex; gap: 6px; border: 1px solid var(--line, #e5e7eb); border-radius: 12px; padding: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.ch-tab { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; color: inherit; }
.ch-tab.on { background: #dbeafe; }
.ch-tab b { font-size: 12px; background: #e5e7eb; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.ch-tab.on b { background: #3b82f6; color: #fff; }
.ch-all { display: inline-flex; width: 18px; height: 18px; border-radius: 5px; background: #64748b; color: #fff; font-size: 12px; align-items: center; justify-content: center; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ch-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line, #e5e7eb); border-radius: 12px; padding: 12px; background: var(--card, #fff); }
.ch-card .avatar { width: 56px; height: 56px; border-radius: 10px; flex-shrink: 0; }
.ch-info { min-width: 0; flex: 1; }
.ch-info > b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted, #64748b); margin-top: 4px; }
.ch-sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.ch-empty { grid-column: 1/-1; text-align: center; padding: 28px; color: var(--muted, #64748b); border: 1px dashed var(--line, #e5e7eb); border-radius: 12px; }
.ch-connect { border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.ch-connect b svg { vertical-align: -4px; margin-right: 4px; }
.ch-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.ch-pick button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; border: 1px solid var(--line, #e5e7eb); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; }
.ch-pick button:hover { border-color: #3b82f6; }
.ch-pick span { font-weight: 700; }
.ch-pick small { color: var(--muted, #64748b); }
@media (max-width: 560px) { .ch-pick { grid-template-columns: 1fr; } .ch-head { flex-wrap: wrap; } }

/* Ô dán khóa kết nối */
details.cred { margin-top: 12px; background: #fff; border: 1px solid var(--line, #e5e7eb); border-radius: 10px; padding: 10px 12px; }
details.cred summary { cursor: pointer; font-weight: 600; }
.cp-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 8px; align-items: center; margin: 4px 0; }
.cp-row code { background: #f1f5f9; padding: 4px 8px; border-radius: 6px; font-size: 12px; overflow-wrap: anywhere; }
.ai-key { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.ai-key label { flex: 1; }
@media (max-width: 560px) { .cp-row { grid-template-columns: 1fr auto; } .cp-row .note { grid-column: 1/-1; } }
