/* ==========================================================================
   LEADSCOPE - DESIGN SYSTEM & PREMIUM MODERN STYLES
   Dark modern theme with vibrant accents, glassmorphism, and fluid animations
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111726;
  --bg-tertiary: #182238;
  --bg-card: rgba(17, 24, 39, 0.82);
  --bg-card-hover: rgba(24, 34, 56, 0.95);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(59, 130, 246, 0.35);

  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Brand Accents */
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
  
  /* Status Colors */
  --color-emerald: #10b981;
  --color-emerald-bg: rgba(16, 185, 129, 0.12);
  --color-emerald-border: rgba(16, 185, 129, 0.3);
  
  --color-amber: #f59e0b;
  --color-amber-bg: rgba(245, 158, 11, 0.12);
  --color-amber-border: rgba(245, 158, 11, 0.3);
  
  --color-purple: #a855f7;
  --color-purple-bg: rgba(168, 85, 247, 0.12);
  --color-purple-border: rgba(168, 85, 247, 0.3);

  --color-rose: #f43f5e;
  --color-rose-bg: rgba(244, 63, 94, 0.12);

  --color-whatsapp: #25d366;
  --color-whatsapp-hover: #1ebd5a;
  --color-whatsapp-glow: rgba(37, 211, 102, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.25);
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(59, 130, 246, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(99, 102, 241, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header-container,
.app-main,
.footer-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 0;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
  flex-shrink: 0;
  overflow: hidden;
  transition: var(--transition-smooth);
}
.brand-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.badge-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: #f1f5f9;
  border-color: var(--border-medium);
}
.btn-secondary:hover {
  background: #202d4a;
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-medium);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.btn-whatsapp-action {
  background: #128c7e;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--color-whatsapp-glow);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn-whatsapp-action:hover {
  background: linear-gradient(135deg, #2ae06e 0%, #169b8c 100%);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.5);
  transform: translateY(-1px);
  color: #fff;
}

.btn-web-action {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.btn-web-action:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  color: #93c5fd;
  transform: translateY(-1px);
}

.btn-web-disabled {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-text {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.btn-text:hover {
  color: #93c5fd;
}

/* ==========================================================================
   DROP ZONE
   ========================================================================== */
.drop-zone-card {
  margin: 24px 0 16px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.45);
  padding: 36px 24px;
  text-align: center;
  transition: var(--transition-smooth);
}
.drop-zone-card.drag-over {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}
.drop-zone-content {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.drop-icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.drop-zone-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}
.drop-zone-card p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 20px;
}
.drop-zone-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================================================
   STATS CARDS (KPIS)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin: 24px 0 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.stat-card.stat-highlight {
  border-color: var(--color-emerald-border);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(17, 24, 39, 0.9) 100%);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.icon-emerald { background: var(--color-emerald-bg); color: var(--color-emerald); }
.icon-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.icon-whatsapp { background: rgba(37, 211, 102, 0.15); color: #25d366; }
.icon-purple { background: var(--color-purple-bg); color: var(--color-purple); }

.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
  margin: 2px 0;
}
.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.text-emerald { color: var(--color-emerald); }
.text-amber { color: var(--color-amber); }
.text-purple { color: var(--color-purple); }

/* ==========================================================================
   TOOLBAR & FILTERS
   ========================================================================== */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}
.search-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  color: #fff;
}
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  width: 100%;
}
.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-pills {
  display: flex;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}
.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.pill-btn:hover {
  color: #fff;
}
.pill-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}
.pill-btn[data-filter="with-web"].active {
  background: #059669;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}
.pill-btn[data-filter="no-web"].active {
  background: #d97706;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.view-toggle {
  display: flex;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}
.view-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}
.view-btn:hover { color: #fff; }
.view-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toolbar-bottom {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-item label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}
.filter-item select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 7px 12px;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
}
.filter-item select:focus {
  border-color: var(--accent-primary);
}
.filter-item select option {
  background: var(--bg-secondary);
  color: #fff;
}
.ml-auto {
  margin-left: auto;
}

/* Results header */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.results-count strong {
  color: #fff;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  margin-left: 8px;
}

/* ==========================================================================
   LEAD CARDS GRID (PRIMARY VIEW)
   ========================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  backdrop-filter: blur(12px);
  position: relative;
}
.lead-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

/* Visual banner/accent for cards WITH WEBSITE (requested by user to highlight) */
.lead-card.card-has-website {
  border-left: 4px solid var(--color-emerald);
}
.lead-card.card-no-website {
  border-left: 4px solid var(--color-amber);
}

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

.card-title-group {
  flex: 1;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 6px;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.badge-web-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge-web-status.has-site {
  background: var(--color-emerald-bg);
  color: #34d399;
  border: 1px solid var(--color-emerald-border);
}
.badge-web-status.no-site {
  background: var(--color-amber-bg);
  color: #fbbf24;
  border: 1px solid var(--color-amber-border);
}

.badge-category {
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Claimed / Verified badge */
.badge-claimed {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.badge-claimed.claimed {
  background: rgba(16, 185, 129, 0.08);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-claimed.not-claimed {
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.25);
  /* subtle pulse to attract attention — this is a prospecting opportunity */
  animation: claimedPulse 3s ease-in-out infinite;
}

@keyframes claimedPulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 8px rgba(245, 158, 11, 0.35); }
}

/* Lead pipeline status selector */
.lead-status-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}
.lead-status-select:focus {
  border-color: var(--accent-primary);
}
.lead-status-select.status-novo { color: #94a3b8; }
.lead-status-select.status-contatado { color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
.lead-status-select.status-em-negociacao { color: #c084fc; border-color: rgba(192, 132, 252, 0.4); }
.lead-status-select.status-fechado { color: #34d399; border-color: rgba(52, 211, 153, 0.4); }
.lead-status-select.status-sem-resposta { color: #f87171; border-color: rgba(248, 113, 113, 0.4); }

/* Rating & stats strip */
.card-stats-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.84rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.rating-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: #fbbf24;
}
.reviews-count {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.city-badge {
  margin-left: auto;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Card details list */
.card-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-break: break-word;
}
.detail-icon {
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--text-muted);
}
.detail-text {
  flex: 1;
  line-height: 1.4;
}
.detail-phone {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #e2e8f0;
}

/* Primary actions buttons */
.card-actions-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.card-actions-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-fast);
}
.link-muted:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* ==========================================================================
   TABLE VIEW
   ========================================================================== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 40px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.leads-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-medium);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.leads-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.leads-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-company-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.table-company-title {
  font-weight: 700;
  color: #fff;
  font-size: 0.92rem;
}
.table-company-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   MODAL WINDOW
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-icon.whatsapp-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-whatsapp-glow);
  color: #25d366;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}
.modal-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}
.modal-close-btn:hover { color: #fff; }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
}

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

.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.chip-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}
.chip-btn.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  color: #93c5fd;
}

.form-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.variables-help {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.var-tag {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: var(--transition-fast);
}
.var-tag:hover {
  background: rgba(59, 130, 246, 0.3);
  color: #fff;
}

.preview-box {
  background: #0d121d;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}
.preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.preview-bubble {
  background: #054740;
  color: #e9edef;
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 10px;
  border-top-left-radius: 2px;
  white-space: pre-wrap;
  line-height: 1.45;
  border-left: 3px solid #25d366;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast-card {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 2000;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
#toastIcon {
  color: var(--color-emerald);
  font-size: 1.1rem;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-card {
  background: var(--bg-card);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  max-width: 500px;
  margin: 40px auto;
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.empty-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #fff;
}
.empty-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 20px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}
.footer-links a:hover {
  color: #fff;
}

/* ==========================================================================
   ANIMATIONS & RESPONSIVE
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

/* ==========================================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .toolbar-top {
    flex-wrap: wrap;
  }

  .header-actions {
    gap: 8px;
  }

  /* Hide less important header buttons on tablet */
  #btnExportCsv {
    display: none;
  }
}

/* ==========================================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ========================================================================== */
@media (max-width: 768px) {

  /* ---- LAYOUT ---- */
  .header-container,
  .app-main,
  .footer-container {
    padding: 0 16px;
  }

  /* ---- HEADER ---- */
  .app-header {
    padding: 12px 0;
  }

  .header-container {
    flex-direction: row;           /* keep logo + actions on one line */
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .brand-subtitle {
    display: none;                 /* hide tagline on mobile */
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .badge-tag {
    display: none;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

  /* Show only WhatsApp config + Upload on header, hide the rest */
  .header-actions {
    gap: 6px;
  }

  #btnLoadSample,
  #btnExportCsv {
    display: none;
  }

  .btn {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  /* ---- DROP ZONE ---- */
  .drop-zone-card {
    padding: 24px 16px;
    margin: 16px 0 12px;
  }

  .drop-zone-card h3 {
    font-size: 1.05rem;
  }

  .drop-zone-actions {
    flex-direction: column;
    width: 100%;
  }

  .drop-zone-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ---- KPI STATS ---- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0 14px;
  }

  .stat-card {
    padding: 14px 14px;
    gap: 12px;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  /* Hide 5th stat card (avg rating) on small screens to keep 2x2 grid clean */
  #statCardRating {
    display: none;
  }

  /* ---- TOOLBAR / FILTERS ---- */
  .toolbar-card {
    padding: 14px 14px;
    gap: 12px;
  }

  .toolbar-top {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-box {
    min-width: unset;
    width: 100%;
  }

  .filter-pills {
    width: 100%;
    justify-content: stretch;
  }

  .pill-btn {
    flex: 1;
    text-align: center;
    padding: 7px 6px;
    font-size: 0.76rem;
  }

  .view-toggle {
    align-self: flex-end;
  }

  .toolbar-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
  }

  .filter-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .filter-item select {
    width: 100%;
    padding: 9px 12px;
  }

  .ml-auto {
    margin-left: 0;
  }

  /* ---- RESULTS HEADER ---- */
  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 0.82rem;
  }

  /* ---- CARDS GRID ---- */
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 100px;        /* room for mobile bottom bar */
  }

  .lead-card {
    padding: 16px;
    border-radius: var(--radius-md);
    gap: 12px;
  }

  .card-title {
    font-size: 1.05rem;
  }

  /* Make status select smaller on mobile */
  .lead-status-select {
    font-size: 0.7rem;
    padding: 3px 6px;
    max-width: 110px;
  }

  .card-stats-strip {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .card-details {
    font-size: 0.82rem;
    gap: 6px;
  }

  /* Buttons always full-width stacked on mobile */
  .card-actions-primary {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .card-actions-primary .btn {
    width: 100%;
    justify-content: center;
    padding: 11px 16px;
    font-size: 0.9rem;
  }

  .card-actions-secondary {
    font-size: 0.76rem;
  }

  /* ---- TABLE VIEW ---- */
  .table-card {
    margin-bottom: 100px;
  }

  /* On mobile hide less critical columns from table */
  .leads-table th:nth-child(4),
  .leads-table td:nth-child(4),
  .leads-table th:nth-child(6),
  .leads-table td:nth-child(6) {
    display: none;
  }

  /* ---- MODAL ---- */
  .modal-backdrop {
    align-items: flex-end;        /* slide up from bottom on mobile */
    padding: 0;
  }

  .modal-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-body {
    max-height: 60vh;
  }

  .template-chips {
    gap: 6px;
  }

  .chip-btn {
    font-size: 0.74rem;
    padding: 5px 10px;
  }

  /* ---- TOAST ---- */
  .toast-card {
    left: 16px;
    right: 16px;
    bottom: 80px;                /* above mobile nav bar */
    width: auto;
  }

  /* ---- FOOTER ---- */
  .app-footer {
    display: none;               /* footer takes too much space on mobile */
  }
}

/* ==========================================================================
   RESPONSIVE — SMALL MOBILE (≤ 400px)
   ========================================================================== */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 12px 10px;
    gap: 8px;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .brand-title {
    font-size: 1rem;
  }

  .card-badges {
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* ==========================================================================
   MOBILE BOTTOM ACTION BAR (shows only on mobile)
   Quick access: Upload CSV, Filtros rápidos
   ========================================================================== */
.mobile-bottom-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10, 14, 23, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-medium);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
    align-items: center;
    justify-content: space-around;
  }

  .mobile-bar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    min-width: 56px;
    text-align: center;
    text-decoration: none;
  }

  .mobile-bar-btn:hover,
  .mobile-bar-btn.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-bar-btn.primary-action {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
    padding: 8px 16px;
    border-radius: var(--radius-full);
  }

  .mobile-bar-btn svg {
    flex-shrink: 0;
  }

  /* pill filter tabs — scrollable on small screens */
  .filter-pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
}

/* Slide-up animation for mobile modal */
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(60px); }
  to   { opacity: 1; transform: translateY(0); }
}
