:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e3e8ee;
  --text: #1f2933;
  --muted: #6b7684;
  --primary: #2f6fed;
  --primary-d: #2456c4;
  --danger: #d64545;
  --ok: #2e9e5b;
  --warn: #e0a100;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
#app { height: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
}
button:hover { border-color: #cdd6e0; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-d); }
button.danger { color: var(--danger); border-color: #f0c4c4; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,237,.25); border-color: var(--primary); }
textarea { resize: vertical; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); padding: 24px 12px; text-align: center; }
.badge {
  display: inline-block;
  background: #eef2f7;
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}
.badge.admin { background: #fdeede; color: #b07a00; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.spread { justify-content: space-between; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1f2933;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-width: 80vw;
}
.toast.err { background: var(--danger); }

/* login */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 22px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.login-card label input { margin-top: 5px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* shell */
.shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  width: 100%;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .brand-hub { color: var(--primary); }
.tabs { display: flex; gap: 6px; }
.tabs button { border: none; background: transparent; color: var(--muted); padding: 6px 12px; white-space: nowrap; }
.tabs button.active { color: var(--primary); background: #eef3ff; border-radius: 8px; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); white-space: nowrap; }
.who b { color: var(--text); }

/* workspace */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px 1fr 300px; }
.col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--panel); }
.col.side { border-right: none; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.col-head h2 { margin: 0; }
.col-body { flex: 1; overflow: auto; padding: 10px; }

/* conv list */
.conv {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 4px;
}
.conv:hover { background: #f6f8fb; }
.conv.active { background: #eef3ff; border-color: #d6e2ff; }
.conv .t { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.conv .t .status { margin-left: auto; }
.conv .m { color: var(--muted); font-size: 13px; margin: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.status { font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.status.open { background: #e6f6ec; color: var(--ok); }
.status.closed { background: #f1f3f5; color: var(--muted); }
.unread { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; }

/* thread */
.thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.thread-head .tt { font-weight: 700; font-size: 15px; }
.thread-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.thread-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.thread.dragover { outline: 2px dashed var(--primary); outline-offset: -6px; background: #f5f9ff; }

/* message */
.msg { max-width: 78%; }
.msg.out { align-self: flex-end; }
.msg.in { align-self: flex-start; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.msg.out .who { text-align: right; }
.msg > div:not(.who):not(.msg-img):not(.link-card) {
  background: #f1f4f8;
  border-radius: 10px;
  padding: 8px 12px;
  word-break: break-word;
}
.msg.out > div:not(.who):not(.msg-img):not(.link-card) { background: #e3edff; }
.msg .caption { margin-top: 6px; }
.msg .att { color: var(--muted); }
.msg .att.missing { color: var(--warn); }
.att-link { display: inline-block; background: #f1f4f8; padding: 8px 12px; border-radius: 10px; }
.msg.out .att-link { background: #e3edff; }

/* image */
.msg-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  object-fit: contain;
  background: #000;
}

/* link card */
.link-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 340px;
  color: var(--text);
}
.link-card:hover { text-decoration: none; border-color: #cdd6e0; background: #f2f6fc; }
.link-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.link-body { min-width: 0; }
.link-title { font-weight: 700; font-size: 13px; }
.link-desc { color: var(--muted); font-size: 12px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-host { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* composer */
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; }
.composer .send { align-self: stretch; }
.attach {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
}
.attach:hover { border-color: var(--primary); background: #f5f9ff; }
.file-input { display: none; }

/* side */
.block { margin-bottom: 18px; }
.block .row { margin-top: 8px; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.kv .k { color: var(--muted); }
.note { background: #fbfcfe; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.note .by { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.note-form { display: flex; gap: 8px; margin-top: 8px; }

/* admin */
.shell > .admin { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.admin-inner { max-width: 1200px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.zalo-state { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f3f5; color: var(--muted); }
.pill.connected { background: #e6f6ec; color: var(--ok); }
.pill.waiting_qr { background: #fdeede; color: #b07a00; }
.qr { margin-top: 14px; text-align: center; }
.qr img { max-width: 240px; border: 1px solid var(--border); border-radius: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.btns { display: flex; gap: 6px; }
.filter { max-width: 240px; }
.table-wrap { max-height: 60vh; overflow: auto; }
.table-wrap table th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.table-wrap td.detail { word-break: break-all; }

/* responsive: 700–1100px -> hide side, show as drawer */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 320px 1fr; }
  .col.side {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    z-index: 60;
    transform: translateX(100%);
    transition: transform .2s ease;
    box-shadow: -6px 0 20px rgba(16, 24, 40, .18);
    border-right: none;
    border-left: 1px solid var(--border);
  }
  .workspace.side-open .col.side { transform: translateX(0); }
  .side-scrim {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .35);
    z-index: 55;
    display: none;
  }
  .workspace.side-open .side-scrim { display: block; }
  .grid { grid-template-columns: 1fr; }
}

/* responsive: <700px -> single column */
@media (max-width: 700px) {
  .workspace { grid-template-columns: 1fr; }
  .col.list { display: flex; }
  .col.thread { display: none; }
  .workspace.show-thread .col.list { display: none; }
  .workspace.show-thread .col.thread { display: flex; }
  .col.side { width: 320px; }
  .topbar { gap: 10px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  .tabs button { padding: 6px 8px; }
  .who { display: none; }
  .msg { max-width: 88%; }
  .thread-head { flex-wrap: wrap; }
  .thread-head .actions { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== Bố cục chuẩn (Claude, ghi đè các quy tắc phía trên) ===== */
html, body, #app { height: 100%; margin: 0; }
.shell { display: flex !important; flex-direction: column !important; height: 100dvh; min-height: 0; }
.topbar { flex: 0 0 auto; width: 100%; box-sizing: border-box; display: flex !important; flex-direction: row !important;
  align-items: center; gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 30; background: var(--panel, #fff);
  border-bottom: 1px solid var(--border, #e5e7eb); }
.topbar .brand, .topbar .tabs button, .topbar .userbox, .topbar .userbox button { white-space: nowrap; }
.topbar .tabs { display: flex; gap: 4px; }
.topbar .userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar .who { display: flex; align-items: center; gap: 6px; }
.workspace, .shell > .admin { flex: 1 1 auto; min-height: 0; }
.shell > .admin { overflow: auto; padding: 16px; box-sizing: border-box; }
.admin > .grid, .admin .admin-inner { max-width: 1200px; margin: 0 auto; }
.admin .grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.admin table { width: 100%; border-collapse: collapse; }
.admin td { word-break: break-word; }
#audit-body td:last-child { word-break: break-all; max-width: 380px; }
.workspace { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; overflow: hidden; position: relative; }
.col { min-height: 0; overflow: hidden; }
.col.thread > .thread { flex: 1; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.col.side { overflow: auto; }
.messages { flex: 1 1 auto; min-height: 0; overflow: auto; }
.composer { flex: 0 0 auto; }
.msg-img { max-width: min(320px, 100%); height: auto; }
.thread-head .back, .thread-head .info-toggle { display: none; }
.side-scrim { display: none; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .col.side { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 90vw); z-index: 20;
    transform: translateX(100%); transition: transform .2s; box-shadow: -4px 0 16px rgba(0,0,0,.12); }
  .workspace.side-open .col.side { transform: none; }
  .workspace.side-open .side-scrim { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.2); z-index: 15; }
  .thread-head .info-toggle { display: inline-flex; }
}
@media (max-width: 900px) {
  .admin .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .topbar { padding: 6px 10px; gap: 6px; }
  .topbar .who { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace .col.thread { display: none; }
  .workspace.show-thread .col.list { display: none; }
  .workspace.show-thread .col.thread { display: flex; }
  .thread-head .back { display: inline-flex; }
  .thread-head { flex-wrap: wrap; }
  .shell > .admin { padding: 10px; }
  .admin table { display: block; overflow-x: auto; }
}

/* ===== Cuộc gọi, cảm xúc, thu hồi, đang soạn (từ gói Qwen) ===== */
.bubble .caption { margin-top: 6px; color: var(--muted); font-size: 13px; }
.bubble .att { margin-top: 6px; color: var(--muted); font-size: 13px; }
.bubble .att.missing { color: var(--danger); }
.att-link { display: inline-block; margin-top: 2px; }
.msg-img {
  max-width: 260px;
  max-height: 260px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
}
/* link card */
.link-card {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  max-width: 300px;
}
/* call pill */
.msg.call { align-self: center; max-width: none; }
.call-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.call-pill .call-ico { font-size: 15px; }
.call-pill .call-body { font-weight: 600; }
.call-pill .call-time { color: var(--muted); font-size: 12px; }
.call-pill.missed .call-body { color: var(--danger); }
.call-pill.missed { border-color: #f3c9c9; }
/* system line */
.msg.system { align-self: center; max-width: none; }
.system-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  background: #f4f6f9;
  border-radius: 999px;
  padding: 4px 12px;
}
.system-line .system-time { opacity: .8; }
/* recalled */
.recalled { font-style: italic; color: var(--muted); }
.recalled-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  background: #eef1f5;
  border-radius: 999px;
  padding: 1px 8px;
  margin-bottom: 4px;
}
.recalled-body { opacity: .6; text-decoration: line-through; text-decoration-color: rgba(123, 135, 148, .5); }
/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 4px 0; }
.msg.out .reactions { justify-content: flex-end; }
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: default;
}
/* delivery */
.delivery { font-size: 11px; color: var(--muted); margin: 4px 4px 0; }
/* typing */
.typing-line {
  padding: 4px 16px 0;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.typing-dots { display: inline-flex; gap: 3px; margin-left: 2px; }
@keyframes typingBlink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ===== Điện thoại gọn kiểu Zalo (Claude) ===== */
.thread-head { position: relative; }
.thread-head .tt-wrap { flex: 1 1 auto; min-width: 0; }
.thread-head .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .more { display: none; }
@media (max-width: 1100px) { .thread-head .info-toggle { display: inline-flex; } }
@media (max-width: 700px) {
  /* đang xem hội thoại: ẩn thanh trên cùng, dành chỗ cho tin nhắn */
  .shell:has(.workspace.show-thread) .topbar { display: none !important; }
  .thread-head { flex-wrap: nowrap !important; gap: 6px; padding: 6px 8px; min-height: 48px; box-sizing: border-box; }
  .thread-head .back { display: inline-flex !important; font-size: 28px; line-height: 1; padding: 2px 10px 6px; border: 0; background: none; }
  .thread-head .tt { font-size: 16px; }
  .thread-head .sub { font-size: 12px; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-head .more { display: inline-flex; font-size: 22px; padding: 2px 10px; border: 0; background: none; }
  .thread-head .actions { display: none !important; }
  .thread-head.menu-open .actions { display: flex !important; flex-direction: column; position: absolute; right: 8px; top: 46px; z-index: 40;
    background: var(--panel, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 6px; gap: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 170px; }
  .thread-head.menu-open .actions button { display: block !important; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; }
  .thread-head.menu-open .actions .back { display: none !important; }
  .messages { padding: 10px 8px; gap: 8px; }
  .composer { padding: 6px 8px; gap: 6px; align-items: center; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .composer .attach { border: 0; background: none; font-size: 20px; padding: 6px; }
  .composer textarea { min-height: 38px; max-height: 120px; padding: 8px 12px; border-radius: 20px; resize: none; font-size: 16px; }
  .composer .send { align-self: center; width: 40px; height: 40px; min-width: 40px; border-radius: 50%; padding: 0; font-size: 18px; }
  /* danh sách: thanh trên gọn */
  .topbar { min-height: 44px; }
  .topbar .brand { font-size: 15px; }
  .col.list .col-head { padding: 8px 12px; }
  .conv { padding: 10px 12px; }
}
.thread-head .presence { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.thread-head .pres { font-size: 12px; color: #92400e; background: #fef3c7; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.thread-head .pres.typing { color: #1e40af; background: #dbeafe; }
.composer .send.sending { opacity: .6; cursor: progress; }
.remember { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.remember input { width: auto; }
.sends { margin-top: 10px; }
@media (max-width: 700px) { .thread-head .presence { margin-top: 0; } }

/* ===== Chuyển tiếp ===== */
.msg { position: relative; }
.fwd-btn { position: absolute; top: 4px; opacity: 0; border: 1px solid var(--border, #e5e7eb); background: var(--panel, #fff);
  border-radius: 50%; width: 28px; height: 28px; padding: 0; font-size: 14px; line-height: 1; cursor: pointer; transition: opacity .15s; }
.msg.in .fwd-btn, .msg:not(.out) .fwd-btn { right: -34px; }
.msg.out .fwd-btn { left: -34px; right: auto; }
.msg:hover .fwd-btn, .fwd-btn:focus { opacity: 1; }
.fwd-from { font-size: 12px; color: var(--muted, #6b7280); font-style: italic; margin-bottom: 2px; }
.fwd-modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.fwd-card { background: var(--panel, #fff); border-radius: 14px; width: min(420px, 100%); max-height: 80dvh; display: flex; flex-direction: column; gap: 8px; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.fwd-head { display: flex; justify-content: space-between; align-items: center; }
.fwd-close { border: 0; background: none; font-size: 18px; cursor: pointer; }
.fwd-preview { font-size: 13px; color: var(--muted, #6b7280); background: #f3f4f6; border-radius: 8px; padding: 6px 10px; white-space: pre-wrap; max-height: 80px; overflow: hidden; }
.fwd-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; min-height: 120px; }
.fwd-item { text-align: left; border: 0; background: none; padding: 10px; border-radius: 8px; cursor: pointer; }
.fwd-item:hover { background: #eff6ff; }
@media (max-width: 700px), (hover: none) {
  .fwd-btn { opacity: .55; position: static; display: inline-flex; align-items: center; justify-content: center; margin-top: 2px; width: 26px; height: 26px; }
  .fwd-modal { align-items: flex-end; padding: 0; }
  .fwd-card { border-radius: 14px 14px 0 0; width: 100%; max-height: 75dvh; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
.fwd-sec { font-size: 12px; font-weight: 600; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px 2px; }
.fwd-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.fwd-sub { font-size: 11px; color: var(--muted, #6b7280); white-space: nowrap; }
.fwd-preview, .fwd-head, .fwd-search { flex-shrink: 0; }
.col-head .new-chat { margin-left: auto; margin-right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--primary, #2563eb); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }

/* ===== Nhiều số Zalo ===== */
.acc-row { border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 10px 12px; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.acc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-btns button { padding: 5px 10px; font-size: 13px; }
.acc-add { display: flex; gap: 8px; margin-top: 12px; }
.acc-add input { flex: 1; min-width: 0; }
.acc-row .qr img { width: 220px; max-width: 100%; }
.acc-filter { margin-left: 8px; max-width: 140px; font-size: 13px; padding: 4px 6px; }
.acc-tag { color: var(--muted, #6b7280); }
.acc-perm { font-size: 13px; }
.acc-cb { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.acc-cb input { width: auto; }
.fwd-acc { flex-shrink: 0; }
.col-head h2 { white-space: nowrap; }

/* ===== Thả cảm xúc ===== */
.msg-tools { position: absolute; top: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.msg:not(.out) .msg-tools { right: -66px; }
.msg.out .msg-tools { left: -66px; }
.msg:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-tools .fwd-btn { position: static; opacity: 1; }
.react-btn { border: 1px solid var(--border, #e5e7eb); background: var(--panel, #fff); border-radius: 50%; width: 28px; height: 28px; padding: 0; font-size: 15px; line-height: 1; cursor: pointer; }
.react-pop { position: absolute; z-index: 50; top: -40px; display: flex; gap: 2px; background: var(--panel, #fff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 22px; padding: 4px 6px; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.msg:not(.out) .react-pop { left: 0; }
.msg.out .react-pop { right: 0; }
.react-opt { border: 0; background: none; font-size: 22px; line-height: 1; padding: 4px; border-radius: 50%; cursor: pointer; transition: transform .1s; }
.react-opt:hover { transform: scale(1.25); }
.react-opt.on { background: #dbeafe; }
@media (max-width: 700px), (hover: none) {
  .msg-tools { position: static; opacity: .6; margin-top: 2px; }
  .msg-tools .fwd-btn, .react-btn { width: 26px; height: 26px; }
  .react-pop { top: auto; bottom: 34px; }
}

/* ===== Ảnh / File / Link ở cột phải ===== */
.media-block summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.media-block summary::-webkit-details-marker { display: none; }
.media-block summary h3 { margin: 0; }
.media-count { font-size: 12px; color: var(--muted, #6b7280); background: #f3f4f6; border-radius: 10px; padding: 0 8px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.media-grid a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: #f3f4f6; }
.media-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.media-file, .media-link { display: flex; gap: 8px; align-items: center; padding: 6px 4px; border-radius: 6px; text-decoration: none; color: inherit; min-width: 0; }
.media-file:hover, .media-link:hover { background: #f3f4f6; }
.mf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mf-time { font-size: 11px; color: var(--muted, #6b7280); }
.media-link { flex-direction: column; align-items: flex-start; gap: 0; }
.ml-title { font-size: 13px; color: var(--primary, #2563eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ml-host { font-size: 11px; color: var(--muted, #6b7280); }
.msg > .msg-tools, .msg > .reactions { background: transparent !important; box-shadow: none !important; border: 0 !important; padding: 0 !important; width: auto !important; max-width: none !important; }
.msg > .reactions { display: inline-flex; gap: 4px; margin-top: -6px; position: relative; z-index: 1; }
.msg.out > .reactions { align-self: flex-end; }

/* ===== Xem ảnh nổi ===== */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.88); display: flex; flex-direction: column; }
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); color: #e5e7eb; font-size: 13px; }
.lb-actions { display: flex; gap: 8px; }
.lb-btn { color: #fff; background: rgba(255,255,255,.12); border: 0; border-radius: 8px; padding: 6px 12px; font-size: 14px; text-decoration: none; cursor: pointer; }
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 56px 16px; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 34px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
@media (max-width: 700px) { .lb-stage { padding: 0 4px 10px; } .lb-nav { width: 36px; height: 52px; font-size: 28px; background: rgba(255,255,255,.08); } }
.lb-img { transition: transform .2s; }

/* ===== Chờ phản hồi ===== */
.wait-chip { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 8px; margin: 3px 0 1px; background: #eef2ff; color: #3730a3; }
.wait-chip.warn { background: #fef3c7; color: #92400e; }
.wait-chip.alert { background: #fee2e2; color: #b91c1c; animation: waitPulse 2s ease-in-out infinite; }
.wait-chip.phone { background: #ecfdf5; color: #047857; font-weight: 500; }
@keyframes waitPulse { 50% { opacity: .65; } }
.wait-toggle { font-size: 12px; padding: 4px 8px; border-radius: 14px; white-space: nowrap; margin-left: auto; }
.wait-toggle.on { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.col-head { gap: 6px; flex-wrap: wrap; }
.col-head .new-chat { margin-left: 0; }
@media (max-width: 700px) { .wait-toggle { padding: 3px 7px; } }

/* ===== Nhảy tới tin gốc ===== */
.media-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.media-row > a { flex: 1; min-width: 0; }
.jump-btn { flex-shrink: 0; border: 0; background: none; font-size: 14px; padding: 4px 6px; border-radius: 6px; cursor: pointer; opacity: .55; }
.jump-btn:hover { opacity: 1; background: #eff6ff; }
.msg.flash > *:not(.msg-tools) { animation: msgFlash 2.4s ease-out; }
@keyframes msgFlash { 0%, 30% { box-shadow: 0 0 0 3px #f59e0b; background-color: #fef3c7; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ===== Đầu danh sách hội thoại: 2 hàng gọn ===== */
.col-head.list-head { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; flex-wrap: nowrap; }
.list-head .lh-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.list-head h2 { margin: 0; font-size: 16px; white-space: nowrap; }
.list-head .conv-count { margin-right: auto; }
.list-head .new-chat { margin: 0 !important; width: 30px; height: 30px; font-size: 17px; flex-shrink: 0; }
.list-head .lh-filters .acc-filter { flex: 1 1 auto; min-width: 0; max-width: none; margin: 0; height: 30px; padding: 2px 6px; font-size: 13px; }
.list-head .lh-filters .wait-toggle { margin: 0; height: 30px; flex-shrink: 0; }
.list-head .lh-filters .wait-toggle:only-child { margin-left: auto; }

/* ===== Menu chuột phải / nhấn giữ ===== */
.msg-menu { position: fixed; z-index: 150; min-width: 200px; background: var(--panel, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.mm-reacts { display: flex; justify-content: space-between; padding: 2px 2px 6px; border-bottom: 1px solid var(--border, #e5e7eb); margin-bottom: 4px; }
.mm-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; color: inherit; }
.mm-item:hover, .mm-item:focus { background: #eff6ff; outline: none; }
.mm-ico { width: 20px; text-align: center; }
.msg.menu-on > *:not(.msg-tools) { box-shadow: 0 0 0 2px #93c5fd; }
@media (hover: none) { .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } .msg-menu .mm-item { padding: 11px 12px; } }

/* ===== Ghim + lọc thời gian chờ ===== */
.conv-sec { font-size: 11px; font-weight: 700; color: var(--muted, #6b7280); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px 4px; }
.conv { position: relative; }
.conv.pinned { background: #fffbeb; }
.conv.pinned.active { background: #eef2ff; }
.pin-btn { position: absolute; right: 8px; bottom: 8px; font-size: 13px; opacity: 0; cursor: pointer; padding: 2px 4px; border-radius: 6px; transition: opacity .15s; }
.conv:hover .pin-btn, .pin-btn:focus { opacity: .5; }
.pin-btn:hover { opacity: 1 !important; background: #fef3c7; }
.pin-btn.on { display: none; }
@media (hover: none) { .pin-btn { display: none; } }
.list-head .lh-filters .wait-filter { flex: 0 0 auto; height: 30px; font-size: 13px; padding: 2px 6px; border-radius: 14px; }
.list-head .lh-filters .wait-filter.on { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.list-head .lh-filters .wait-filter:only-child { margin-left: auto; }
.list-head .lh-filters .acc-filter, .list-head .lh-filters .wait-filter { flex: 1 1 0; min-width: 0; width: 0; max-width: none; }
.list-head .lh-filters .wait-filter:only-child { flex: 0 1 auto; width: auto; }
.msg > .delivery { background: transparent !important; box-shadow: none !important; border: 0 !important; padding: 0 2px !important; width: auto !important; font-size: 11px; color: var(--muted, #6b7280); }
.msg.out > .delivery { align-self: flex-end; text-align: right; }

/* ===== Tìm kiếm ===== */
.search-box { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; background: #f3f4f6; border-radius: 18px; padding: 0 10px; height: 34px; }
.search-box:focus-within { background: #fff; box-shadow: 0 0 0 2px #bfdbfe; }
.search-ico { font-size: 13px; opacity: .6; }
.search-box input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; outline: none; box-shadow: none !important; padding: 0; height: 32px; font-size: 14px; }
.list-head .conv-count { margin-right: 0; }
.sr-item { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.sr-snip { white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
/* điện thoại: thao tác qua nhấn giữ, ẩn nút ☺ ↪ dưới từng tin cho gọn */
@media (hover: none) { .msg > .msg-tools { display: none !important; } }
.acc-warn { font-size: 12px; color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 6px 8px; }
.acc-who { font-size: 12px; color: #047857; }
.qr-focus { border: 2px solid #2563eb; border-radius: 12px; padding: 10px; background: #eff6ff; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr-title { font-weight: 700; font-size: 15px; color: #1e3a8a; }
.qr-steps { margin: 0; padding-left: 18px; font-size: 12px; color: #374151; align-self: stretch; }

/* ===== Mật khẩu ===== */
.me-btn { border: 0; background: none; font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.me-btn:hover { background: #f3f4f6; }
.pw-form { display: flex; flex-direction: column; gap: 6px; }
.pw-form label { font-size: 13px; color: var(--muted, #6b7280); margin-top: 4px; }
.pw-form .primary { margin-top: 10px; }
.pw-err { color: #b91c1c; font-size: 13px; min-height: 1em; }
.pw-note { font-size: 13px; background: #fef3c7; color: #92400e; border-radius: 8px; padding: 8px 10px; }
.pw-temp { display: block; font-size: 22px; letter-spacing: 1px; text-align: center; padding: 12px; background: #f3f4f6; border-radius: 8px; user-select: all; margin: 6px 0; }
.acc-add { flex-wrap: wrap; }
.acc-kind { flex: 1 1 100%; height: 34px; font-size: 13px; }
.oa-setup { font-size: 12px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; }
.oa-setup code { font-size: 11px; word-break: break-all; background: #eef2ff; padding: 1px 4px; border-radius: 4px; user-select: all; }

/* ===== Thành viên nhóm ===== */
.mem-body { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.mem-search { height: 30px; font-size: 13px; }
.mem-list { display: flex; flex-direction: column; max-height: 360px; overflow: auto; }
.mem-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-radius: 6px; min-width: 0; }
.mem-row:hover { background: #f3f4f6; }
.mem-av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #e5e7eb; }
.mem-av-x { display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #4b5563; }
.mem-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-role { font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 6px; white-space: nowrap; }
.mem-role.creator { background: #fef3c7; color: #92400e; }
.mem-role.admin { background: #e0e7ff; color: #3730a3; }
.admin-left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.oa-app-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.oa-app-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 8px 10px; }
.oa-app-row > div:first-child { flex: 1 1 140px; min-width: 0; }
.oa-app-row button { padding: 4px 10px; font-size: 13px; }
.oa-app-form { display: flex; flex-direction: column; gap: 6px; }
.usage-box { font-size: 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.usage-box code { font-size: 11px; word-break: break-all; }
.acc-usage { font-size: 12px; color: #334155; }

/* ===== Tab Nhật ký ===== */
.logs-page .admin-inner { max-width: 1400px; }
.logs-card { display: flex; flex-direction: column; gap: 10px; }
.logs-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.logs-head h2 { margin: 0 auto 0 0; }
.logs-head select { height: 32px; font-size: 13px; max-width: 240px; }
.logs-scroll { max-height: calc(100dvh - 230px); overflow: auto; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; }
.logs-scroll table { width: 100%; border-collapse: collapse; }
.logs-scroll thead th { position: sticky; top: 0; background: var(--panel, #fff); z-index: 1; }
.logs-scroll td.nowrap { white-space: nowrap; }
.log-detail { word-break: break-all; font-size: 12px; color: #475569; max-width: 520px; }
.logs-foot { display: flex; justify-content: center; }
.update-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 300; background: #1e293b; color: #fff; padding: 8px 10px 8px 16px; border-radius: 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 14px; }
/* số chưa đọc: xanh khi có, bấm để xếp chưa đọc lên đầu */
.list-head .conv-count { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; min-width: 34px; height: 28px; border-radius: 14px; padding: 0 9px; background: #eef2f7; color: #475569; }
.list-head .conv-count.has { background: #dbeafe; color: #1d4ed8; }
.list-head .conv-count.on { background: #2563eb; color: #fff; box-shadow: 0 0 0 2px #bfdbfe; }
.conv-sec.unread-sec { color: #1d4ed8; }

/* ===== Tin ghim nhóm ===== */
.board-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.board-item { border: 1px solid var(--border, #e5e7eb); border-left: 3px solid #f59e0b; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.board-title { font-size: 13px; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.board-links { display: flex; flex-wrap: wrap; gap: 4px; }
.board-links a { font-size: 12px; background: #eff6ff; border-radius: 6px; padding: 1px 6px; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted, #6b7280); gap: 6px; }
.board-poll { display: flex; flex-direction: column; gap: 2px; }
.poll-opt { display: flex; justify-content: space-between; font-size: 12px; background: #f8fafc; border-radius: 6px; padding: 2px 6px; }

/* ===== Xem trước link / tệp / video / thiệp ===== */
.lp-card { margin-top: 6px; }
.lp-card.loading { display: block; height: 0; overflow: hidden; border: 0; }
.lp-card.lp-image { display: block; padding: 0; border: 0; background: none; }
.lp-card.lp-image img { max-width: min(320px, 100%); max-height: 320px; border-radius: 8px; display: block; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 340px; padding: 8px 10px; border-radius: 10px; background: #fff; border: 1px solid var(--border, #e5e7eb); text-decoration: none; color: inherit; }
.file-card:hover { background: #f8fafc; }
.fc-ico { font-size: 28px; line-height: 1; }
.fc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fc-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-meta { font-size: 11px; color: var(--muted, #6b7280); }
.fc-dl { font-size: 16px; color: var(--primary, #2563eb); }
.msg-video { max-width: min(360px, 100%); max-height: 360px; border-radius: 8px; display: block; background: #000; }
.video-missing { position: relative; display: inline-block; }
.video-missing img { max-width: 240px; border-radius: 8px; display: block; opacity: .8; }
.video-missing span { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.zcard { display: flex; flex-direction: column; gap: 6px; max-width: 280px; }
.zcard img { width: 100%; border-radius: 8px; display: block; }
.zcard-text { font-size: 13px; }
.file-wrap { display: flex; flex-direction: column; gap: 0; max-width: 340px; }
.file-thumb { display: block; border: 1px solid var(--border, #e5e7eb); border-bottom: 0; border-radius: 10px 10px 0 0; overflow: hidden; background: #f8fafc; max-height: 200px; }
.file-thumb img { width: 100%; display: block; object-fit: cover; object-position: top; max-height: 200px; }
.file-wrap .file-card { border-radius: 0 0 10px 10px; }
.deleted-bar { position: sticky; top: 0; z-index: 2; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 8px; padding: 6px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.deleted-bar button { padding: 2px 10px; }
.bk-row { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bk-row input { width: 64px; }
.backup-card .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Thống kê ===== */
.stats-page .admin-inner { max-width: 1400px; }
.heat-wrap { overflow-x: auto; }
.heatmap { border-collapse: separate; border-spacing: 2px; font-size: 12px; min-width: 760px; width: 100%; }
.heatmap th { font-weight: 600; color: var(--muted, #6b7280); font-size: 11px; padding: 2px; }
.heatmap .hm-name { text-align: left; white-space: nowrap; padding-right: 8px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.heatmap .hm-cell { width: 3.2%; height: 26px; text-align: center; border-radius: 4px; background: #f1f5f9; font-variant-numeric: tabular-nums; }
.heatmap .hm-total { text-align: right; font-weight: 700; padding-left: 8px; font-variant-numeric: tabular-nums; }
.heatmap .hm-foot td { font-weight: 700; color: #334155; background: transparent; }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; flex-wrap: wrap; }
.hm-sw { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-tip { position: fixed; z-index: 400; pointer-events: none; background: #0f172a; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; display: none; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 12px; background: none; }
.seg button.on { background: #2a78d6; color: #fff; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: 10px 12px; }
.tile-v { font-size: 26px; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 12px; color: var(--muted, #6b7280); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 200px; border-bottom: 1px solid #cbd5e1; padding-top: 18px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; cursor: default; }
.bar { width: 70%; max-width: 28px; background: #2a78d6; border-radius: 4px 4px 0 0; }
.bar-col:hover .bar { background: #1c5cab; }
.bar-v { font-size: 11px; color: #334155; font-variant-numeric: tabular-nums; }
.bar-l { position: absolute; bottom: -18px; font-size: 10px; color: var(--muted, #6b7280); white-space: nowrap; }
.stats-page .bars { margin-bottom: 22px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.logs-head input[type=date] { width: auto; height: 32px; font-size: 13px; padding: 2px 8px; }
.logs-head > button { padding: 4px 10px; }
.stats-page .logs-head select { width: auto; }

/* ===== AI + giọng nói ===== */
.ai-bar { display: none; }
.ai-bar.show { display: flex; flex-direction: column; gap: 6px; padding: 8px 16px; border-top: 1px solid var(--border, #e5e7eb); background: #f8fafc; max-height: 40vh; overflow: auto; }
.ai-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #475569; }
.ai-head span, .ai-head b { margin-right: auto; }
.ai-head button { border: 0; background: none; padding: 2px 8px; cursor: pointer; }
.ai-chip { text-align: left; border: 1px solid #c7d2fe; background: #eef2ff; border-radius: 10px; padding: 8px 10px; font-size: 14px; cursor: pointer; white-space: pre-wrap; }
.ai-chip:hover { background: #e0e7ff; }
.ai-hint { height: 32px; font-size: 13px; }
.ai-summary { margin: 8px 16px 0; border: 1px solid #c7d2fe; background: #f5f7ff; border-radius: 10px; padding: 8px 12px; }
.ai-sum-text { white-space: pre-wrap; font-size: 14px; }
.mic-btn.recording { background: #fee2e2 !important; animation: waitPulse 1s ease-in-out infinite; }
.msg-audio { width: 260px; max-width: 100%; display: block; }
.transcript { font-size: 13px; color: #334155; background: #f1f5f9; border-radius: 8px; padding: 4px 8px; margin-top: 4px; white-space: pre-wrap; }
.tr-btn { margin-top: 4px; font-size: 12px; padding: 3px 8px; }
@media (max-width: 700px) { .ai-bar.show { padding: 6px 8px; } .composer .mic-btn, .composer .ai-btn { font-size: 18px; padding: 4px; border: 0; background: none; } }
/* giữ xuống dòng (Shift+Enter / tin nhiều dòng từ Zalo) */
.msg-text, .bubble .caption, .recalled-body, .note .body { white-space: pre-wrap; word-break: break-word; }
/* ô gợi ý AI: không bị khung tin nhắn ép nhỏ */
.thread > .ai-bar.show { flex: 0 0 auto; max-height: min(50vh, 460px); min-height: 120px; overflow-y: auto; }
.thread > .messages { min-height: 120px; }
.ai-chip { flex: 0 0 auto; line-height: 1.45; }
@media (min-width: 1100px) { .ai-bar.show { padding: 10px 20px; } .ai-chip { font-size: 14.5px; } }

/* ===== Ô soạn tin (một khung bo tròn) ===== */
.thread > .composer { display: block; padding: 8px 16px 10px; border-top: 1px solid var(--border, #e5e7eb); background: var(--panel, #fff); }
.cmp-box { display: flex; align-items: flex-end; gap: 4px; border: 1px solid #d6dbe3; border-radius: 22px; background: #f8fafc; padding: 4px 4px 4px 6px; transition: border-color .15s, box-shadow .15s, background .15s; }
.cmp-box:focus-within { border-color: #93b4f0; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.cmp-tools { display: flex; align-items: center; gap: 0; padding-bottom: 2px; }
.cmp-tools button, .composer .cmp-tools .attach { width: 34px; height: 34px; min-width: 34px; padding: 0; border: 0 !important; background: none !important; border-radius: 50%; font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; opacity: .75; box-shadow: none !important; }
.cmp-tools button:hover { opacity: 1; background: #e8eef9 !important; }
.cmp-tools .mic-btn.recording { background: #fee2e2 !important; opacity: 1; }
.cmp-box textarea#reply-box { flex: 1; min-width: 0; border: 0 !important; outline: none; box-shadow: none !important; background: transparent !important; resize: none; padding: 8px 6px; font-size: 15px; line-height: 1.4; min-height: 38px; max-height: 160px; overflow-y: auto; }
.cmp-box .send { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; padding: 0; display: inline-flex; align-items: center; justify-content: center; align-self: flex-end; }
.send-ico { font-size: 16px; transform: translateX(1px); }
.cmp-hint { font-size: 11px; color: var(--muted, #94a3b8); padding: 4px 14px 0; }
@media (max-width: 700px) { .thread > .composer { padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); } .cmp-tools button { width: 32px; height: 32px; min-width: 32px; } }
/* ===== Online ===== */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.dot.off { background: #cbd5e1; }
.online-list { display: flex; flex-direction: column; }
.online-row { display: grid; grid-template-columns: 14px minmax(120px, 1.2fr) 100px minmax(160px, 2fr) 150px; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.online-row.off { color: #64748b; }
.on-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.on-role, .on-first { font-size: 12px; color: var(--muted, #6b7280); }
.on-what { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .online-row { grid-template-columns: 14px 1fr; } .on-role, .on-first { display: none; } .on-what { grid-column: 2; } }

/* ===== Thanh trên cùng: không bao giờ vỡ ===== */
.topbar { flex-wrap: nowrap !important; overflow: hidden; }
.topbar .brand { flex: 0 0 auto; white-space: nowrap; }
.topbar .brand .brand-hub { display: inline; width: auto; height: auto; border-radius: 0; background: none; box-shadow: none; vertical-align: baseline; }
.topbar .tabs { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.topbar .tabs::-webkit-scrollbar { display: none; }
.topbar .tabs button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; }
.tab-ico { font-size: 14px; line-height: 1; }
.topbar .userbox { flex: 0 0 auto; }
@media (max-width: 1000px) { .topbar .who b, .topbar .who .me-btn { max-width: 120px; overflow: hidden; text-overflow: ellipsis; } }
@media (max-width: 860px) { .topbar .tab-label { display: none; } .topbar .tabs button { padding: 6px 10px; } .tab-ico { font-size: 17px; } .topbar .who .badge { display: none; } }
@media (max-width: 520px) { .topbar .userbox button:not(.me-btn) { padding: 6px 10px; font-size: 13px; } .topbar .brand { font-size: 14px; } }

/* Sticker Zalo: hiện ảnh, không nền bong bóng */
.bubble.sticker-bubble { background: transparent !important; box-shadow: none !important; padding: 2px 0 !important; }
.msg-sticker { width: 120px; height: 120px; object-fit: contain; display: block; }
@media (max-width: 600px) { .msg-sticker { width: 96px; height: 96px; } }

.composer { position: relative; }
.sticker-pop { position: absolute; bottom: calc(100% + 6px); left: 8px; width: min(340px, calc(100vw - 32px)); max-height: 320px; overflow: auto; background: #fff; border: 1px solid #dfe3ea; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 8px; z-index: 50; }
.sp-head { font-size: 12px; color: #667; margin: 0 4px 6px; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 4px; }
.sp-item { border: 0; background: none; padding: 4px; border-radius: 8px; cursor: pointer; }
.sp-item:hover { background: #eef3fb; }
.sp-item img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }

.bot-accs { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.bot-card select { width: 100%; max-width: 100%; }
.bot-card .bk-row input[type=number] { width: 70px; }
.bot-preview { white-space: pre-wrap; word-break: break-word; background: #f6f8fb; border: 1px solid #e1e6ee; border-radius: 8px; padding: 10px; font: 13px/1.45 inherit; max-height: 360px; overflow: auto; margin: 6px 0 0; }

/* ✨ Hiệu quả gợi ý AI */
.ai-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 8px; }
.ai-tile { border: 1px solid #e3e8ef; border-radius: 10px; padding: 10px; }
.ai-tile-n { font-size: 22px; font-weight: 700; color: #0f172a; }
.ai-tile-l { font-size: 13px; color: #334155; }
.ai-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
.ai-table th, .ai-table td { padding: 5px 8px; border-bottom: 1px solid #eef1f5; text-align: right; white-space: nowrap; }
.ai-table th:first-child, .ai-table td:first-child { text-align: left; }
.ai-sub { font-size: 14px; margin: 14px 0 6px; }
.ai-rec { border: 1px solid #eef1f5; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.ai-rec-head { color: #475569; margin-bottom: 4px; }
.ai-rec-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 3px; }
.ai-rec-t { white-space: pre-wrap; word-break: break-word; flex: 1; min-width: 0; }
.ai-lbl { flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: #eef2ff; color: #3730a3; }
.ai-lbl.sent { background: #ecfdf5; color: #065f46; }
.ai-res { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: #f1f5f9; }
.ai-res.ok { background: #dcfce7; color: #166534; } .ai-res.light { background: #fef9c3; color: #854d0e; } .ai-res.heavy { background: #fee2e2; color: #991b1b; }
.btn-link { font-size: 13px; text-decoration: none; padding: 5px 10px; border: 1px solid #d5dce6; border-radius: 8px; color: inherit; white-space: nowrap; }

/* Đơn vị / thương hiệu / dung lượng */
.brand { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 240px; }
.brand-logo { height: 26px; width: auto; max-width: 90px; object-fit: contain; flex: 0 0 auto; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 600px) { .brand { max-width: 120px; } .brand-logo + .brand-name { display: none; } }
.login-logo { max-height: 64px; max-width: 200px; object-fit: contain; display: block; margin: 0 auto 8px; }
.tenant-pick { margin-top: 12px; font-size: 14px; } .tenant-pick summary { cursor: pointer; color: #475569; }
.tp-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; } .tp-row input { flex: 1; min-width: 0; }
.signup-link { margin-top: 12px; font-size: 14px; text-align: center; }
.signup-card label { display: block; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.org-brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.org-logo { width: 72px; height: 72px; object-fit: contain; border: 1px solid #e3e8ef; border-radius: 10px; background: #fff; }
.org-logo.empty { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.dom-list { display: flex; flex-direction: column; gap: 8px; }
.dom-row { border: 1px solid #e3e8ef; border-radius: 10px; padding: 8px; }
.dom-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dns-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; display: block; overflow-x: auto; }
.dns-table th, .dns-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #eef1f5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.quota-bar { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.quota-bar > div { height: 100%; background: #2563eb; } .quota-bar.warn > div { background: #d97706; } .quota-bar.full > div { background: #dc2626; }
.tenant-row { border: 1px solid #e3e8ef; border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.tenant-row.suspended { opacity: .65; }
.tenant-row details { margin-top: 6px; } .tenant-row summary { cursor: pointer; font-size: 13px; color: #475569; }
.tenant-row .bk-row { flex-wrap: wrap; }
.tn-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.storage-card .acc-cb, .bot-card .acc-cb { white-space: normal; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; line-height: 1.5; }
.storage-card .acc-cb input[type=number] { width: 70px; }

/* Gói & thanh toán */
.plan-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .plan-l { min-width: 170px; }
.plan-total { font-weight: 600; margin: 6px 0; }
.inv-row { border: 1px solid #e3e8ef; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.inv-row.hl { border-color: #f59e0b; background: #fffbeb; }
.inv-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } .inv-amt { font-weight: 700; }
.pay-box { background: #f6f8fb; border-radius: 8px; padding: 8px; margin: 6px 0; font-size: 13px; line-height: 1.6; word-break: break-word; }
.pill.pending { background: #fef3c7; color: #92400e; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.price-l { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.lock-card p { line-height: 1.6; }
.billing-card .acc-cb { white-space: normal; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.logs-head input[type=month] { width: auto; flex: 0 0 auto; }

/* Trích dẫn */
.quote-box { border-left: 3px solid #2563eb; background: rgba(37,99,235,.07); border-radius: 6px; padding: 4px 8px; margin-bottom: 6px; cursor: pointer; max-width: 100%; }
.quote-from { font-size: 12px; font-weight: 600; color: #1d4ed8; }
.quote-text { font-size: 13px; color: #475569; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.quote-bar { display: none; }
.quote-bar.show { display: flex; align-items: center; gap: 8px; border-left: 3px solid #2563eb; background: #f1f5fe; border-radius: 8px; padding: 6px 8px; margin: 0 0 6px; }
.quote-bar .qb-body { flex: 1; min-width: 0; }
.qb-x { border: 0; background: none; cursor: pointer; font-size: 16px; color: #64748b; padding: 4px 6px; }
