/* ============================================================================
   app.css — MsgFlow v2 base layout + component library
   Loaded on every authenticated page. Screen-specific overrides live in
   their own CSS files (inbox.css, campaigns.css, etc.).
   ============================================================================ */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ── App Layout ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-page);
}
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top Nav ────────────────────────────────────────────────────────────────── */
.topnav {
  height: 68px;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
  text-decoration: none;
}
.topnav-logo-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.topnav-logo-text {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.3px;
}
.topnav-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-lighter);
  border-radius: var(--radius-full);
  padding: 4px;
}
.topnav-pill {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.topnav-pill:hover { color: var(--text); background: rgba(255,255,255,0.6); }
.topnav-pill.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(108,99,255,0.1);
}
.pill-badge {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topnav-spacer { flex: 1; }
.topnav-actions { display: flex; align-items: center; gap: 6px; }
.topnav-divider { width: 1px; height: 28px; background: var(--border); margin: 0 8px; }
.topnav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Dropdown (More menu) ───────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 180px;
  z-index: 200;
  padding: 6px;
  animation: slideUp 0.15s ease-out;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--accent-lighter); color: var(--accent); }
.dropdown-item.active { background: var(--accent-lighter); color: var(--accent); font-weight: 600; }
.dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ── Screen area ────────────────────────────────────────────────────────────── */
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
/* Legacy class used by older templates that haven't been migrated yet */
.page-content { flex: 1; padding: 1.5rem; overflow-y: auto; }

/* ── Page header (screen level) ─────────────────────────────────────────────── */
.page-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-hd h1, .screen-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.screen-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.page-wrap { max-width: 1100px; margin: 0 auto; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-static {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -0.5px; }
.stat-sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.stat-change { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: var(--radius-full); }
.stat-change.up   { color: var(--success-text); background: var(--success-light); }
.stat-change.down { color: var(--danger); background: var(--danger-light); }

/* an-card aliases kept for analytics/dashboard compatibility */
.an-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.an-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; text-align: center; }
.an-card-val { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.2; display: flex; align-items: center; justify-content: center; gap: 0.4rem; }
.an-card-lbl { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }
.an-section { margin-bottom: 2rem; }
.an-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 14px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--accent-lighter);
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-md) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-md) 0 0; }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border-light); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--accent-lighter); }
tbody tr:last-child td { border-bottom: none; }

/* an-table alias (analytics/dashboard) */
.an-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.an-table th, .an-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-light); text-align: left; }
.an-table th { background: var(--accent-lighter); font-weight: 600; color: var(--text-secondary); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,168,132,0.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(0,168,132,0.3);
  transform: translateY(-1px);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(108,99,255,0.25);
}
.btn-accent:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(108,99,255,0.3);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--accent-lighter);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: var(--danger-dark); transform: translateY(-1px); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--accent-lighter); color: var(--text); }
.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  cursor: pointer;
}
.btn-icon:hover { background: var(--accent-lighter); color: var(--accent); }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* BEM variants (v1 compat) */
.btn--primary  { background: var(--primary); color: #fff; border: none; box-shadow: 0 2px 8px rgba(0,168,132,0.2); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: var(--bg-card); color: var(--text); border: 1.5px solid var(--border); }
.btn--secondary:hover { background: var(--accent-lighter); border-color: var(--accent); color: var(--accent); }
.btn--danger { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success-text); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-neutral { background: var(--accent-lighter); color: var(--text-secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-accent  { background: rgba(108,99,255,0.1);  color: var(--accent); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.badge-dot.green  { background: var(--success); }
.badge-dot.yellow { background: var(--warning); }
.badge-dot.red    { background: var(--danger); }

/* Campaign status badges (legacy compat) */
.badge.status-scheduled { background: var(--info-bg);       color: var(--info-text); }
.badge.status-running   { background: var(--success-light); color: var(--success-text); }
.badge.status-completed { background: var(--success-bg);    color: var(--success-strong); }
.badge.status-cancelled { background: var(--danger-light);  color: var(--danger); }
.badge.status-paused    { background: var(--warning-light); color: var(--warning-text); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
  width: 100%;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}
.form-input::placeholder { color: var(--text-muted); }
select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.08);
}
.form-control { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--bg-card); font-size: 14px; outline: none; width: 100%; transition: border-color 0.2s; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,99,255,0.08); }
.form-control.sm { max-width: 180px; }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--accent-lighter);
  border-radius: var(--radius-full);
  padding: 4px;
}
.tab {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  border: none;
  background: none;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.5); }
.tab.active { background: var(--bg-card); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(108,99,255,0.08); }

.tabs-underline { display: flex; border-bottom: 2px solid var(--border-light); gap: 0; }
.tab-underline {
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  border: none;
  background: none;
}
.tab-underline:hover { color: var(--text); }
.tab-underline.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,29,46,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s cubic-bezier(0.4,0,0.2,1);
}
.modal-header { padding: 22px 24px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 17px; font-weight: 700; }
.modal-body   { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 12px; }

/* Confirm dialog (campaigns) */
.confirm-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
}
.confirm-dialog::backdrop { background: rgba(26,29,46,0.4); backdrop-filter: blur(4px); }
.confirm-dialog h2 { margin: 0 0 1.25rem; font-size: 1.1rem; font-weight: 700; }
.confirm-summary { background: var(--accent-lighter); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.confirm-summary dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1.25rem; font-size: 0.875rem; margin: 0; }
.confirm-summary dt { color: var(--text-secondary); }
.confirm-summary dd { margin: 0; font-weight: 600; }
.confirm-note  { font-size: 0.8rem; color: var(--text-secondary); margin: 0 0 1.25rem; }
.confirm-btns  { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  animation: slideInRight 0.3s cubic-bezier(0.4,0,0.2,1);
  min-width: 280px;
  pointer-events: all;
}
.toast-success { background: var(--success-text);  color: #fff; }
.toast-error   { background: var(--danger);        color: #fff; }
.toast-info    { background: var(--accent);        color: #fff; }
.toast-warning { background: var(--warning-text);  color: #fff; }

/* ── Progress bars ──────────────────────────────────────────────────────────── */
.progress-bar  { height: 8px; background: var(--accent-lighter); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.5s; }

/* ── Avatar ─────────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  color: #fff;
}

/* ── Tags ───────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

/* ── Search box ─────────────────────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-lighter);
  border: 1.5px solid transparent;
  border-radius: var(--radius-full);
  padding: 9px 16px;
  transition: all 0.2s;
}
.search-box:focus-within {
  background: var(--bg-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.08);
}
.search-box input { border: none; background: none; outline: none; flex: 1; font-size: 14px; min-width: 0; }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-lighter);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--accent);
}
.empty-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-desc  { font-size: 14px; color: var(--text-secondary); max-width: 400px; margin-bottom: 20px; }

/* ── Callouts (guardrail notices) ───────────────────────────────────────────── */
[x-cloak] { display: none !important; }
.callout {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.callout--warning { background: var(--warning-tint); border-color: var(--warning); color: var(--warning-text); }
.callout--danger  { background: var(--danger-tint); border-color: var(--danger-border); color: var(--danger-text); }
.callout--info    { background: var(--accent-lighter); border-color: var(--border); color: var(--text-secondary); }

/* ── Quality indicators ─────────────────────────────────────────────────────── */
.quality-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}
.quality-green  { background: var(--accent-online); }
.quality-yellow { background: var(--warning); }
.quality-red    { background: var(--danger); }

/* ── Tier-cap progress bar (dashboard) ──────────────────────────────────────── */
.tier-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}
.tier-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--accent-lighter);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.tier-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: var(--radius-full);
  transition: width 0.5s;
}
.tier-bar-fill--warn { background: var(--warning); }
.tier-bar-lbl { color: var(--text-secondary); white-space: nowrap; font-size: 13px; }

/* ── Dashboard dash-actions quick panel ─────────────────────────────────────── */
.dash-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ── Native <dialog> — global centering fix ─────────────────────────────────── */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-lighter) 0%, var(--bg-page) 50%, var(--primary-light) 100%);
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 44px;
  width: 440px;
  max-width: 95vw;
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; justify-content: center; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-err  { color: var(--danger); font-size: 13px; background: var(--danger-light); padding: 10px 14px; border-radius: var(--radius); }

/* ── Onboarding step indicator ───────────────────────────────────────────────── */
.onb-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  counter-reset: step;
}
.onb-steps .s {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.25rem 0.6rem 0.25rem 0;
  white-space: nowrap;
}
.onb-steps .s::before {
  content: counter(step);
  counter-increment: step;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-lighter);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.onb-steps .s.on { color: var(--accent); font-weight: 600; }
.onb-steps .s.on::before { background: var(--accent); color: #fff; }
.onb-steps .s.done::before { background: var(--success); color: #fff; content: '✓'; }

/* ── Setup checklist ────────────────────────────────────────────────────────── */
.onb-checklist { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ci { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.ci:last-child { border-bottom: none; }
.ci-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; min-width: 22px; border-radius: 50%; font-size: 0.7rem; font-weight: 700; }
.ci.ok .ci-icon { background: var(--success); color: #fff; }
.ci.no .ci-icon { background: var(--accent-lighter); color: var(--text-secondary); }
.ci-lbl { font-weight: 500; line-height: 1.4; }
.ci.ok .ci-lbl { color: var(--text); }
.ci.no .ci-lbl { color: var(--text-secondary); }
.ci-hint { font-size: 0.775rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp    { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108,99,255,0.25); }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-4  { gap: 4px; }  .gap-8  { gap: 8px; }  .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; }
.page-info { font-size: 13px; color: var(--text-secondary); }
.page-buttons { display: flex; gap: 4px; }
.page-btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--text-secondary); border: 1.5px solid var(--border); transition: all 0.15s; background: var(--bg-card); cursor: pointer; }
.page-btn:hover  { background: var(--accent-lighter); border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Wizard (campaigns) ─────────────────────────────────────────────────────── */
.wizard { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); margin-bottom: 1.5rem; overflow: hidden; }
.wizard-nav { display: flex; list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--border); background: var(--accent-lighter); }
.wizard-nav li { flex: 1; text-align: center; padding: 0.75rem 0.5rem; font-size: 0.85rem; color: var(--text-secondary); border-right: 1px solid var(--border); font-weight: 500; cursor: default; }
.wizard-nav li:last-child { border-right: none; }
.wizard-nav li.active { color: var(--accent); background: var(--bg-card); font-weight: 700; }
.wizard-nav li.done   { color: var(--success); }
.wizard-body    { padding: 1.5rem; }
.wizard-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── Message bubble aliases (inbox) ─────────────────────────────────────────── */
.bubble     { max-width: 65%; padding: 10px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.bubble-in  { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 6px; align-self: flex-start; }
.bubble-out { background: var(--bubble-out); border-bottom-right-radius: 6px; align-self: flex-end; }
.bubble-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.bubble-date { text-align: center; padding: 8px; font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ── Code snippets ───────────────────────────────────────────────────────────── */
code {
  font-size: 12px;
  background: var(--accent-lighter);
  padding: 3px 10px;
  border-radius: 6px;
  color: var(--accent);
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .topnav-pills { flex-wrap: wrap; gap: 2px; padding: 3px; }
  .topnav-pill  { padding: 7px 12px; font-size: 13px; }
  .screen { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  /* Dashboard 2-col → stack */
  [style*="grid-template-columns:1fr 280px"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  .topnav { padding: 0 14px; gap: 10px; }
  .topnav-logo-text { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-hd { flex-direction: column; align-items: flex-start; }
}
