/* ═══════════════════════════════════════════════════════════
   WA AUTOMATION — DESIGN SYSTEM
   Dark SaaS theme · Outfit + JetBrains Mono
═══════════════════════════════════════════════════════════ */

:root {
  --bg-base:       #080d0a;
  --bg-surface:    #0f1612;
  --bg-elevated:   #162019;
  --bg-card:       #1a2820;
  --bg-hover:      #1f3028;
  --border:        #243328;
  --border-light:  #2d3f34;

  --green:         #25D366;
  --green-dim:     #1a9e4a;
  --green-glow:    rgba(37,211,102,0.15);
  --green-subtle:  rgba(37,211,102,0.08);
  --teal:          #128C7E;

  --text-primary:  #e8f0eb;
  --text-secondary:#8fa898;
  --text-muted:    #4d6358;
  --text-inverse:  #080d0a;

  --blue:          #4A9EFF;
  --blue-dim:      rgba(74,158,255,0.15);
  --purple:        #9B6DFF;
  --purple-dim:    rgba(155,109,255,0.15);
  --orange:        #FF8C42;
  --orange-dim:    rgba(255,140,66,0.15);
  --red:           #FF4D4D;
  --red-dim:       rgba(255,77,77,0.15);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow:        0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);
  --shadow-green:  0 0 24px rgba(37,211,102,0.2);

  --sidebar-w:     240px;
  --topbar-h:      60px;
  --transition:    0.18s ease;

  --font-ui:       'Outfit', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-ui); }
input, textarea, select {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-subtle);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg-card); }
textarea { resize: vertical; }
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   AUTH
═══════════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
}
.auth-overlay:not(.active) { display: none; }

.auth-bg-pattern {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(37,211,102,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(18,140,126,0.05) 0%, transparent 50%);
}

.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(37,211,102,0.06);
  animation: slideUp 0.4s ease;
}

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

.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
  font-size: 1.2rem; font-weight: 700; color: var(--text-primary);
}

.auth-title {
  font-size: 1.7rem; font-weight: 700;
  color: var(--text-primary); margin-bottom: 6px;
}
.auth-subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 0.9rem; }

.auth-error {
  background: var(--red-dim); border: 1px solid var(--red);
  color: var(--red); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 16px; font-size: 0.875rem;
}

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

.auth-demo {
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.auth-demo code {
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--green);
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════ */
.app {
  display: flex; height: 100vh; overflow: hidden;
}
.app:not(.hidden) { display: flex; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span:not(.nav-count):not(.nav-badge),
.sidebar.collapsed .wa-status-pill span,
.sidebar.collapsed .user-details { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .wa-status-pill { justify-content: center; padding: 8px; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand { font-weight: 700; font-size: 1rem; color: var(--text-primary); white-space: nowrap; }
.sidebar-toggle {
  background: none; border: none; color: var(--text-muted);
  padding: 4px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

.wa-status-pill {
  margin: 12px 12px 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 99px; padding: 6px 12px;
  font-size: 0.78rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.connecting { background: var(--orange); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 8px 8px;
}
.nav-section-label {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 12px 8px 4px; white-space: nowrap;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition); position: relative;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--green-subtle);
  color: var(--green);
  border: 1px solid rgba(37,211,102,0.2);
}
.nav-item svg { flex-shrink: 0; }
.nav-count {
  margin-left: auto; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 1px 7px; font-size: 0.72rem;
  font-family: var(--font-mono); color: var(--text-muted);
}
.nav-badge {
  margin-left: auto; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red);
  display: none;
}
.nav-badge.visible { display: block; }

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-dim); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }
.logout-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 6px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* ── Main Content ── */
.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn { display: none; }
.page-breadcrumb { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 12px;
  transition: border-color var(--transition);
}
.topbar-search:focus-within { border-color: var(--green); }
.topbar-search svg { color: var(--text-muted); flex-shrink: 0; }
.topbar-search input {
  background: none; border: none; padding: 0; width: 180px;
  font-size: 0.85rem; color: var(--text-primary);
}
.topbar-search input:focus { box-shadow: none; }

.topbar-btn {
  position: relative; background: var(--bg-elevated);
  border: 1px solid var(--border); color: var(--text-secondary);
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.topbar-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); display: none;
}
.notif-dot.visible { display: block; }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-dim); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
}

/* ── Notifications Panel ── */
.notifications-panel {
  position: absolute; top: calc(var(--topbar-h) + 8px); right: 16px;
  width: 320px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 200;
  animation: fadeIn 0.15s ease;
}
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.875rem; font-weight: 600;
}
.notif-header button {
  background: none; border: none; color: var(--text-muted);
  font-size: 0.8rem; transition: color var(--transition);
}
.notif-header button:hover { color: var(--green); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; display: flex; gap: 10px; align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-text { flex: 1; }
.notif-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Pages ── */
.page {
  display: none; flex: 1; overflow-y: auto;
  padding: 24px; animation: fadeIn 0.2s ease;
}
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: var(--green); color: var(--text-inverse);
  border-color: var(--green);
}
.btn-primary:hover { background: #20c05a; box-shadow: var(--shadow-green); }
.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-danger {
  background: var(--red-dim); color: var(--red);
  border-color: rgba(255,77,77,0.3);
}
.btn-danger:hover { background: var(--red); color: white; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
  background: none; border: none; color: var(--text-muted);
  padding: 6px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-spinner {
  width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.2);
  border-top-color: var(--text-inverse); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.82rem; font-weight: 500; color: var(--text-secondary);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { font-size: 0.78rem; color: var(--text-muted); }
.char-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); float: right; }

.input-with-icon { position: relative; }
.input-with-icon input { padding-right: 40px; }
.toggle-password {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  transition: color var(--transition);
}
.toggle-password:hover { color: var(--text-primary); }

/* Toggle switch */
.toggle-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 0.875rem; color: var(--text-primary);
  user-select: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle {
  width: 38px; height: 20px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 99px;
  position: relative; transition: all var(--transition); flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted); transition: all var(--transition);
}
.toggle-label input:checked + .toggle { background: var(--green); border-color: var(--green); }
.toggle-label input:checked + .toggle::after { left: 20px; background: white; }

/* Range */
.range-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  flex: 1; height: 4px; background: var(--border);
  border: none; border-radius: 99px; padding: 0;
  accent-color: var(--green);
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; gap: 16px; align-items: flex-start;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.green { background: var(--green-subtle); color: var(--green); }
.stat-icon.blue  { background: var(--blue-dim);    color: var(--blue); }
.stat-icon.purple{ background: var(--purple-dim);  color: var(--purple); }
.stat-icon.orange{ background: var(--orange-dim);  color: var(--orange); }
.stat-body { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.stat-value {
  font-size: 1.7rem; font-weight: 700; line-height: 1.1;
  font-family: var(--font-mono); color: var(--text-primary);
}
.stat-delta { font-size: 0.75rem; color: var(--text-muted); }
.stat-delta.positive { color: var(--green); }
.stat-delta.negative { color: var(--red); }

.charts-row {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 16px; margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-title { font-size: 0.9rem; font-weight: 600; }
.chart-tabs { display: flex; gap: 4px; }
.chart-tab {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); padding: 4px 10px;
  border-radius: var(--radius-sm); font-size: 0.78rem;
  transition: all var(--transition);
}
.chart-tab.active, .chart-tab:hover {
  background: var(--green-subtle); color: var(--green);
  border-color: rgba(37,211,102,0.3);
}
.donut-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; font-size: 0.9rem; font-weight: 600;
}
.panel-link { font-size: 0.8rem; color: var(--green); }
.panel-link:hover { text-decoration: underline; }
.live-badge {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em;
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(255,77,77,0.3); border-radius: 99px;
  padding: 2px 8px; animation: pulse 2s infinite;
}

/* Campaign list */
.campaign-list { display: flex; flex-direction: column; gap: 10px; }
.campaign-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.campaign-item-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--green-subtle); color: var(--green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.campaign-item-body { flex: 1; min-width: 0; }
.campaign-item-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.campaign-item-meta { font-size: 0.75rem; color: var(--text-muted); }
.campaign-item-progress { width: 60px; }
.campaign-progress-bar { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.campaign-progress-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width 0.5s ease; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.activity-item {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.82rem; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.activity-text { flex: 1; color: var(--text-secondary); }
.activity-text strong { color: var(--text-primary); }
.activity-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   WHATSAPP CONNECT
═══════════════════════════════════════════════════════════ */
.wa-connect-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 24px;
}
.wa-connect-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 40px;
  display: flex; align-items: center; justify-content: center;
  min-height: 400px;
}
.wa-connect-status { display: flex; gap: 48px; align-items: center; flex-wrap: wrap; justify-content: center; }
.qr-container {
  width: 200px; height: 200px;
  background: white; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-spinner {
  width: 36px; height: 36px; border: 3px solid rgba(37,211,102,0.2);
  border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.qr-placeholder p { font-size: 0.8rem; color: #666; }
#qr-canvas { width: 200px !important; height: 200px !important; }

.wa-instructions h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }
.wa-instructions ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.wa-instructions li { font-size: 0.875rem; color: var(--text-secondary); }
.wa-instructions li strong { color: var(--text-primary); }
.wa-instructions .btn { margin-top: 20px; }

.wa-connected-view {
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.connected-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--green-subtle); border: 2px solid rgba(37,211,102,0.3);
  display: flex; align-items: center; justify-content: center;
}
.wa-connected-view h3 { font-size: 1.4rem; font-weight: 700; }
.wa-connected-view p { color: var(--text-secondary); font-family: var(--font-mono); }

.wa-info-panel { display: flex; flex-direction: column; gap: 16px; }
.info-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.info-card h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 14px; color: var(--text-secondary); }
.info-rows { display: flex; flex-direction: column; gap: 10px; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem;
}
.info-row span:first-child { color: var(--text-muted); }

.rate-limit-bars { display: flex; flex-direction: column; gap: 14px; }
.rate-bar-item { display: flex; flex-direction: column; gap: 6px; }
.rate-bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--text-muted);
}
.rate-bar-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.rate-bar-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width 0.5s ease; }

/* ═══════════════════════════════════════════════════════════
   MESSAGING
═══════════════════════════════════════════════════════════ */
.messaging-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; }
.compose-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px;
}
.compose-title { font-size: 1rem; font-weight: 700; margin-bottom: 20px; }

.recipient-tabs, .msg-type-tabs {
  display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap;
}
.rtab, .mtab {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); padding: 6px 12px;
  border-radius: var(--radius-sm); font-size: 0.8rem;
  transition: all var(--transition);
}
.rtab.active, .mtab.active,
.rtab:hover, .mtab:hover {
  background: var(--green-subtle); color: var(--green);
  border-color: rgba(37,211,102,0.3);
}
.rtab-content, .mtype-content { display: none; }
.rtab-content.active, .mtype-content.active { display: block; }

.contact-filter-row { display: flex; gap: 8px; margin-bottom: 8px; }
.contact-filter-row input, .contact-filter-row select { flex: 1; }
.msg-contact-list {
  max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.msg-contact-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.msg-contact-item:last-child { border-bottom: none; }
.msg-contact-item:hover { background: var(--bg-hover); }
.msg-contact-item input[type="checkbox"] { width: auto; }

.msg-toolbar {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.toolbar-btn {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 4px 10px;
  border-radius: var(--radius-sm); font-size: 0.78rem;
  font-family: var(--font-mono); transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--green-subtle); color: var(--green); border-color: rgba(37,211,102,0.3); }

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: all var(--transition); color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.upload-zone:hover { border-color: var(--green); color: var(--green); background: var(--green-subtle); }
.upload-zone.small { padding: 20px; }
.upload-zone p { font-size: 0.875rem; font-weight: 500; }
.upload-zone span { font-size: 0.78rem; }

.send-options { display: flex; flex-direction: column; gap: 12px; }
.option-row { display: flex; flex-direction: column; gap: 8px; }
.delay-inputs {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--text-secondary);
}
.delay-inputs input { width: 60px; text-align: center; }

.compose-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* Phone mockup */
.phone-mockup { display: flex; justify-content: center; margin-bottom: 20px; }
.phone-frame {
  width: 260px; background: #1a1a1a;
  border-radius: 36px; padding: 12px;
  border: 2px solid #333;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.phone-notch {
  width: 80px; height: 20px; background: #1a1a1a;
  border-radius: 0 0 14px 14px; margin: 0 auto 8px;
}
.phone-screen {
  background: #e5ddd5; border-radius: 24px; overflow: hidden;
  min-height: 360px; display: flex; flex-direction: column;
}
.wa-chat-header {
  background: #075e54; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.wa-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #25D366; color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.wa-contact-info { display: flex; flex-direction: column; }
.wa-contact-name { font-size: 0.85rem; font-weight: 600; color: white; }
.wa-contact-status { font-size: 0.72rem; color: rgba(255,255,255,0.7); }
.wa-messages { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.wa-msg { display: flex; }
.wa-msg.outgoing { justify-content: flex-end; }
.wa-bubble {
  background: #dcf8c6; border-radius: 8px 0 8px 8px;
  padding: 8px 10px; max-width: 85%;
  font-size: 0.82rem; color: #1a1a1a; position: relative;
}
.wa-time { font-size: 0.65rem; color: #666; float: right; margin-left: 8px; margin-top: 2px; }

/* Send progress */
.send-progress {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.progress-header {
  display: flex; justify-content: space-between;
  font-size: 0.875rem; font-weight: 600; margin-bottom: 12px;
}
.progress-bar-track { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress-bar-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width 0.3s ease; }
.progress-log { max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.progress-log-item { font-size: 0.78rem; font-family: var(--font-mono); color: var(--text-muted); }
.progress-log-item.success { color: var(--green); }
.progress-log-item.error { color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   CAMPAIGNS GRID
═══════════════════════════════════════════════════════════ */
.campaigns-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; margin-top: 16px;
}
.campaign-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color var(--transition), transform var(--transition);
}
.campaign-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.campaign-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.campaign-card-name { font-size: 0.95rem; font-weight: 600; }
.campaign-card-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.campaign-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 14px 0; padding: 12px; background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
.campaign-stat { display: flex; flex-direction: column; gap: 2px; }
.campaign-stat-val { font-size: 1.1rem; font-weight: 700; font-family: var(--font-mono); }
.campaign-stat-label { font-size: 0.72rem; color: var(--text-muted); }
.campaign-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
}
.campaign-card-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════════
   CONTACTS TABLE
═══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.filter-bar input { max-width: 280px; }
.filter-bar select { max-width: 160px; }
.filter-count { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }

.table-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--bg-elevated); }
.data-table th {
  padding: 12px 14px; text-align: left;
  font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text-primary); }
.sort-icon { opacity: 0.4; }
.data-table td {
  padding: 12px 14px; font-size: 0.85rem;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table input[type="checkbox"] { width: auto; cursor: pointer; }

.contact-name-cell { display: flex; align-items: center; gap: 10px; }
.contact-avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-dim); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.phone-mono { font-family: var(--font-mono); font-size: 0.82rem; }
.tags-cell { display: flex; gap: 4px; flex-wrap: wrap; }

.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 0.82rem; color: var(--text-muted);
}
.pagination { display: flex; gap: 4px; }
.page-btn {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); width: 30px; height: 30px;
  border-radius: var(--radius-sm); font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--green-subtle); color: var(--green);
  border-color: rgba(37,211,102,0.3);
}

.bulk-actions {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg); z-index: 50;
  animation: slideUp 0.2s ease;
}
.bulk-actions span { font-size: 0.85rem; font-weight: 600; color: var(--green); }

/* ═══════════════════════════════════════════════════════════
   GROUPS
═══════════════════════════════════════════════════════════ */
.groups-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-top: 16px;
}
.group-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color var(--transition), transform var(--transition);
}
.group-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.group-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.group-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--green-subtle); color: var(--green);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.group-name { font-size: 0.95rem; font-weight: 600; }
.group-id { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }
.group-members { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 14px; }
.group-card-footer { display: flex; gap: 8px; }

/* ═══════════════════════════════════════════════════════════
   ANALYTICS
═══════════════════════════════════════════════════════════ */
.analytics-grid {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.analytics-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.analytics-card.wide { grid-column: 1 / -1; }

/* ═══════════════════════════════════════════════════════════
   SETTINGS
═══════════════════════════════════════════════════════════ */
.settings-layout { display: grid; grid-template-columns: 180px 1fr; gap: 24px; }
.settings-nav {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 8px; height: fit-content;
}
.stab {
  background: none; border: none; color: var(--text-secondary);
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 0.875rem; text-align: left; font-weight: 500;
  transition: all var(--transition);
}
.stab:hover { background: var(--bg-hover); color: var(--text-primary); }
.stab.active { background: var(--green-subtle); color: var(--green); }
.stab-content { display: none; }
.stab-content.active { display: block; }
.stab-content h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
.settings-form { display: flex; flex-direction: column; gap: 18px; max-width: 560px; }
.settings-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
}

.backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.backup-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
}
.backup-card h4 { font-size: 0.9rem; font-weight: 600; }
.backup-card p { font-size: 0.8rem; color: var(--text-muted); }

.api-key-display { display: flex; flex-direction: column; gap: 8px; }
.api-key-row { display: flex; gap: 8px; align-items: center; }
.api-key-row input { flex: 1; font-family: var(--font-mono); font-size: 0.82rem; }

.danger-zone { display: flex; flex-direction: column; gap: 0; }
.danger-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; border-bottom: 1px solid var(--border); gap: 16px;
}
.danger-item:last-child { border-bottom: none; }
.danger-item h4 { font-size: 0.9rem; font-weight: 600; color: var(--red); margin-bottom: 4px; }
.danger-item p { font-size: 0.8rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: var(--green-subtle); color: var(--green); border: 1px solid rgba(37,211,102,0.3); }
.badge-red    { background: var(--red-dim);    color: var(--red);   border: 1px solid rgba(255,77,77,0.3); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);  border: 1px solid rgba(74,158,255,0.3); }
.badge-orange { background: var(--orange-dim); color: var(--orange);border: 1px solid rgba(255,140,66,0.3); }
.badge-purple { background: var(--purple-dim); color: var(--purple);border: 1px solid rgba(155,109,255,0.3); }
.badge-gray   { background: var(--bg-elevated);color: var(--text-muted); border: 1px solid var(--border); }

.tag-pill {
  display: inline-flex; align-items: center;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 2px 8px;
  border-radius: 99px; font-size: 0.72rem;
}

/* ═══════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay:not(.hidden) { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.4rem; line-height: 1; transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; 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: 10px;
}

/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 1000;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  box-shadow: var(--shadow-lg); min-width: 280px; max-width: 380px;
  animation: slideInRight 0.25s ease;
  font-size: 0.875rem;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--orange); }
.toast-icon { flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .wa-connect-layout { grid-template-columns: 1fr; }
  .messaging-layout { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    position: fixed; left: -240px; top: 0; bottom: 0;
    width: 240px; z-index: 200;
    transition: left var(--transition);
  }
  .sidebar.mobile-open { left: 0; }
  .mobile-menu-btn { display: flex !important; }
  .topbar-search { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .backup-actions { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .page-header { flex-direction: column; }
  .page-actions { width: 100%; }
}