/* ═══════════════════════════════════════════════════════════
   SocialPilot VN — Design System
   Phong cách: social dashboard, sidebar tối + content sáng
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('/fonts/BeVietnamPro-700.ttf') format('truetype');
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('/fonts/BeVietnamPro-800.ttf') format('truetype');
  font-weight: 800; font-display: swap;
}

:root {
  --font: 'Segoe UI', 'SF Pro Display', system-ui, -apple-system, Roboto, sans-serif;
  --font-display: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;

  --brand-1: #6d5efc;
  --brand-2: #a855f7;
  --brand-3: #ec4899;
  --grad-brand: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 55%, var(--brand-3) 100%);
  --grad-brand-soft: linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 12%, transparent), color-mix(in srgb, var(--brand-3) 12%, transparent));
  --grad-green: linear-gradient(135deg, #10b981, #34d399);
  --grad-orange: linear-gradient(135deg, #f59e0b, #fbbf24);
  --grad-red: linear-gradient(135deg, #ef4444, #f87171);
  --grad-blue: linear-gradient(135deg, #3b82f6, #60a5fa);

  --bg: #f3f4fb;
  --bg-glow-1: color-mix(in srgb, var(--brand-1) 7%, transparent);
  --bg-glow-2: color-mix(in srgb, var(--brand-3) 5%, transparent);
  --card: #ffffff;
  --card-2: #f8f9fe;
  --border: #e8eaf6;
  --border-strong: #d8dcf0;
  --text: #1a1d3d;
  --text-2: #565d87;
  --text-3: #9aa0c3;
  --sidebar-w: 262px;
  --sidebar-bg: linear-gradient(180deg, #14162b 0%, #1b1e3e 100%);
  --sidebar-text: #aab0d6;
  --topbar-h: 68px;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 2px 6px rgba(26, 29, 61, .04), 0 12px 32px rgba(26, 29, 61, .07);
  --shadow-lg: 0 8px 20px rgba(26, 29, 61, .10), 0 24px 60px rgba(26, 29, 61, .12);
  --shadow-brand: 0 8px 24px color-mix(in srgb, var(--brand-1) 35%, transparent);
  --ok: #10b981; --warn: #f59e0b; --err: #ef4444; --info: #3b82f6;
}

[data-theme="dark"] {
  --bg: #0e101f;
  --bg-glow-1: color-mix(in srgb, var(--brand-1) 10%, transparent);
  --bg-glow-2: color-mix(in srgb, var(--brand-3) 7%, transparent);
  --card: #171a30;
  --card-2: #1d2140;
  --border: #272b4d;
  --border-strong: #33375e;
  --text: #eef0ff;
  --text-2: #a6acdc;
  --text-3: #676e9e;
  --shadow: 0 2px 6px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 20px rgba(0,0,0,.4), 0 24px 60px rgba(0,0,0,.5);
}

/* ── Màu chủ đạo (chọn ở Cài đặt — đặt data-brand trên <html>; mặc định purple khi không có thuộc tính) ── */
html[data-brand="purple"] { --brand-1: #6d5efc; --brand-2: #a855f7; --brand-3: #ec4899; }
html[data-brand="indigo"] { --brand-1: #6366f1; --brand-2: #4f46e5; --brand-3: #8b5cf6; }
html[data-brand="blue"]   { --brand-1: #3b82f6; --brand-2: #2563eb; --brand-3: #06b6d4; }
html[data-brand="teal"]   { --brand-1: #14b8a6; --brand-2: #0d9488; --brand-3: #22d3ee; }
html[data-brand="green"]  { --brand-1: #22c55e; --brand-2: #16a34a; --brand-3: #84cc16; }
html[data-brand="orange"] { --brand-1: #f97316; --brand-2: #ea580c; --brand-3: #f59e0b; }
html[data-brand="red"]    { --brand-1: #ef4444; --brand-2: #dc2626; --brand-3: #f97316; }
html[data-brand="slate"]  { --brand-1: #64748b; --brand-2: #475569; --brand-3: #94a3b8; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 85% -10%, var(--bg-glow-2), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, var(--bg-glow-1), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14.5px;
  line-height: 1.5;
}
::selection { background: color-mix(in srgb, var(--brand-1) 25%, transparent); }
h1,h2,h3,h4 { font-family: var(--font-display); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: var(--text); }
a { color: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,126,180,.35); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,126,180,.6); background-clip: content-box; }

/* ═══════════ LAYOUT ═══════════ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
  flex-shrink: 0;
  transition: width .25s ease;
}
.sidebar.collapsed { width: 78px; }
.sidebar .hide-collapse { transition: opacity .15s; }
.sidebar.collapsed .hide-collapse { opacity: 0; pointer-events: none; }

.logo {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 18px;
  color: #fff;
}
.logo-badge {
  width: 42px; height: 42px; border-radius: 13px;
  background: var(--grad-brand);
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
  font-size: 20px;
}
.logo h1 { font-size: 17px; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.logo .sub { font-size: 11px; color: #7d84b8; font-weight: 400; font-family: var(--font); white-space: nowrap; }

.nav { padding: 8px 14px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px;
  color: #5d6396; padding: 14px 12px 8px; font-weight: 700; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 13px;
  width: 100%;
  padding: 11px 13px; margin-bottom: 3px;
  border: none; border-radius: 13px;
  background: transparent; color: var(--sidebar-text);
  font-size: 14px; font-weight: 600;
  transition: all .18s ease;
  position: relative;
  white-space: nowrap;
  text-align: left;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.nav-item .nbadge {
  margin-left: auto;
  background: rgba(255,255,255,.16);
  border-radius: 99px; font-size: 11px; padding: 1px 8px; font-weight: 700;
}
.nav-item.active .nbadge { background: rgba(255,255,255,.25); }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.demo-pill {
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(245,158,11,.08));
  border: 1px solid rgba(245,158,11,.3);
  color: #fbbf24; border-radius: 12px;
  padding: 10px 12px; font-size: 12.5px; font-weight: 600;
  margin-bottom: 10px; white-space: nowrap;
}
.demo-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 8px #fbbf24; flex-shrink: 0; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.main {
  flex: 1; min-width: 0;
  padding: 0 28px 40px;
}

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(var(--bg) 82%, transparent);
}
.topbar .titles h2 { font-size: 20px; font-weight: 800; }
.topbar .titles p { font-size: 12.5px; color: var(--text-2); margin-top: -2px; }
.topbar .spacer { flex: 1; }

/* ═══════════ COMPONENTS ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 700;
  transition: all .18s ease;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--brand-1); color: var(--brand-1); transform: translateY(-1px); }
.btn.primary {
  background: var(--grad-brand); color: #fff; border: none;
  box-shadow: var(--shadow-brand);
}
.btn.primary:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.btn.primary:disabled { opacity: .55; transform: none; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card-2); }
.btn.danger { color: var(--err); border-color: rgba(239,68,68,.35); }
.btn.danger:hover { background: rgba(239,68,68,.08); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.btn.icon-only { padding: 9px; }
.btn.icon-only.sm { padding: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 99px;
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--brand-1); color: var(--brand-1); }
.chip.active { background: var(--grad-brand); border-color: transparent; color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-1) 30%, transparent); }
.chip.static { cursor: default; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700;
}
.badge.ok   { background: rgba(16,185,129,.13); color: #0da271; }
.badge.violet { background: color-mix(in srgb, var(--brand-1) 13%, transparent); color: var(--brand-1); }
.badge.warn { background: rgba(245,158,11,.15); color: #d97706; }
.badge.err  { background: rgba(239,68,68,.12); color: #dc2626; }
.badge.info { background: rgba(59,130,246,.13); color: #2563eb; }
.badge.gray { background: rgba(120,126,180,.13); color: var(--text-2); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px 0;
}
.card-head h3 { font-size: 15.5px; font-weight: 800; }
.card-head .sub { font-size: 12px; color: var(--text-2); font-weight: 400; font-family: var(--font); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px 22px 22px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; }
.input, textarea.input, select.input {
  width: 100%;
  background: var(--card-2);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand-1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-1) 12%, transparent); background: var(--card); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.55; }
select.input { cursor: pointer; }

.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--border-strong);
  transition: .2s; cursor: pointer;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--grad-brand); }
.switch input:checked + .track::after { transform: translateX(20px); }

.empty {
  text-align: center; padding: 46px 20px; color: var(--text-3);
}
.empty .icon { font-size: 42px; margin-bottom: 10px; }
.empty h4 { color: var(--text-2); font-size: 15px; margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 340px; margin: 0 auto; }

.skeleton { position: relative; overflow: hidden; background: var(--card-2); border-radius: 12px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Toast */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow-lg);
  padding: 13px 17px;
  min-width: 280px; max-width: 400px;
  font-size: 13.5px; font-weight: 600;
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.2);
}
.toast .ticon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.toast.ok .ticon { background: rgba(16,185,129,.15); }
.toast.err .ticon { background: rgba(239,68,68,.13); }
.toast.info .ticon { background: rgba(59,130,246,.13); }
.toast.out { animation: toastOut .25s forwards; }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(40px); opacity: 0; } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 17, 38, .55);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fadeIn .2s;
}
.modal {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px;
  max-height: 88vh; overflow-y: auto;
  animation: modalIn .28s cubic-bezier(.2,.9,.3,1.15);
}
.modal.wide { max-width: 860px; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 24px 0;
}
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-head .x {
  margin-left: auto;
  width: 34px; height: 34px; border-radius: 10px;
  border: none; background: var(--card-2); color: var(--text-2);
  font-size: 17px; display: grid; place-items: center;
}
.modal-head .x:hover { background: var(--border); }
.modal-body { padding: 18px 24px 24px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { transform: translateY(24px) scale(.97); opacity: 0; } }

/* ═══════════ POLICY CHECK (🛡️ Kiểm tra chính sách) ═══════════ */
.policy-clean { background: rgba(16,185,129,.12); color: #0da271; border-radius: 12px; padding: 14px 16px; font-weight: 700; font-size: 13.5px; }
.policy-group { margin-top: 14px; }
.policy-group > h4 { margin: 0 0 8px; font-size: 12.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; }
.policy-group.err > h4 { color: #dc2626; }
.policy-group.warn > h4 { color: #d97706; }
.policy-group.note > h4 { color: #2563eb; }
.policy-hint { font-size: 12px; color: var(--text-2); margin: -4px 0 8px; }
.policy-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 7px; font-size: 13px; line-height: 1.5; }
.policy-item > div { min-width: 0; }
.policy-item b { display: block; margin-bottom: 1px; }
.policy-item .pi-ic { flex: none; font-size: 15px; line-height: 1.3; }
.policy-item.err { background: rgba(239,68,68,.09); }
.policy-item.warn { background: rgba(245,158,11,.11); }
.policy-item.note { background: rgba(59,130,246,.09); }
.policy-foot { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-2); background: var(--card-2); border-radius: 12px; padding: 10px 13px; margin-top: 16px; line-height: 1.55; }

/* ═══════════ TEMPLATES / STYLE BORROW (🪄 Nội dung mẫu) ═══════════ */
.tpl-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 4px; }
@media (max-width: 860px) { .tpl-grid { grid-template-columns: repeat(2, 1fr); } }
.tpl-card { text-align: left; background: var(--card-2); border: 1.5px solid var(--border); border-radius: 14px; padding: 11px 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.tpl-card:hover { border-color: var(--brand-1); transform: translateY(-1px); }
.tpl-card.active { border-color: var(--brand-1); background: color-mix(in srgb, var(--brand-1) 8%, var(--card-2)); }
.tpl-card .tico { font-size: 18px; }
.tpl-card b { display: block; font-size: 13px; margin: 3px 0 2px; }
.tpl-card .tdesc { font-size: 11.5px; color: var(--text-2); line-height: 1.4; }
.tpl-lbl { display: block; font-size: 12.5px; font-weight: 700; margin: 12px 0 4px; }
.style-note { background: rgba(59,130,246,.09); border-radius: 12px; padding: 10px 13px; font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.tpl-prev-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin: 12px 0 6px; flex-wrap: wrap; }
.style-variant { background: var(--card-2); border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 12px; margin-top: 10px; }
.sv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.style-variant textarea, #tpl-preview textarea { width: 100%; background: var(--card); resize: vertical; }
.tpl-error { background: rgba(239,68,68,.09); color: #dc2626; border-radius: 12px; padding: 10px 13px; font-size: 13px; margin-top: 10px; line-height: 1.5; }

/* ═══════════ EMOJI PICKER (😊 Thêm) ═══════════ */
.emoji-pop { position: fixed; z-index: 300; background: var(--card); border: 1.5px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 10px; width: 352px; max-width: calc(100vw - 24px); animation: fadeIn .15s; }
.emoji-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.emoji-tabs .chip { flex: none; padding: 3px 8px; font-size: 11.5px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; max-height: 216px; overflow-y: auto; }
.emoji-grid button { font-size: 20px; padding: 5px 0; border: none; background: transparent; border-radius: 8px; cursor: pointer; line-height: 1.25; }
.emoji-grid button:hover { background: var(--border); }
.emoji-empty { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); padding: 14px 6px; text-align: center; }

/* ═══════════ LOGIN (🔐 Đăng nhập bằng Facebook) ═══════════ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg, #14162b); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 38px 36px 30px; width: 100%; max-width: 420px; text-align: center; }
.login-logo { font-size: 46px; }
.login-card h1 { font-family: var(--font-display); font-size: 24px; font-weight: 800; margin: 10px 0 2px; }
.login-card h1 span { color: var(--brand-1); }
.login-sub { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; }
.login-fb { width: 100%; justify-content: center; display: flex; gap: 8px; align-items: center; padding: 12px; font-size: 14px; margin-bottom: 10px; }
.login-note { background: var(--card-2); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin-bottom: 10px; word-break: break-all; }
.login-err { background: rgba(239,68,68,.09); color: #dc2626; border-radius: 12px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 12px; line-height: 1.5; }
.login-foot { font-size: 11.5px; color: var(--text-3); margin-top: 12px; line-height: 1.6; }

/* user chip ở sidebar (đã đăng nhập) */
.user-chip { display: flex; gap: 9px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--card-2); margin-bottom: 8px; }
.user-chip .avatar { width: 32px; height: 32px; flex: none; }
.uc-info { min-width: 0; flex: 1; text-align: left; }
.uc-info .uname { font-size: 12.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ulogout { border: none; background: none; color: var(--text-2); font-size: 11.5px; cursor: pointer; padding: 0; }
.ulogout:hover { color: var(--err); }

/* ═══════════ DASHBOARD ═══════════ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: ''; position: absolute; top: -30px; right: -30px;
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--sc, var(--grad-brand));
  opacity: .1; filter: blur(2px);
}
.stat-card .shead { display: flex; align-items: center; gap: 10px; }
.stat-card .sicon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--sc, var(--grad-brand));
  color: #fff; font-size: 18px;
  box-shadow: 0 6px 14px rgba(26,29,61,.18);
}
.stat-card .slabel { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.stat-card .svalue { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-top: 12px; letter-spacing: -.3px; }
.stat-card .sdelta { font-size: 12px; font-weight: 700; margin: 2px 0 40px; }
.stat-card .sdelta.up { color: var(--ok); }
.stat-card .sdelta.down { color: var(--err); }
.stat-card .sdelta:empty { margin-bottom: 40px; }
.stat-card .spark { position: absolute; bottom: 0; left: 0; right: 0; height: 38px; opacity: .75; pointer-events: none; }

.grid-2 { display: grid; grid-template-columns: 1fr 360px; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.mt16 { margin-top: 16px; }

.metric-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.mtoggle {
  padding: 5px 12px; border-radius: 99px; border: 1.5px solid transparent;
  font-size: 12px; font-weight: 700; cursor: pointer;
  background: var(--card-2); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: .15s;
}
.mtoggle .swdot { width: 8px; height: 8px; border-radius: 50%; }
.mtoggle.on { border-color: currentColor; background: var(--card); }

.legend { display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-row .swdot { width: 11px; height: 11px; border-radius: 4px; }
.legend-row .lname { color: var(--text-2); font-weight: 600; flex: 1; }
.legend-row .lval { font-weight: 800; font-family: var(--font-display); }

/* Timeline / list rows */
.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.row-item:last-child { border-bottom: none; padding-bottom: 0; }
.row-item .rmain { flex: 1; min-width: 0; }
.row-item .rtitle { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .rsub { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.rtime-chip {
  font-size: 11.5px; font-weight: 700; color: var(--text-2);
  background: var(--card-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 9px; white-space: nowrap;
}

.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-item .aicon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 15px;
}
.activity-item .atext { font-size: 13px; }
.activity-item .atime { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ═══════════ COMPOSER ═══════════ */
.composer-grid { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 16px; align-items: start; }
.compose-tabs { display: flex; gap: 6px; background: var(--card-2); padding: 5px; border-radius: 14px; border: 1px solid var(--border); }
.compose-tabs button {
  flex: 1; border: none; background: transparent;
  padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 700; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: .18s;
}
.compose-tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(26,29,61,.08); }
.compose-tabs svg { width: 17px; height: 17px; }

.page-chips { display: flex; gap: 9px; flex-wrap: wrap; }
.page-chip {
  display: flex; align-items: center; gap: 9px;
  border: 1.5px solid var(--border);
  background: var(--card-2);
  border-radius: 13px; padding: 8px 14px 8px 8px;
  cursor: pointer; transition: .15s;
  font-weight: 700; font-size: 13px;
}
.page-chip:hover { border-color: var(--border-strong); }
.page-chip.on {
  border-color: var(--brand-1);
  background: var(--grad-brand-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 10%, transparent);
}
.page-chip .check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: 10px; color: transparent; transition: .15s;
  flex-shrink: 0;
}
.page-chip.on .check { background: var(--grad-brand); border-color: transparent; color: #fff; }

.msg-count { font-size: 11.5px; color: var(--text-3); font-weight: 700; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  color: var(--text-3);
  transition: .2s;
  cursor: pointer;
  background: var(--card-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-1); color: var(--brand-1); background: var(--grad-brand-soft); }
.dropzone svg { width: 30px; height: 30px; margin-bottom: 6px; }
.dropzone b { color: var(--text-2); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 9px; }
.media-item {
  position: relative; border-radius: 13px; overflow: hidden;
  aspect-ratio: 1; background: var(--card-2);
  border: 1px solid var(--border);
  cursor: grab;
  transition: box-shadow .15s;
}
.media-item.dragging { opacity: .4; box-shadow: var(--shadow-lg); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-item .remove {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(15,17,38,.65); color: #fff;
  font-size: 12px; display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.media-item .remove:hover { background: var(--err); }
.media-item .mnum {
  position: absolute; bottom: 5px; left: 5px;
  background: rgba(15,17,38,.65); color: #fff;
  font-size: 10px; font-weight: 800;
  border-radius: 7px; padding: 2px 7px;
  backdrop-filter: blur(4px);
}
.media-collapse-btn {
  width: 100%; border: 1.5px dashed var(--border-strong); background: transparent;
  color: var(--text-2); border-radius: 12px; padding: 8px;
  font-size: 12.5px; font-weight: 700; margin-top: 9px;
}
.media-collapse-btn:hover { border-color: var(--brand-1); color: var(--brand-1); }

.schedule-box {
  background: var(--grad-brand-soft);
  border: 1.5px solid color-mix(in srgb, var(--brand-1) 25%, transparent);
  border-radius: 15px; padding: 14px;
  display: flex; gap: 10px; align-items: center;
}
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.toggle-row .ttext { flex: 1; }
.toggle-row .ttitle { font-weight: 700; font-size: 13.5px; }
.toggle-row .tsub { font-size: 12px; color: var(--text-2); }

/* FB preview */
.fb-preview { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--card); }
.fb-p-head { display: flex; align-items: center; gap: 11px; padding: 13px 15px; }
.fb-p-name { font-weight: 700; font-size: 13.5px; }
.fb-p-time { font-size: 11.5px; color: var(--text-3); }
.fb-p-msg { padding: 0 15px 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; max-height: 130px; overflow: hidden; }
.fb-p-media { display: grid; gap: 2px; max-height: 320px; overflow: hidden; position: relative; }
.fb-p-media.m1 { grid-template-columns: 1fr; }
.fb-p-media.m2 { grid-template-columns: 1fr 1fr; }
.fb-p-media.m3 { grid-template-columns: 1fr 1fr; }
.fb-p-media.m3 > :first-child { grid-column: span 2; }
.fb-p-media.m4 { grid-template-columns: 1fr 1fr; }
.fb-p-media img, .fb-p-media video { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1.6; }
.fb-p-media .more-overlay {
  position: absolute; inset: 0;
  background: rgba(15,17,38,.55); color: #fff;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; font-family: var(--font-display);
  backdrop-filter: blur(2px);
}
.fb-p-media.collapsed img:nth-child(n+2), .fb-p-media.collapsed video:nth-child(n+2) { display: none; }
.fb-p-media.collapsed { grid-template-columns: 1fr !important; }
.fb-p-link {
  display: flex; gap: 10px; padding: 11px 15px;
  background: var(--card-2); border-top: 1px solid var(--border);
}
.fb-p-link .lthumb { width: 44px; height: 44px; border-radius: 9px; background: var(--grad-brand); flex-shrink: 0; display: grid; place-items: center; color: #fff; font-size: 18px; }
.fb-p-link .lhost { font-size: 11px; color: var(--text-3); text-transform: uppercase; }
.fb-p-link .lurl { font-size: 12.5px; color: var(--text-2); word-break: break-all; }
.fb-p-actions {
  display: flex; padding: 6px 10px; border-top: 1px solid var(--border);
}
.fb-p-actions button {
  flex: 1; border: none; background: transparent;
  padding: 9px; color: var(--text-2); font-weight: 700; font-size: 13px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.fb-p-actions button:hover { background: var(--card-2); }
.fb-p-actions svg { width: 17px; height: 17px; }

/* Queue table */
.queue-filters { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.queue-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
}
.queue-item:last-child { border-bottom: none; }
.queue-item .qmsg { flex: 1; min-width: 0; }
.queue-item .qtext { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.queue-item .qtitle { font-size: 13.5px; font-weight: 800; color: var(--brand-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.queue-item .qtitle + .qtext { font-weight: 500; font-size: 12.5px; color: var(--text-2); }
.queue-item .qmeta { display: flex; gap: 8px; align-items: center; margin-top: 5px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.queue-item .qactions { display: flex; gap: 6px; flex-shrink: 0; }
.qthumb { width: 46px; height: 46px; border-radius: 11px; object-fit: cover; background: var(--card-2); border: 1px solid var(--border); flex-shrink: 0; }
.qthumb-wrap { position: relative; flex-shrink: 0; width: 46px; height: 46px; }
.qthumb-wrap .qthumb-play {
  position: absolute; bottom: 2px; right: 2px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 8px; line-height: 1; padding: 2px 4px;
  border-radius: 5px; pointer-events: none;
}
.queue-item .qcheck { width: 17px; height: 17px; margin-top: 15px; accent-color: var(--brand-1); cursor: pointer; flex-shrink: 0; }
.queue-item.selected { background: var(--grad-brand-soft); border-radius: 14px; margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.queue-bulk {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 8px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px; color: var(--text-2);
}
.queue-bulk b { color: var(--brand-1); }
.queue-item .qerror {
  margin-top: 7px;
  font-size: 12px; line-height: 1.45;
  color: #dc2626;
  background: rgba(239,68,68,.07);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 9px;
  padding: 6px 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  cursor: help;
}
[data-theme="dark"] .queue-item .qerror { color: #f87171; }

/* ═══════════ CALENDAR ═══════════ */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-title { font-size: 20px; font-weight: 800; font-family: var(--font-display); min-width: 170px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.cal-weekday { text-align: center; font-size: 11.5px; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; padding: 6px 0; }
.cal-day {
  min-height: 104px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  cursor: pointer;
  transition: .15s;
  display: flex; flex-direction: column; gap: 4px;
  overflow: hidden;
}
.cal-day:hover { border-color: var(--brand-1); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-1) 15%, transparent); transform: translateY(-1px); }
.cal-day.other { opacity: .45; background: transparent; }
.cal-day.today { border-color: var(--brand-1); border-width: 2px; }
.cal-day .dnum { font-size: 12.5px; font-weight: 800; color: var(--text-2); }
.cal-day.today .dnum {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--grad-brand); color: #fff;
  display: grid; place-items: center;
}
.cal-event {
  font-size: 10.5px; font-weight: 700;
  padding: 3px 7px; border-radius: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.cal-event.published { background: rgba(16,185,129,.14); color: #0da271; }
.cal-event.scheduled { background: color-mix(in srgb, var(--brand-1) 14%, transparent); color: var(--brand-1); }
.cal-event.failed { background: rgba(239,68,68,.13); color: #dc2626; }
.cal-more { font-size: 10.5px; color: var(--text-3); font-weight: 700; padding-left: 4px; }

/* ═══════════ ENGAGEMENT ═══════════ */
.post-card { margin-bottom: 16px; }
.eng-post-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 0; }
.eng-msg { padding: 10px 20px 0; font-size: 14px; white-space: pre-wrap; }
.eng-media { margin: 12px 20px 0; border-radius: 14px; overflow: hidden; max-height: 300px; }
.eng-media img { width: 100%; object-fit: cover; max-height: 300px; }
.eng-stats {
  display: flex; gap: 18px; align-items: center;
  padding: 13px 20px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 600;
  flex-wrap: wrap;
}
.eng-stats .es { display: flex; align-items: center; gap: 6px; }
.eng-stats svg { width: 17px; height: 17px; }
.eng-stats .es b { color: var(--text); font-family: var(--font-display); }

.reaction-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; margin: 10px 20px 0; background: var(--card-2); }
.reaction-bar span { height: 100%; }

.comment-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-bubble { background: var(--card-2); border-radius: 4px 16px 16px 16px; padding: 9px 14px; flex: 1; }
.comment-bubble .cname { font-weight: 700; font-size: 12.5px; }
.comment-bubble .ctext { font-size: 13.5px; margin-top: 1px; }
.comment-bubble .cmeta { font-size: 11.5px; color: var(--text-3); margin-top: 5px; display: flex; gap: 12px; }
.comment-bubble .cmeta button { border: none; background: none; color: var(--text-2); font-weight: 700; font-size: 11.5px; padding: 0; }
.comment-bubble .cmeta button:hover { color: var(--brand-1); }
.reply-box { margin-top: 9px; display: flex; gap: 8px; }
.reply-item { margin-left: 44px; padding: 8px 0; }

/* ═══════════ SOURCES ═══════════ */
.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.connect-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.connect-card .cicon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 24px;
  margin-bottom: 13px;
}
.connect-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.connect-card p { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }

.map-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.map-table th { text-align: left; padding: 8px 10px; color: var(--text-3); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .6px; border-bottom: 1px solid var(--border); }
.map-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-table tr:last-child td { border-bottom: none; }

.source-row {
  display: flex; align-items: center; gap: 15px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.source-row:last-child { border-bottom: none; }
.source-row .sicon2 { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }

/* ═══════════ ANALYTICS ═══════════ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 15px 17px;
  box-shadow: var(--shadow);
}
.kpi .klabel { font-size: 12px; color: var(--text-2); font-weight: 700; display: flex; align-items: center; gap: 7px; }
.kpi .klabel svg { width: 15px; height: 15px; color: var(--brand-1); }
.kpi .kvalue { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin-top: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-3); border-bottom: 1.5px solid var(--border);
  font-weight: 800;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--card-2); }
.table td.num { font-family: var(--font-display); font-weight: 700; }
.table .rank { width: 34px; height: 34px; border-radius: 10px; background: var(--card-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--text-2); }

.hbar-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.hbar-row .hname { width: 110px; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.hbar-row .htrack { flex: 1; height: 10px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.hbar-row .hfill { height: 100%; border-radius: 99px; background: var(--grad-brand); transition: width .6s cubic-bezier(.2,.8,.3,1); }
.hbar-row .hval { font-size: 12.5px; font-weight: 800; font-family: var(--font-display); min-width: 52px; text-align: right; }

/* Tooltip cho charts */
.chart-tip {
  position: fixed; z-index: 400; pointer-events: none;
  background: #1a1d3d; color: #fff;
  border-radius: 11px; padding: 9px 13px;
  font-size: 12px; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .12s;
  max-width: 250px;
}
.chart-tip .tt { font-weight: 800; margin-bottom: 4px; }
.chart-tip .tr { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.chart-tip .tr .swdot { width: 8px; height: 8px; border-radius: 50%; }
.chart-tip .tr .tv { margin-left: auto; font-weight: 800; padding-left: 14px; }

/* Charts svg */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; }
.chart-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { stroke: var(--card); stroke-width: 2.5; }
.gridline { stroke: var(--border); stroke-dasharray: 3 5; }

/* Sidebar mobile toggle */
.sb-toggle { display: none; }
#backdrop { display: none; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 1280px) {
  .stat-grid, .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .composer-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .sb-toggle { display: inline-flex; }
  #backdrop { display: block; position: fixed; inset: 0; background: rgba(15,17,38,.5); z-index: 45; }
  .main { padding: 0 14px 30px; }
  .stat-grid, .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .cal-day { min-height: 74px; }
}
@media (max-width: 560px) {
  .stat-grid, .kpi-grid { grid-template-columns: 1fr; }
  .cal-grid { gap: 4px; }
}

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }
.view-enter { animation: fadeUp .35s cubic-bezier(.2,.8,.3,1); }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════ Chatbox Tin nhắn (2 cột) ═══════════ */
.chatwrap { display: grid; grid-template-columns: 430px 1fr; padding: 0; overflow: hidden; height: calc(100vh - 130px); min-height: 520px; }
.chat-side { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.chat-side-head { display: flex; align-items: flex-start; gap: 8px; padding: 14px 12px 8px; }
.chat-side-head h3 { display: flex; align-items: center; gap: 7px; font-size: 16px; margin: 0; }
.chatbot-pill { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--card-2); color: var(--text-2); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; margin-top: 5px; }
.chatbot-pill:hover { border-color: var(--brand-1); }
.chatbot-pill b { color: var(--text-1); }
.chatbot-pill.on { background: var(--grad-brand); border-color: transparent; color: #fff; }
.chatbot-pill.on b { color: #fff; }
.chat-conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 10px; }
.chat-conv { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.chat-conv:hover { background: var(--card-2); }
.chat-conv.active { background: var(--grad-brand-soft); box-shadow: inset 3px 0 0 var(--brand-1); }
.chat-conv .avatar { width: 40px; height: 40px; flex-shrink: 0; }
.chat-conv .rmain { flex: 1; min-width: 0; }
.chat-conv .rtitle { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.chat-conv .rsub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; font-size: 11px; color: var(--text-3); }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-empty { margin: auto; text-align: center; color: var(--text-3); max-width: 320px; }
.chat-empty .icon { font-size: 42px; margin-bottom: 8px; }
.chat-main-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-back { display: none; }
.chat-thread { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--card-2); }
.chat-row { display: flex; }
.chat-row.me { justify-content: flex-end; }
.chat-bubble { max-width: 76%; background: var(--card); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; padding: 9px 13px; box-shadow: 0 1px 3px rgba(20,22,43,.06); }
.chat-row.me .chat-bubble { background: var(--grad-brand); border: none; color: #fff; border-radius: 16px 16px 4px 16px; }
.chat-bubble .cname { font-size: 11.5px; font-weight: 800; color: var(--text-3); margin-bottom: 3px; }
.chat-row.me .chat-bubble .cname { color: rgba(255,255,255,.82); }
.chat-bubble .ctext { font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-bubble .cmeta { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
.chat-row.me .chat-bubble .cmeta { color: rgba(255,255,255,.75); }
.chat-img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 6px; cursor: zoom-in; }
.chat-file { display: inline-block; font-size: 12.5px; color: var(--brand-1); margin-top: 6px; text-decoration: none; }
.chat-row.me .chat-file { color: #fff; text-decoration: underline; }
.chat-inputbar { display: flex; gap: 9px; padding: 12px 14px 6px; border-top: 1px solid var(--border); }
.chat-note { padding: 2px 14px 10px; font-size: 11px; color: var(--text-3); }

/* Nhãn & nhóm khách hàng (Tin nhắn) */
.ctags { display: flex; gap: 5px; align-items: center; margin: 2px 0; flex-wrap: wrap; }
.ctag-group { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); color: var(--text-2); font-weight: 700; white-space: nowrap; }
.ctag-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.pal-dot { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; display: inline-block; border: 2px solid rgba(255,255,255,.6); box-shadow: 0 0 0 1px var(--border); }
.pal-dot.sel { border-color: var(--card); box-shadow: 0 0 0 2px var(--brand-1); }
.script-row.sel-row { border-color: var(--brand-1); background: var(--card-2); }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Kịch bản chat có sẵn (Tin nhắn) */
.script-row {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 9px 12px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.script-row:hover { border-color: var(--brand-1); background: var(--card-2); }
.script-row .rtitle { font-weight: 800; font-size: 13.5px; margin-bottom: 2px; }
.script-row .rsub { font-size: 12.5px; color: var(--text-3); }
.script-row .btn { flex-shrink: 0; }

/* Bộ chọn màu chủ đạo (Cài đặt) */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.brand-swatch {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 14px; background: var(--card);
  cursor: pointer; font-family: inherit; color: var(--text); text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.brand-swatch:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.brand-swatch.active { border-color: var(--brand-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 15%, transparent); }
.brand-swatch.active .sw-name { color: var(--brand-1); }
.brand-swatch .sw-dot {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--sw-1), var(--sw-2) 55%, var(--sw-3));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand-swatch .sw-name { font-size: 13px; font-weight: 700; color: var(--text-2); }

/* Trang Cài đặt — tự cân số cột theo chiều rộng (multicol), card không bị cắt đôi;
   .settings-col chỉ là nhóm logic (display:contents) nên thứ tự card giữ nguyên trên mobile */
.settings-wrap { max-width: 1920px; margin-inline: auto; }
.settings-cols { columns: 560px; column-gap: 16px; }
.settings-col { display: contents; }
.settings-cols .card { break-inside: avoid; }

/* Phân trang danh sách (Đăng bài, Tương tác) */
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; padding: 10px 2px 0; border-top: 1px solid var(--border); margin-top: 10px; }
.pager .pg-info { font-size: 12.5px; color: var(--text-2); }
.pager .pg-per { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.pager .pg-per select { width: auto; padding: 4px 8px; font-size: 12.5px; }
.pager .pg-btn:disabled { opacity: .4; cursor: default; }

/* Modal tương tác chi tiết: nội dung trái — bình luận phải */
.modal.eg-wide { max-width: 1080px; }
.eg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; }
.eg-cmt-col { border-left: 1px solid var(--border); padding-left: 18px; }
.eg-cmt-list { max-height: 58vh; overflow-y: auto; }
@media (max-width: 760px) {
  .eg-grid { grid-template-columns: 1fr; }
  .eg-cmt-col { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}

/* Lightbox xem ảnh/video phóng to */
.lightbox-backdrop { position: fixed; inset: 0; z-index: 400; background: rgba(9,10,24,.92); display: flex; align-items: center; justify-content: center; }
.lightbox-backdrop img, .lightbox-backdrop video { max-width: 92vw; max-height: 86vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.55); display: block; }
.lightbox-backdrop .lb-close { position: absolute; top: 16px; right: 18px; width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; font-size: 16px; cursor: pointer; }
.lightbox-backdrop .lb-close:hover { background: rgba(255,255,255,.28); }
.lightbox-backdrop .lb-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255,255,255,.14); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.lightbox-backdrop .lb-arrow:hover { background: rgba(255,255,255,.28); }
.lightbox-backdrop .lb-prev { left: 20px; }
.lightbox-backdrop .lb-next { right: 20px; }
.lightbox-backdrop .lb-foot { position: absolute; bottom: 20px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 12px; color: #fff; font-size: 12.5px; }
.lightbox-backdrop .lb-cap { opacity: .85; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox-backdrop .lb-count { font-weight: 800; }

/* Modal sửa bài: thumbnail media to hơn, bấm xem lớn */
#edit-media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
#edit-media-grid .media-item { cursor: zoom-in; }

/* Hàng chờ: badge số ảnh/video trên thumbnail */
.qthumb-count {
  position: absolute; top: -5px; right: -5px;
  background: var(--brand-1); color: #fff;
  font-size: 9.5px; font-weight: 800; line-height: 1;
  padding: 3px 5px; border-radius: 999px;
  border: 1.5px solid var(--card);
}
.qthumb-wrap .qthumb-count { top: -5px; left: -5px; right: auto; }

/* Modal sửa bài đăng: cao gần hết màn hình — textarea giãn tới đáy, media tự cuộn trong cột phải */
.modal.edit-split { display: flex; flex-direction: column; height: 92vh; max-height: 92vh; }
.modal.edit-split .modal-head { flex-shrink: 0; }
.modal.edit-split .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.modal.edit-split .eg-grid { flex: 1; min-height: 0; align-items: stretch; }
.modal.edit-split .eg-grid > div { display: flex; flex-direction: column; min-height: 0; }
.modal.edit-split .field:has(> #edit-msg) { flex: 1; display: flex; flex-direction: column; min-height: 160px; margin-bottom: 0 !important; }
.modal.edit-split .field:has(> #edit-msg) textarea { flex: 1; resize: none; min-height: 0; }
.modal.edit-split .eg-cmt-col { overflow-y: auto; min-height: 0; }
@media (max-width: 760px) {
  .modal.edit-split { height: auto; }
  .modal.edit-split .modal-body { overflow-y: auto; }
  .modal.edit-split .eg-grid > div { display: block; }
  .modal.edit-split .field:has(> #edit-msg) textarea { min-height: 160px; }
}




/* Luật chatbot trong Cài đặt */
.mbot-rule { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; background: var(--card-2); }
.mbot-rule .input { font-size: 13px; }
.mbot-test-out { border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-top: 8px; display: none; }

@media (max-width: 900px) {
  .chatwrap { grid-template-columns: 1fr; height: calc(100vh - 120px); }
  .chat-main { display: none; }
  .chat-main.open { display: flex; }
  .chatwrap.thread-open .chat-side { display: none; }
  .chat-back { display: inline-flex; }
  .chat-bubble { max-width: 88%; }
}
@media (max-width: 560px) {
  .mbot-rule { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .chat-main-head { gap: 7px; padding: 10px 12px; }
  .chat-main-head .btn.sm { padding: 6px 9px; font-size: 11.5px; }
}

/* ── Sidemenu: dropdown chọn Page sử dụng ── */
.pg-select { padding: 0 14px 12px; border-top: 1px solid rgba(255,255,255,.07); margin-top: 4px; }
.pg-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px;
  color: #5d6396; padding: 12px 10px 5px; font-weight: 700; white-space: nowrap;
}
.pg-select-el {
  width: 100%;
  padding: 9px 30px 9px 11px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 11px;
  background: rgba(255,255,255,.06) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23aab0d6'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: #dfe3ff; font-size: 13px; font-weight: 600; font-family: var(--font);
  appearance: none; -webkit-appearance: none;
  cursor: pointer; transition: background-color .15s ease, border-color .15s ease;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.pg-select-el:hover { background-color: rgba(255,255,255,.1); }
.pg-select-el:focus { outline: none; border-color: rgba(168,85,247,.65); }
.pg-select-el option { background: #1b1e3e; color: #e6e8ff; }
.sidebar.collapsed .pg-select { display: none; }
