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

:root {
  --bg-deep: #0a0e1a;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --bg-input: #0d1220;
  --accent: #00e5a0;
  --accent-dim: rgba(0, 229, 160, 0.12);
  --accent-glow: rgba(0, 229, 160, 0.25);
  --text-primary: #f0f4f8;
  --text-secondary: #8892a4;
  --text-muted: #5a6478;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --red: #ff4d6a;
  --red-dim: rgba(255, 77, 106, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ==================== AUTH SCREEN ==================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.auth-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}

.auth-logo span { color: var(--accent); }

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  background: var(--bg-deep);
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--accent);
}

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

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
  width: 100%;
  padding: 12px 24px;
  background: var(--accent);
  color: var(--bg-deep);
  border: none;
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  padding: 10px 20px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 160, 0.2);
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: rgba(0, 229, 160, 0.2); }

.btn-ghost {
  padding: 10px 20px;
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }

.btn-danger {
  padding: 8px 16px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 77, 106, 0.2);
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: rgba(255, 77, 106, 0.2); }

.btn-sm { padding: 8px 16px; font-size: 0.82rem; width: auto; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; width: auto; border-radius: 6px; }

/* ==================== APP LAYOUT ==================== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-left { display: flex; align-items: center; }

.nav-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-logo span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 18px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-link:hover { color: var(--text-secondary); background: rgba(255,255,255,0.03); }
.nav-link.active { color: var(--text-primary); background: rgba(255,255,255,0.06); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-email {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==================== MAIN CONTENT ==================== */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 80px;
  position: relative;
  z-index: 1;
}

.page { animation: fadeIn 0.2s ease; }

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

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-left: -8px;
}

.page-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 36px 0 20px;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 24px 20px;
  text-align: center;
  transition: background 0.2s;
}

.stat-card:first-child { border-radius: 12px 0 0 12px; }
.stat-card:last-child { border-radius: 0 12px 12px 0; }
.stat-card:hover { background: var(--bg-card-hover); }

.stat-card.accent .stat-value { color: var(--accent); }

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== SEARCH BAR ==================== */
.search-bar {
  margin-bottom: 20px;
}

.search-bar input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

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

/* ==================== TABLE ==================== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 2px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.data-table td {
  padding: 14px 16px;
  background: var(--bg-card);
  font-size: 0.9rem;
  vertical-align: middle;
}

.data-table tr td:first-child { border-radius: 8px 0 0 8px; }
.data-table tr td:last-child { border-radius: 0 8px 8px 0; }

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

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.text-accent { color: var(--accent); }

/* ==================== CAMPAIGNS GRID ==================== */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.2s;
}

.campaign-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

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

.campaign-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.campaign-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.campaign-card-stats {
  display: flex;
  gap: 20px;
  font-size: 0.8rem;
}

.campaign-card-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.campaign-card-stat .val {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
}

.campaign-card-stat .lbl {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== STATUS BADGES ==================== */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.draft { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.status-badge.active { background: var(--accent-dim); color: var(--accent); }
.status-badge.paused { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.completed { background: var(--blue-dim); color: var(--blue); }
.status-badge.sent { background: var(--accent-dim); color: var(--accent); }
.status-badge.queued { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.replied { background: var(--blue-dim); color: var(--blue); }
.status-badge.failed, .status-badge.bounced { background: var(--red-dim); color: var(--red); }

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ==================== CAMPAIGN DETAIL ==================== */
.campaign-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin-bottom: 28px;
}

.campaign-stat-card {
  background: var(--bg-card);
  padding: 20px;
  text-align: center;
}

.campaign-stat-card:first-child { border-radius: 10px 0 0 10px; }
.campaign-stat-card:last-child { border-radius: 0 10px 10px 0; }

.campaign-stat-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
}

.campaign-stat-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ==================== EMAIL CARD ==================== */
.email-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  transition: background 0.2s;
}

.email-card:hover { background: var(--bg-card-hover); }

.email-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.email-card-to {
  font-weight: 600;
  font-size: 0.9rem;
}

.email-card-subject {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.email-card-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.email-card-body.expanded { max-height: none; }

.email-card-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.step-badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  font-weight: 600;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

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

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

.modal-body {
  padding: 24px 28px 28px;
}

/* ==================== CHECKBOX LIST ==================== */
.checkbox-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0;
}

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

.checkbox-item:last-child { border-bottom: none; }
.checkbox-item:hover { background: rgba(255,255,255,0.02); }

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-item-info {
  flex: 1;
}

.checkbox-item-name { font-weight: 500; font-size: 0.9rem; }
.checkbox-item-detail { font-size: 0.78rem; color: var(--text-muted); }

/* ==================== LOADING ==================== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ==================== AI SEARCH RESULTS ==================== */
.search-result {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.search-result-info { flex: 1; }
.search-result-name { font-weight: 600; font-size: 0.95rem; }
.search-result-detail { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.search-result-notes { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; font-style: italic; }

/* ==================== PROSPECT ACTIONS ==================== */
.prospect-actions {
  display: flex;
  gap: 4px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .app-nav { padding: 0 16px; }
  .nav-links { display: none; }
  .app-main { padding: 20px 16px 60px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .campaigns-grid { grid-template-columns: 1fr; }
  .campaign-stats-row { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .auth-container { margin: 16px; padding: 32px 24px; }

  /* Mobile nav menu */
  .nav-right { gap: 8px; }
  .user-email { display: none; }
}

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

/* ==================== MISC ==================== */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 0.9rem;
  z-index: 2000;
  animation: slideUp 0.2s ease;
  max-width: 360px;
}

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

/* Mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
}

.mobile-nav-links {
  display: flex;
  justify-content: space-around;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
}

.mobile-nav-link.active { color: var(--accent); }
.mobile-nav-link svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
  .mobile-nav { display: block; }
  .app-main { padding-bottom: 80px; }
}
