@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0b0f14;
  --bg-secondary: #111820;
  --bg-tertiary: #19222d;
  --bg-hover: #1e2936;
  --bg-active: #243342;
  --surface: #1a2332;
  --surface-raised: #1e2a3a;
  --border: #243342;
  --border-subtle: #1c2735;

  --text-primary: #e8edf3;
  --text-secondary: #8899aa;
  --text-muted: #556677;
  --text-inverse: #0b0f14;

  --accent: #25d366;
  --accent-dim: #1a9e4a;
  --accent-glow: rgba(37, 211, 102, 0.15);
  --accent-subtle: rgba(37, 211, 102, 0.08);

  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font-sans: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */

.sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.sidebar-logo .dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
}

.sidebar-biz {
  margin-top: 12px;
}

.sidebar-biz select {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

.sidebar-biz select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.ws-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ws-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* --- Main content --- */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.view-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.view-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.view-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* === COMMON ELEMENTS === */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-active { background: var(--accent-glow); color: var(--accent); }
.badge-syncing { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-disconnected { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-approved { background: var(--accent-glow); color: var(--accent); }
.badge-rejected { background: rgba(239,68,68,0.15); color: var(--red); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}

.empty-state svg { width: 40px; height: 40px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

.input {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

select.input {
  cursor: pointer;
}

/* === CARDS & STATS === */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  font-feature-settings: 'tnum';
  letter-spacing: -0.02em;
}

/* === INBOX === */

.inbox-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.inbox-list {
  width: 340px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.inbox-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border-subtle);
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }

.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  flex-shrink: 0;
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-time {
  font-size: 11px;
  color: var(--text-muted);
  font-feature-settings: 'tnum';
}

.conv-unread {
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* --- Messages thread --- */

.thread-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  max-width: 65%;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
}

.msg-incoming {
  align-self: flex-start;
  background: var(--surface-raised);
  border-bottom-left-radius: 4px;
}

.msg-outgoing {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.6;
  justify-content: flex-end;
}

.msg-ticks {
  display: inline-flex;
  align-items: center;
  position: relative;
  color: rgba(255,255,255,0.5);
  margin-left: 2px;
}

.msg-ticks .tick-icon { vertical-align: middle; }

.msg-ticks .tick-icon-overlay {
  margin-left: -9px;
}

.msg-ticks.delivered { color: rgba(255,255,255,0.7); }
.msg-ticks.read { color: #53bdeb; }
.msg-ticks.failed { color: var(--red); }

.msg-incoming .msg-ticks { color: var(--text-muted); }
.msg-incoming .msg-ticks.read { color: #53bdeb; }

/* --- Compose bar --- */

.compose-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.compose-input {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.4;
}

.compose-input:focus {
  border-color: var(--accent);
}

.compose-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.compose-send:hover { background: var(--accent-dim); }
.compose-send svg { width: 18px; height: 18px; fill: var(--text-inverse); }

/* === TEMPLATES === */

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color 0.15s;
}

.tpl-card:hover { border-color: var(--accent); }

.tpl-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.tpl-name {
  font-weight: 600;
  font-size: 15px;
  font-family: var(--font-mono);
}

.tpl-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.tpl-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* === MODAL === */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

/* === TOAST === */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s;
  max-width: 360px;
}

.toast-success { border-left: 3px solid var(--accent); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }

/* === ANIMATIONS === */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === SCROLLBAR === */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === TABS === */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: var(--font-sans);
}

.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--accent); color: var(--text-inverse); }

/* === ONBOARD SECTION === */

.onboard-section {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
}

.btn-connect {
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  transition: background 0.15s;
}

.btn-connect:hover { background: var(--accent-dim); }
.btn-connect:disabled { background: var(--bg-tertiary); color: var(--text-muted); cursor: not-allowed; }

/* === STATUS ALERT === */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

.alert-info { background: rgba(59,130,246,0.1); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
.alert-success { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(37,211,102,0.2); }
.alert-error { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.alert-warn { background: rgba(245,158,11,0.1); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }

/* === LOGIN PAGE === */

.login-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 9999;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  justify-content: center;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

/* === DATA TABLE === */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* === SIDEBAR USER === */

.sidebar-user {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* === KEY DISPLAY === */

.key-display {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 8px;
}

/* === BADGE VARIANTS === */

.badge-admin { background: rgba(168,85,247,0.15); color: var(--purple); }
.badge-developer { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-manager { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-agent { background: var(--accent-subtle); color: var(--accent); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-approved, .badge-active { background: var(--accent-subtle); color: var(--accent); }
.badge-rejected, .badge-disconnected, .badge-inactive { background: rgba(239,68,68,0.15); color: var(--red); }

/* === ERROR COLOR VAR === */

:root { --error: var(--red); --warning: var(--amber); --color-info: var(--blue); --color-success: var(--accent); --color-primary: var(--purple); --color-danger: var(--red); }

/* === CAMPAIGN BADGE VARIANTS === */

.badge-info { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-success { background: var(--accent-subtle); color: var(--accent); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-muted { background: rgba(85,102,119,0.15); color: var(--text-muted); }
.badge-pulse { animation: badge-pulse 1.5s ease-in-out infinite; }
@keyframes badge-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.btn-danger-text { color: var(--red); }
.btn-warning { background: var(--amber); color: var(--text-inverse); }
.btn-danger { background: var(--red); color: #fff; }

/* === CAMPAIGN STYLES === */

.campaign-wizard { max-width: 640px; }
.wizard-steps { display: flex; gap: 16px; margin-bottom: 24px; }
.wizard-step { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem; }
.wizard-step.active { color: var(--accent); font-weight: 600; }
.wizard-step.done { color: var(--text-secondary); }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--bg-tertiary); font-size: 0.75rem; font-weight: 600; }
.wizard-step.active .step-num { background: var(--accent); color: var(--text-inverse); }
.wizard-step.done .step-num { background: var(--accent-dim); color: #fff; }
.wizard-content { display: flex; flex-direction: column; gap: 12px; }
.wizard-nav { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }
.checkbox-label, .radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.campaign-review { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surface); border-radius: var(--radius-md); }
.review-row { display: flex; justify-content: space-between; }
.review-label { color: var(--text-muted); }
.review-value { font-weight: 500; }

.campaign-info-bar { display: flex; flex-wrap: wrap; gap: 20px; padding: 12px 16px; background: var(--surface); border-radius: var(--radius-md); margin-bottom: 16px; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.campaign-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { padding: 16px; background: var(--surface); border-radius: var(--radius-md); text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.stat-pct { font-size: 0.75rem; color: var(--text-secondary); }

.campaign-progress { margin-bottom: 16px; }
.campaign-progress span { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; display: block; }
.campaign-progress-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.campaign-progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }

.campaign-controls { display: flex; gap: 8px; margin-bottom: 16px; }
.mono-sm { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; }

/* === MOBILE TOGGLE BUTTON === */
.mobile-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.5);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
  .sidebar { display: none; position: fixed; z-index: 100; height: 100vh; }
  .sidebar.open { display: flex; }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .view-header { padding-left: 48px; }
  .campaign-stats { grid-template-columns: repeat(2, 1fr); }
  .wizard-steps { flex-wrap: wrap; }
  .data-table { display: block; overflow-x: auto; }
}

@media (max-width: 640px) {
  .campaign-stats { grid-template-columns: repeat(2, 1fr); }
  .wizard-steps { flex-wrap: wrap; }
}

/* === TEMPLATE PREVIEW === */

.template-preview { margin-top: 8px; }
.tpl-preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; max-width: 400px; }
.tpl-preview-header { font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.tpl-preview-header.tpl-preview-media { color: var(--text-muted); font-style: italic; font-weight: 400; }
.tpl-preview-body { white-space: pre-wrap; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.tpl-var { background: rgba(59,130,246,0.2); color: var(--blue); padding: 1px 4px; border-radius: 3px; font-weight: 500; }
.tpl-preview-vars { font-size: 0.8rem; color: var(--blue); margin-bottom: 8px; }
.tpl-preview-footer { font-size: 0.8rem; color: var(--text-muted); border-top: 1px solid var(--border-subtle); padding-top: 8px; margin-top: 8px; }
.tpl-preview-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; border-top: 1px solid var(--border-subtle); padding-top: 8px; }
.tpl-btn-pill { background: var(--bg-tertiary); color: var(--blue); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; }

/* === CAMPAIGN CHARTS === */

.campaign-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card { background: var(--surface); border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column; align-items: center; }
.chart-title { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; align-self: flex-start; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.funnel { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 8px; }
.funnel-label { width: 70px; font-size: 0.8rem; color: var(--text-muted); text-align: right; }
.funnel-bar { flex: 1; height: 24px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.funnel-value { font-size: 0.8rem; color: var(--text-secondary); min-width: 80px; }

/* Scheduled campaign info */
.campaign-scheduled-info { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 12px 16px; background: var(--surface); border-radius: var(--radius-md); }
.countdown { font-weight: 600; color: var(--blue); }

@media (max-width: 768px) { .campaign-charts { grid-template-columns: 1fr; } }
