/* ── Reset & Variables ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #00d68f;
  --brand-light:  #e6faf2;
  --brand-dark:   #00b87a;
  --brand-glow:   rgba(0,214,143,.18);
  --sidebar-bg:   #1a1d2e;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --bg:           #f4f5f8;
  --surface:      #ffffff;
  --border:       #e8eaf0;
  --text:         #1a1d2e;
  --text-muted:   #6b7280;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,.07);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.12);
  --transition:   .2s ease;
}

/* ── Dark mode variables ──────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0b0d14;
  --surface:      #151821;
  --border:       #252836;
  --text:         #e4e6eb;
  --text-muted:   #8b8fa3;
  --shadow:       0 2px 12px rgba(0,0,0,.25);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.4);
  --brand-light:  rgba(0,214,143,.15);
  --brand-glow:   rgba(0,214,143,.25);
  --sidebar-bg:   #0d0f17;
}
[data-theme="dark"] .chat-detail-panel { background: #1a1c24; }
[data-theme="dark"] .chat-bubble.customer .bubble-content { background: #252836; color: var(--text); }
[data-theme="dark"] .chat-bubble.agent .bubble-content { background: #054640; color: #e9edef; }
[data-theme="dark"] .wa-preview { background: #1a1c24; }
[data-theme="dark"] .wa-preview-bubble { background: #252836; color: var(--text); }
[data-theme="dark"] .doc-link { background: rgba(255,255,255,.05); }
[data-theme="dark"] .doc-link:hover { background: rgba(255,255,255,.08); }
[data-theme="dark"] .kpi-card { background: var(--surface); }
[data-theme="dark"] .campaign-card { background: var(--surface); }
[data-theme="dark"] .filter-btn { background: var(--surface); color: var(--text-muted); }
[data-theme="dark"] .conv-item:hover { background: rgba(255,255,255,.04); }
[data-theme="dark"] .conv-item.active { background: rgba(233,30,99,.12); }
[data-theme="dark"] img { opacity: .92; }

html, body { height: 100%; font-family: 'PingFang SC','Microsoft YaHei','Helvetica Neue',Arial,sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; transition: background .3s ease, color .3s ease; }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width .25s ease;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .logo-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-divider,
.sidebar.collapsed .badge,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .logo-wrap { justify-content: center; }
.sidebar.collapsed .logo-img { width: 32px; height: 32px; }
.sidebar.collapsed .sidebar-header { padding: 16px 8px 12px; justify-content: center; }
.sidebar.collapsed .sidebar-close { display: none; }
.sidebar.collapsed .nav-item {
  justify-content: center; padding: 10px 0; border-radius: 10px; margin: 2px 8px;
}
.sidebar.collapsed .nav-item i { margin: 0; font-size: 18px; }
.sidebar.collapsed .sidebar-nav { padding: 8px 0; }

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s ease;
}
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 199;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-toggle {
  width: 28px; height: 28px; border-radius: 7px; border: none;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.35);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: all .25s; flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar.collapsed .sidebar-toggle { display: none; }
.logo-wrap { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
  box-shadow: 0 4px 12px var(--brand-glow);
}
.logo-img {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.logo-title { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.logo-sub { color: rgba(255,255,255,.45); font-size: 11px; margin-top: 2px; }

.sidebar-nav {
  flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 8px;
  color: rgba(255,255,255,.6);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 16px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--brand-glow); color: var(--brand); }
.nav-item.active i { color: var(--brand); }
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--brand); color: #fff; border-radius: 10px;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

.sidebar-footer {
  padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.07);
}
.app-links { margin-bottom: 14px; }
.app-links-title { color: rgba(255,255,255,.4); font-size: 11px; font-weight: 600; margin-bottom: 8px; letter-spacing: .5px; text-transform: uppercase; }
.app-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px;
  color: rgba(255,255,255,.6); font-size: 12px; margin-bottom: 4px;
  background: rgba(255,255,255,.04);
  transition: background var(--transition), color var(--transition);
}
.app-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.app-link i { font-size: 14px; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name { color: rgba(255,255,255,.85); font-size: 13px; font-weight: 600; }
.user-status { display: flex; align-items: center; gap: 5px; color: rgba(255,255,255,.4); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 14px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  font-size: 16px; color: var(--text-muted); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  transition: all .2s; flex-shrink: 0;
}
.menu-toggle:hover { color: var(--brand); border-color: var(--brand); background: rgba(0,214,143,.06); }
.sidebar.collapsed ~ .main-content .menu-toggle { display: flex; }
.topbar-title { font-weight: 700; font-size: 17px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg); color: var(--brand); }
.notification-bell { position: relative; }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface);
}

/* ── Page content ─────────────────────────────────────────────────────────── */
.page-content { flex: 1; padding: 24px; overflow: hidden; }
.page { display: none; opacity: 0; }
.page.active { display: block; animation: pageIn .3s ease forwards; }
#page-chat.active { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); }
#page-chat .chat-layout { flex: 1; height: 100%; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 15px;
}
.card-header i { color: var(--brand); margin-right: 8px; }
.card-body { padding: 20px; }

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-icon.pink   { background: var(--brand-light); color: var(--brand); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--text); }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.stat-trend { font-size: 11px; margin-top: 6px; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ── Charts row ───────────────────────────────────────────────────────────── */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-container { position: relative; height: 220px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid rgba(232,234,240,.7); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(233,30,99,.02); }

/* ── Status badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.status-badge.resolved { background: #d1fae5; color: #065f46; }
.status-badge.active   { background: #dbeafe; color: #1e40af; }
.status-badge.pending  { background: #fef3c7; color: #92400e; }
.status-badge.completed{ background: #d1fae5; color: #065f46; }
.status-badge.scheduled{ background: #dbeafe; color: #1e40af; }
.status-badge.draft    { background: #f3f4f6; color: #6b7280; }

/* ── (old chat styles removed — see Chat Layout Fix below) ────────────────── */

/* ── Campaign page ────────────────────────────────────────────────────────── */
.campaign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.template-card {
  border: 2px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: all var(--transition);
  display: flex; align-items: flex-start; gap: 14px;
}
.template-card:hover { border-color: var(--brand); background: var(--brand-light); }
.template-card.selected { border-color: var(--brand); background: var(--brand-light); }
.template-emoji { font-size: 32px; line-height: 1; }
.template-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.template-desc { color: var(--text-muted); font-size: 12px; }

.campaign-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; }
.form-control {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid var(--border); outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--brand); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* WhatsApp preview */
.wa-preview {
  background: #ece5dd; border-radius: 12px; padding: 16px; min-height: 120px;
  font-family: 'Helvetica Neue', Arial, sans-serif;
}
.wa-preview-header { font-size: 11px; color: #6b7280; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.wa-preview-header i { color: #25D366; font-size: 14px; }
.wa-bubble { background: #fff; border-radius: 10px 10px 10px 0; padding: 10px 14px; max-width: 85%; box-shadow: 0 1px 3px rgba(0,0,0,.1); font-size: 13px; line-height: 1.5; }
.wa-bubble img { width: 100%; border-radius: 8px; margin-bottom: 8px; display: block; }
.wa-time { font-size: 10px; color: #92a0a8; text-align: right; margin-top: 4px; }
.wa-product-name { font-weight: 700; margin-bottom: 4px; }
.wa-link { color: #25D366; font-size: 12px; display: block; margin-top: 6px; }

/* Group chips */
.group-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.group-chip {
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border);
  cursor: pointer; font-size: 12px; font-weight: 600; transition: all var(--transition);
}
.group-chip:hover { border-color: var(--brand); color: var(--brand); }
.group-chip.selected { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Delivery stats mini */
.delivery-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 6px; }
.delivery-bar-inner { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); transition: width .6s ease; }
.delivery-stats { display: flex; gap: 16px; margin-top: 8px; }
.delivery-stat { text-align: center; }
.delivery-stat-val { font-weight: 700; font-size: 16px; }
.delivery-stat-lbl { font-size: 10px; color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: 13px;
  transition: all var(--transition); cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 12px var(--brand-glow); }
.btn-outline { border: 1.5px solid var(--border); color: var(--text-muted); background: var(--surface); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 16px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; padding: 13px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500; animation: slideIn .25s ease;
}
.toast.success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.toast.error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.toast.info    { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--info); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader { display: flex; align-items: center; justify-content: center; padding: 40px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc helpers ─────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.section-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--brand); }

.avatar-colors { --c1:#E91E63; --c2:#9c27b0; --c3:#3f51b5; --c4:#2196f3; --c5:#009688; --c6:#ff5722; --c7:#607d8b; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .campaign-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-w) !important; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0 !important; }
  .menu-toggle { display: flex !important; }
  .sidebar-toggle { display: none !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .conv-list { display: none; height: 360px; }
  .conv-list.show { display: flex; }
  .message-area { min-height: 480px; }
  .campaign-form-row { grid-template-columns: 1fr; }
  .  page-content { padding: 14px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { border-radius: 12px 12px 0 0; margin: auto 0 0 0; max-width: 100%; }
}

/* ── Language selector ────────────────────────────────────────────────────── */
.lang-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 200px; overflow-y: auto; }
.lang-item { padding: 6px 8px; border-radius: 6px; border: 1.5px solid var(--border); cursor: pointer; font-size: 12px; text-align: center; transition: all var(--transition); }
.lang-item:hover { border-color: var(--brand); }
.lang-item.selected { border-color: var(--brand); background: var(--brand-light); color: var(--brand); font-weight: 600; }

/* ── Campaign type icons ──────────────────────────────────────────────────── */
.type-icon { font-size: 20px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 48px; opacity: .3; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-dark)); }

/* ── Responsive chat ──────────────────────────────────────────────────────── */
.back-btn { display: none; }
@media (max-width: 768px) {
  .back-btn { display: flex; }
}

/* ── Dashboard KPI ────────────────────────────────────────────────────────── */
.dashboard-grid { display: flex; flex-direction: column; gap: 20px; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-card { animation: cardIn .4s ease both; }
.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .1s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .2s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.kpi-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.kpi-body { flex: 1; }
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.kpi-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.kpi-detail { color: var(--text-muted); font-size: 11px; margin-top: 6px; }

.chart-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
}
.chart-card .card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.chart-card .card-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chart-card .card-header h3 i { color: var(--brand); }
.chart-wrap { padding: 16px 20px; height: 220px; }
.chart-small { display: flex; flex-direction: column; }
.chart-small .card-header { border-bottom: 1px solid var(--border); }

.status-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.status-item { display: flex; align-items: center; gap: 10px; }
.status-dot-lg { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.status-dot-lg.resolved { background: var(--success); }
.status-dot-lg.active { background: var(--info); }
.status-dot-lg.pending { background: var(--warning); }
.status-label { flex: 1; font-size: 13px; }
.status-count { font-weight: 700; font-size: 15px; }

.campaign-stats-mini { padding: 0 20px 16px; }
.cs-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.cs-row span { color: var(--text-muted); }
.cs-row strong { font-weight: 700; }
.cs-divider { height: 1px; background: var(--border); margin: 6px 0; }

@media (max-width: 1024px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }

/* ── Chat Layout Fix ──────────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - var(--topbar-h) - 48px); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); background: var(--surface); }
.conv-list-panel { display: flex; flex-direction: column; border-right: 1px solid var(--border); overflow: hidden; background: var(--surface); min-height: 0; }
.conv-search { padding: 14px; border-bottom: 1px solid var(--border); }
.search-box { position: relative; }
.search-box i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.search-box input {
  width: 100%; padding: 9px 12px 9px 36px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--bg); outline: none;
  transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--brand); }
.conv-filters { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.conv-list { flex: 1; overflow-y: auto; }
.conv-top { display: flex; align-items: center; justify-content: space-between; }
.conv-bottom { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.conv-last-msg { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.conv-phone { color: var(--text-muted); font-size: 11px; }
.conv-status-tag {
  padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;
}
.conv-status-tag.active { background: #dbeafe; color: #1e40af; }
.conv-status-tag.pending { background: #fef3c7; color: #92400e; }
.conv-status-tag.resolved { background: #d1fae5; color: #065f46; }
.has-unread .conv-name { font-weight: 700; }

.chat-detail-panel { display: flex; flex-direction: column; background: #f0ece4; overflow: hidden; min-height: 0; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 12px; }
.chat-empty i { font-size: 56px; opacity: .25; color: #25D366; }
.chat-empty p { font-size: 14px; }

/* ── Nav Section Divider ──────────────────────────────────────────────────── */
.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 12px 16px; }
.nav-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: rgba(255,255,255,.35); padding: 4px 20px 8px; user-select: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Kling-style AI Pages — dark creative workspace
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Kling-style: Page container ──────────────────────────────────────────── */
.kling-page {
  max-width: 1280px; margin: 0 auto;
  background: #0c0d12; border-radius: 16px; padding: 0;
  min-height: calc(100vh - var(--topbar-h) - 72px);
}
.kling-tabs {
  display: flex; gap: 4px; padding: 16px 24px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.kling-tab {
  padding: 10px 20px; border-radius: 10px 10px 0 0; font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.45); background: transparent; border: none; cursor: pointer;
  transition: all .2s;
}
.kling-tab:hover { color: rgba(255,255,255,.7); }
.kling-tab.active {
  color: #fff; background: rgba(255,255,255,.06);
  border-bottom: 2px solid #00d68f;
}
.kling-workspace {
  display: grid; grid-template-columns: 420px 1fr; gap: 0; min-height: 500px;
}
.kling-input {
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
  border-right: 1px solid rgba(255,255,255,.06);
  overflow-y: auto; max-height: calc(100vh - var(--topbar-h) - 140px);
}
.kling-card {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 16px;
}
.kling-card-title {
  font-size: 13px; font-weight: 700; color: rgba(255,255,255,.7);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.kling-card-title i { color: #00d68f; }
.kling-textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.3);
  color: #e4e6eb; font-size: 13.5px; resize: vertical; outline: none;
  font-family: inherit; transition: border-color .2s; line-height: 1.6;
}
.kling-textarea:focus { border-color: #00d68f; }
.kling-textarea::placeholder { color: rgba(255,255,255,.25); }
.kling-char-count { text-align: right; font-size: 11px; color: rgba(255,255,255,.25); margin-top: 4px; }
.kling-settings-grid { display: flex; flex-direction: column; gap: 14px; }
.kling-setting label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.5); margin-bottom: 6px; display: block; }
.kling-chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.kling-chip {
  padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.6); cursor: pointer; transition: all .2s;
}
.kling-chip:hover { border-color: #00d68f; color: #80ebb8; }
.kling-chip.active {
  background: linear-gradient(135deg, rgba(0,214,143,.2), rgba(0,184,122,.15));
  border-color: #00d68f; color: #80ebb8;
}
.kling-upload-zone {
  border: 2px dashed rgba(255,255,255,.1); border-radius: 12px; padding: 28px;
  text-align: center; color: rgba(255,255,255,.3); cursor: pointer; transition: all .2s;
}
.kling-upload-zone:hover, .kling-upload-zone.drag-over { border-color: #00d68f; color: rgba(255,255,255,.5); background: rgba(0,214,143,.05); }
.kling-upload-zone i { font-size: 28px; display: block; margin-bottom: 8px; }
.kling-upload-zone p { font-size: 13px; margin: 0; }
.kling-upload-zone small { font-size: 11px; opacity: .6; }

/* Upload preview */
.upload-preview {
  display: flex; align-items: center; gap: 12px; position: relative;
}
.upload-preview img {
  width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
  border: 1px solid rgba(255,255,255,.15);
}
.upload-preview-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.upload-filename {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-filesize { font-size: 11px; color: rgba(255,255,255,.35); }
.upload-remove {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3);
  color: #f87171; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: all .2s; flex-shrink: 0;
}
.upload-remove:hover { background: rgba(239,68,68,.3); }
.kling-gen-btn {
  width: 100%; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, #00d68f, #00b87a);
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .2s; box-shadow: 0 4px 20px rgba(0,214,143,.3);
}
.kling-gen-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(0,214,143,.4); }
.kling-gen-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.kling-btn-spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite;
}
.kling-output {
  padding: 20px; display: flex; flex-direction: column; background: rgba(0,0,0,.2);
}
.kling-output-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700; color: rgba(255,255,255,.7); margin-bottom: 16px;
}
.kling-status-tag { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px; }
.kling-status-tag.generating { background: rgba(249,168,37,.15); color: #fbbf24; }
.kling-status-tag.success { background: rgba(34,197,94,.15); color: #4ade80; }
.kling-status-tag.error { background: rgba(239,68,68,.15); color: #f87171; }
.kling-result-area { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto; }
.kling-empty-state { text-align: center; color: rgba(255,255,255,.3); padding: 48px; }
.kling-empty-icon {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 16px;
  background: rgba(0,214,143,.1); border: 1px solid rgba(0,214,143,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #00d68f;
}
.kling-empty-state p { font-size: 15px; margin: 0 0 6px; color: rgba(255,255,255,.5); }
.kling-empty-state small { font-size: 12px; }
.kling-generating { text-align: center; padding: 48px; }
.kling-pulse-ring {
  width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%;
  border: 3px solid rgba(0,214,143,.3); border-top-color: #00d68f;
  animation: spin 1.2s linear infinite;
}
.kling-gen-text { font-size: 16px; font-weight: 700; color: rgba(255,255,255,.7); }
.kling-gen-sub { font-size: 12px; color: rgba(255,255,255,.3); margin-top: 6px; }
.kling-error { text-align: center; padding: 48px; color: rgba(255,255,255,.5); }
.kling-error i { font-size: 36px; color: #f87171; margin-bottom: 12px; display: block; }
.kling-error p { font-size: 13px; max-width: 400px; margin: 0 auto; line-height: 1.6; }
.kling-image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; width: 100%; align-self: stretch;
}
.kling-image-item {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03);
  min-height: 100px;
}
.kling-image-item img { width: 100%; height: auto; display: block; cursor: pointer; transition: transform .3s; }
.kling-image-item:hover img { transform: scale(1.03); }
.kling-image-overlay {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  display: flex; justify-content: center; gap: 8px; opacity: 0; transition: opacity .2s;
}
.kling-image-item:hover .kling-image-overlay { opacity: 1; }
.kling-image-overlay button {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(8px);
  border: none; color: #fff; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: background .2s;
}
.kling-image-overlay button:hover { background: rgba(255,255,255,.25); }
.kling-video-wrap { width: 100%; }
.kling-video-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: center; }
.kling-action-btn {
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7); cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.kling-action-btn:hover { background: rgba(0,214,143,.15); border-color: #00d68f; color: #80ebb8; }
.kling-avatar-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kling-avatar-card {
  padding: 12px 8px; border-radius: 12px; border: 2px solid rgba(255,255,255,.08);
  text-align: center; cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.kling-avatar-card:hover { border-color: rgba(0,214,143,.4); }
.kling-avatar-card.selected { border-color: #00d68f; background: rgba(0,214,143,.1); }
.kling-avatar-circle {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff;
}
.kling-avatar-card span { font-weight: 700; font-size: 12px; color: rgba(255,255,255,.7); }
.kling-avatar-card small { font-size: 10px; color: rgba(255,255,255,.35); }
.kling-history {
  margin: 20px; padding: 20px; border-radius: 12px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
}
.kling-history-header h3 {
  font-size: 14px; font-weight: 700; color: rgba(255,255,255,.6);
  margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.kling-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
}
.kling-gallery-empty {
  grid-column: 1 / -1; text-align: center; padding: 24px;
  color: rgba(255,255,255,.2); font-size: 13px;
}
.kling-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 9999;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.kling-viewer img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }
.kling-viewer-close {
  position: absolute; top: 20px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: none; color: #fff;
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
@media (max-width: 768px) {
  .kling-workspace { grid-template-columns: 1fr; }
  .kling-input { max-height: none; border-right: none; border-bottom: 1px solid rgba(255,255,255,.06); }
  .kling-avatar-row { grid-template-columns: repeat(2, 1fr); }
  .kling-tabs { overflow-x: auto; }
}
/* ── Workspace / 工作台 ────────────────────────────────────────────────────── */
.workspace { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.ws-welcome { margin-bottom: 28px; }
.ws-welcome h1 { font-size: 28px; font-weight: 800; margin: 0 0 4px; }
.ws-welcome p { color: var(--text-muted); font-size: 14px; margin: 0; }

.ws-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 32px;
}
.ws-stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
}
.ws-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.ws-stat-num { font-size: 26px; font-weight: 800; line-height: 1; }
.ws-stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.ws-section { margin-bottom: 32px; }
.ws-section h2 { font-size: 17px; font-weight: 700; margin: 0 0 16px; }

.ws-actions {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.ws-action-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  cursor: pointer; transition: all .2s;
}
.ws-action-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.ws-action-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.ws-action-info { flex: 1; min-width: 0; }
.ws-action-info h3 { font-size: 14px; font-weight: 700; margin: 0 0 2px; }
.ws-action-info p { font-size: 12px; color: var(--text-muted); margin: 0; }
.ws-action-arrow { color: var(--text-muted); font-size: 12px; }

.ws-charts { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ws-chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
}
.ws-chart-card h3 { font-size: 14px; font-weight: 700; margin: 0 0 14px; }
.ws-chart-card h3 i { color: var(--brand); margin-right: 6px; }

@media (max-width: 768px) {
  .ws-stats { grid-template-columns: repeat(2, 1fr); }
  .ws-actions { grid-template-columns: 1fr; }
}

/* ── Publish / Buffer-style 内容发布 ────────────────────────────────────────── */
.pub-shell { min-height: calc(100vh - var(--topbar-h) - 40px); background: #0c0d12; border-radius: 16px; }

/* Toolbar */
.pub-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.pub-view-tabs { display: flex; gap: 4px; }
.pub-view-btn {
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: transparent; border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.45); cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.pub-view-btn:hover { color: rgba(255,255,255,.7); border-color: rgba(255,255,255,.15); }
.pub-view-btn.active { color: #fff; background: rgba(255,255,255,.08); border-color: var(--brand); }
.pub-new-btn {
  padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 700;
  background: var(--brand); color: #fff; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: all .2s;
}
.pub-new-btn:hover { background: var(--brand-dark); }

#pub-main { padding: 0; }

/* ── Kanban ────────────────────────────────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; min-height: 500px; }
.kanban-col {
  border-right: 1px solid rgba(255,255,255,.04); padding: 12px;
  transition: background .15s;
}
.kanban-col:last-child { border-right: none; }
.kanban-col.drag-over { background: rgba(0,214,143,.03); }
.kanban-col-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 4px 14px;
  font-size: 13px; font-weight: 700; color: rgba(255,255,255,.6);
}
.kanban-stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 10px;
  color: rgba(255,255,255,.35);
}
.kanban-items { display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  padding: 12px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
  transition: all .15s;
}
.kanban-card:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card-plats { margin-bottom: 6px; display: flex; gap: 6px; font-size: 14px; }
.kanban-card-text { font-size: 13px; color: rgba(255,255,255,.65); line-height: 1.5; margin-bottom: 6px; }
.kanban-card-media { font-size: 11px; color: rgba(255,255,255,.3); margin-bottom: 4px; }
.kanban-card-time { font-size: 11px; color: rgba(255,255,255,.3); display: flex; align-items: center; gap: 4px; }
.kanban-card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.kanban-card-tags span { font-size: 10px; color: var(--brand); opacity: .7; }
.kanban-add-btn {
  padding: 10px; border-radius: 8px; border: 1px dashed rgba(255,255,255,.08);
  background: transparent; color: rgba(255,255,255,.25); font-size: 12px;
  cursor: pointer; transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.kanban-add-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ── Queue ─────────────────────────────────────────────────────────────────── */
.queue-panel { padding: 16px 20px; }
.queue-slots-bar {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  background: rgba(255,255,255,.03); border-radius: 10px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.queue-slots-label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.45); display: flex; align-items: center; gap: 6px; }
.queue-slot-chip {
  padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 700;
  background: rgba(0,214,143,.1); color: var(--brand); border: 1px solid rgba(0,214,143,.2);
}
.queue-slot-add {
  width: 26px; height: 26px; border-radius: 6px; border: 1px dashed rgba(255,255,255,.15);
  background: transparent; color: rgba(255,255,255,.3); cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.queue-slot-add:hover { border-color: var(--brand); color: var(--brand); }
.queue-group { margin-bottom: 16px; }
.queue-date { font-size: 13px; font-weight: 700; color: rgba(255,255,255,.5); margin-bottom: 8px; }
.queue-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; cursor: pointer; margin-bottom: 6px; transition: all .15s;
}
.queue-item:hover { background: rgba(255,255,255,.06); }
.queue-time { font-size: 14px; font-weight: 700; color: rgba(255,255,255,.5); width: 50px; }
.queue-plats { display: flex; gap: 6px; font-size: 16px; }
.queue-text { flex: 1; font-size: 13px; color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Composer overlay ──────────────────────────────────────────────────────── */
.pub-composer-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.composer {
  width: 960px; max-width: 95vw; max-height: 90vh;
  background: #13141a; border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; display: flex; flex-direction: column;
  overflow: hidden;
}
.composer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.composer-header h2 { font-size: 16px; font-weight: 700; margin: 0; color: rgba(255,255,255,.8); }
.composer-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.4); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.composer-close:hover { background: rgba(255,255,255,.1); }
.composer-body {
  display: grid; grid-template-columns: 1fr 320px; flex: 1; overflow-y: auto;
}
.composer-left { padding: 20px; display: flex; flex-direction: column; gap: 16px; border-right: 1px solid rgba(255,255,255,.06); }
.composer-right { padding: 20px; display: flex; flex-direction: column; align-items: center; }
.composer-section label { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.45); margin-bottom: 8px; display: block; }
.composer-textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.3);
  color: #e4e6eb; font-size: 13.5px; resize: vertical; outline: none;
  font-family: inherit; line-height: 1.6; transition: border-color .2s;
}
.composer-textarea:focus { border-color: var(--brand); }
.composer-textarea::placeholder { color: rgba(255,255,255,.2); }
.composer-text-tools {
  display: flex; align-items: center; gap: 10px; margin-top: 6px;
  font-size: 11px; color: rgba(255,255,255,.25);
}
.composer-text-tools .pub-ai-btn { margin-left: auto; }
.composer-plats { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-schedule { display: flex; gap: 8px; }
.composer-quick-times { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.composer-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.06);
}
.composer-footer-right { display: flex; gap: 8px; }
.composer-delete {
  padding: 8px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.2);
  color: #f87171; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.composer-delete:hover { background: rgba(239,68,68,.2); }

/* Composer media */
.composer-media-row { display: flex; gap: 8px; flex-wrap: wrap; }
.composer-thumb {
  width: 72px; height: 72px; border-radius: 8px; overflow: hidden;
  position: relative; border: 1px solid rgba(255,255,255,.1);
}
.composer-thumb img, .composer-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.composer-thumb button {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.7); border: none; color: #fff;
  font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.composer-add-media {
  width: 72px; height: 72px; border-radius: 8px;
  border: 2px dashed rgba(255,255,255,.1); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.25); font-size: 18px; transition: all .15s;
}
.composer-add-media:hover { border-color: var(--brand); color: var(--brand); }

/* Phone preview */
.composer-preview-label { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.35); margin-bottom: 12px; align-self: flex-start; }
.composer-phone {
  width: 280px; background: #000; border-radius: 24px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.1);
}
.phone-status-bar {
  display: flex; justify-content: space-between; padding: 6px 16px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,.6);
}
.phone-status-bar span { display: flex; gap: 4px; }
.phone-app-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 700; color: #fff;
}
.phone-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.phone-dots { margin-left: auto; color: rgba(255,255,255,.4); }
.phone-image { min-height: 160px; background: rgba(255,255,255,.02); }
.phone-image img, .phone-image video { width: 100%; display: block; }
.phone-actions {
  display: flex; gap: 14px; padding: 10px 14px; font-size: 20px; color: #fff; align-items: center;
}
.phone-caption { padding: 2px 14px 14px; font-size: 12px; line-height: 1.5; color: rgba(255,255,255,.7); }
.phone-caption b { color: #fff; margin-right: 4px; }

/* Calendar */
.cal-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 24px;
}
.cal-header h2 { font-size: 18px; font-weight: 700; margin: 0; color: rgba(255,255,255,.8); }
.cal-nav {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
  background: transparent; color: rgba(255,255,255,.5); cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.cal-nav:hover { border-color: var(--brand); color: var(--brand); }

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 24px;
  text-align: center; font-size: 12px; font-weight: 700; color: rgba(255,255,255,.3);
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 8px 24px;
}
.cal-cell {
  min-height: 80px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.02); border: 1px solid transparent;
  transition: all .15s; position: relative;
}
.cal-cell:hover { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }
.cal-cell.cal-today { border-color: var(--brand); background: rgba(0,214,143,.05); }
.cal-cell.cal-empty { cursor: default; background: transparent; }
.cal-cell.cal-empty:hover { background: transparent; border-color: transparent; }
.cal-day-num { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.6); }
.cal-today .cal-day-num { color: var(--brand); font-weight: 800; }
.cal-dots { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-count {
  position: absolute; top: 4px; right: 6px; font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,.4);
}

.pub-platforms-legend {
  display: flex; gap: 16px; padding: 12px 24px; justify-content: center;
  font-size: 11px; color: rgba(255,255,255,.35);
}
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* Calendar day detail */
.cal-day-detail {
  margin: 0 24px 16px; padding: 16px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
}
.cal-detail-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.cal-detail-header h3 { font-size: 14px; font-weight: 700; margin: 0; color: rgba(255,255,255,.7); }
.cal-detail-close {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cal-post-card {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 8px; background: rgba(255,255,255,.03); margin-bottom: 6px;
}
.cal-post-platform {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px;
}
.cal-post-title { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.7); }
.cal-post-meta { font-size: 11px; color: rgba(255,255,255,.35); }

/* Create view */
.pub-platform-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.pub-plat-chip {
  padding: 8px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.5); cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.pub-plat-chip:hover { border-color: rgba(255,255,255,.25); }
.pub-plat-chip.selected { border-color: var(--brand); color: #fff; background: rgba(0,214,143,.1); }
.pub-plat-chip i { font-size: 14px; }

.pub-ai-btn {
  padding: 8px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: linear-gradient(135deg, rgba(0,214,143,.1), rgba(0,184,122,.08));
  border: 1px solid rgba(0,214,143,.25); color: #00d68f; cursor: pointer;
  transition: all .2s; display: inline-flex; align-items: center; gap: 6px;
}
.pub-ai-btn:hover { background: rgba(0,214,143,.15); border-color: var(--brand); }
.pub-ai-btn:disabled { opacity: .5; cursor: not-allowed; }

.pub-input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.3);
  color: #e4e6eb; font-size: 13px; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.pub-input:focus { border-color: var(--brand); }
.pub-schedule-row { display: flex; gap: 10px; }
.pub-quick-times { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.pub-actions { display: flex; gap: 10px; margin-top: 4px; }

/* Media preview */
.pub-media-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pub-media-thumb {
  width: 72px; height: 72px; border-radius: 8px; overflow: hidden; position: relative;
  border: 1px solid rgba(255,255,255,.1);
}
.pub-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub-media-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.7); border: none; color: #fff;
  font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Phone preview */
.pub-preview { display: flex; justify-content: center; padding: 20px; }
.pub-phone-frame {
  width: 320px; background: #000; border-radius: 20px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.1);
}
.pub-phone-header {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  font-size: 13px; font-weight: 700; color: #fff;
}
.pub-phone-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #00b87a);
}
.pub-phone-dots { margin-left: auto; letter-spacing: 2px; color: rgba(255,255,255,.5); }
.pub-phone-image { min-height: 200px; background: rgba(255,255,255,.03); }
.pub-phone-image img, .pub-phone-image video { width: 100%; display: block; }
.pub-phone-actions {
  display: flex; gap: 14px; padding: 10px 14px; font-size: 20px; color: #fff; align-items: center;
}
.pub-phone-text { padding: 4px 14px 14px; font-size: 13px; line-height: 1.5; color: rgba(255,255,255,.8); }
.pub-phone-username { font-weight: 700; margin-right: 6px; }
.pub-phone-caption { color: rgba(255,255,255,.6); }

/* List (drafts/history) */
.pub-list { padding: 16px 24px; display: flex; flex-direction: column; gap: 8px; }
.pub-list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; transition: all .15s;
}
.pub-list-item:hover { background: rgba(255,255,255,.05); }
.pub-list-platforms { display: flex; gap: 6px; font-size: 16px; }
.pub-list-body { flex: 1; min-width: 0; }
.pub-list-text { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub-list-meta { font-size: 11px; color: rgba(255,255,255,.3); margin-top: 2px; }

@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; }
  .kanban-col { border-right: none; border-bottom: 1px solid rgba(255,255,255,.04); }
  .composer-body { grid-template-columns: 1fr; }
  .composer-right { display: none; }
  .cal-grid { padding: 8px 10px; }
  .cal-cell { min-height: 60px; padding: 4px; }
  .composer-schedule { flex-direction: column; }
}

@media (max-width: 480px) {
  .kling-page { border-radius: 0; }
  .kling-input, .kling-output { padding: 14px; }
}

/* ── Conversation List Items ───────────────────────────────────────────────── */
.conv-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition), transform .15s ease;
  display: flex; align-items: center; gap: 12px;
}
.conv-item:active { transform: scale(.985); }
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--brand-light); }

.conv-name-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.conv-name-col .conv-name {
  font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-name-col .conv-time {
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
}

.conv-status-col {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.conv-status-tag {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 12px;
  white-space: nowrap;
}
.conv-status-tag.active { background: #fff8e1; color: #f9a825; }
.conv-status-tag.resolved { background: #e8f5e9; color: #2e7d32; }
.conv-status-tag.pending { background: #fbe9e7; color: #d32f2f; }
[data-theme="dark"] .conv-status-tag.active { background: rgba(249,168,37,.15); color: #fdd835; }
[data-theme="dark"] .conv-status-tag.resolved { background: rgba(46,125,50,.15); color: #66bb6a; }
[data-theme="dark"] .conv-status-tag.pending { background: rgba(211,47,47,.15); color: #ef5350; }

.conv-item .badge {
  min-width: 18px; height: 18px; padding: 0 5px; background: var(--brand); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.conv-list { flex: 1; overflow-y: auto; }

/* ── Avatar ────────────────────────────────────────────────────────────────── */
.conv-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  object-fit: cover;
}
img.conv-avatar { display: block; }

.chat-header {
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-header-name { font-weight: 700; font-size: 15px; }
.chat-header-phone { color: var(--text-muted); font-size: 12px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat-bubble { max-width: 72%; }
.chat-bubble.customer { align-self: flex-start; }
.chat-bubble.agent { align-self: flex-end; }
.bubble-content {
  padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.55;
  word-break: break-word; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.chat-bubble.customer .bubble-content { background: #fff; border-bottom-left-radius: 3px; }
.chat-bubble.agent .bubble-content { background: #dcf8c6; border-bottom-right-radius: 3px; }
.bubble-time { font-size: 10px; color: #92a0a8; margin-top: 3px; padding: 0 4px; }
.chat-bubble.agent .bubble-time { text-align: right; }

.chat-input-area { padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); }
.chat-input-note { color: var(--text-muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.chat-input-note i { color: var(--info); }

/* ── Campaign Page ────────────────────────────────────────────────────────── */
.campaign-page { }
.campaign-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.campaign-toolbar h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.campaign-toolbar h2 i { color: var(--brand); }

.campaign-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.campaign-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.campaign-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.camp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.camp-type, .camp-status { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.camp-name { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.camp-meta { display: flex; gap: 16px; color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.camp-meta i { margin-right: 4px; }
.camp-dates { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.camp-dates i { margin-right: 4px; }
.camp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.camp-stat { text-align: center; padding: 8px; background: var(--bg); border-radius: 8px; }
.camp-stat-value { font-size: 16px; font-weight: 700; }
.camp-stat-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.camp-progress { margin-bottom: 14px; }
.progress-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.progress-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.camp-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  transition: all var(--transition);
}
.btn-send { background: var(--brand); color: #fff; }
.btn-send:hover { background: var(--brand-dark); }
.btn-preview { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.btn-preview:hover { border-color: var(--brand); color: var(--brand); }

.empty-list { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ── Campaign Form (Modal) ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid var(--border); outline: none; background: var(--surface);
  transition: border-color var(--transition); font-size: 13px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.radio-group { display: flex; gap: 16px; margin-top: 6px; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.radio-label input[type="radio"] { accent-color: var(--brand); }

.wa-preview-bubble {
  background: #fff; border-radius: 10px 10px 10px 0; padding: 12px 16px;
  max-width: 85%; box-shadow: 0 1px 3px rgba(0,0,0,.1);
  font-size: 13px; line-height: 1.6; white-space: pre-wrap;
}

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn-secondary {
  padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: 13px;
  background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
  transition: all var(--transition); cursor: pointer;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 8px; font-size: 14px; }
.error-msg { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--danger); gap: 8px; font-size: 14px; }

/* ── Media Messages ───────────────────────────────────────────────────────── */
.media-wrap { max-width: 100%; }
.media-image img {
  max-width: 280px; max-height: 300px; border-radius: 8px; cursor: pointer;
  display: block; object-fit: cover;
  transition: transform .2s ease;
}
.media-image img:hover { transform: scale(1.02); }
.media-caption { padding: 6px 0 2px; font-size: 13px; line-height: 1.4; }

.media-video video { max-width: 300px; max-height: 260px; }

.audio-player {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; min-width: 200px;
}
.audio-play-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: #25D366; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; flex-shrink: 0;
  transition: background .2s;
}
.audio-play-btn:hover { background: #1da851; }
.audio-wave {
  display: flex; align-items: center; gap: 2px; flex: 1; height: 28px;
}
.audio-wave span {
  width: 3px; border-radius: 2px; background: #92a0a8;
  transition: background .2s;
}
.audio-duration { font-size: 11px; color: #92a0a8; white-space: nowrap; }

.doc-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px; background: rgba(0,0,0,.04);
  text-decoration: none; color: inherit;
  transition: background .2s;
}
.doc-link:hover { background: rgba(0,0,0,.08); }
.doc-icon {
  width: 40px; height: 40px; border-radius: 8px;
  background: #e8eaf0; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.doc-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.doc-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.media-sticker img { max-width: 160px; }

/* ── Message Status Ticks ─────────────────────────────────────────────────── */
.tick { font-size: 11px; margin-left: 3px; letter-spacing: -2px; }
.tick-sent { color: #92a0a8; }
.tick-delivered { color: #92a0a8; }
.tick-read { color: #53bdeb; }
.tick-failed { color: #ef4444; letter-spacing: 0; }
.tick-pending { letter-spacing: 0; }

/* ── Bubble animation ─────────────────────────────────────────────────────── */
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Enhanced Responsive ──────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .page-content { padding: 14px; }

  .chat-layout { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - var(--topbar-h) - 28px); }
  .conv-list-panel { max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .conv-list-panel.hidden { display: none; }
  .chat-detail-panel.hidden { display: none; }
  .back-btn { display: flex; }

  .campaign-cards { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  .topbar-title { font-size: 15px; }
  .modal { border-radius: 16px 16px 0 0; margin: auto 0 0; max-width: 100%; max-height: 85vh; }
}

/* Mobile */
@media (max-width: 480px) {
  .page-content { padding: 10px; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { width: 40px; height: 40px; font-size: 16px; }

  .stats-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 180px; }

  .conv-list-panel { max-height: 40vh; }
  .chat-bubble { max-width: 88%; }
  .media-image img { max-width: 220px; }
  .media-video video { max-width: 240px; }

  .camp-stats { grid-template-columns: repeat(2, 1fr); }
  .camp-meta { flex-direction: column; gap: 4px; }

  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 14px; }

  .sidebar { width: 260px; }
}

/* Desktop wide */
@media (min-width: 1400px) {
  .chat-layout { grid-template-columns: 400px 1fr; }
  .campaign-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ── Scrollbar styling ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ── Focus/accessibility ──────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Smooth transitions for theme ─────────────────────────────────────────── */
.sidebar, .main-content, .topbar, .card, .kpi-card, .campaign-card, .modal,
.conv-list-panel, .chat-detail-panel, .chat-header, .btn-primary, .btn-secondary,
.conv-item, .filter-btn, .chat-bubble .bubble-content, .wa-preview, .wa-preview-bubble {
  transition: background .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease;
}
