/* ============================================
   Pithon Dashboards - Main Stylesheet
   Dark theme with professional medical aesthetic
   ============================================ */

:root {
  --bg-primary: #0b0a14;
  --bg-secondary: #12111e;
  --bg-card: #1a1830;
  --bg-card-hover: #221f3d;
  --border: #2d2952;
  --border-light: #3d3868;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --blue: #7F41F9;
  --blue-light: #9B6DFF;
  --blue-glow: rgba(127, 65, 249, 0.15);
  --green: #10b981;
  --green-light: #34d399;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #7F41F9;
  --cyan: #06b6d4;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

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

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  height: 48px;
}

.topbar-logo img {
  height: 48px;
  width: auto;
}

.topbar-logo span { display: none; }

.topbar-campaign {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 12px;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-light); }

/* ============ CAMPAIGN SELECTOR (index.html) ============ */
.selector-screen {
  max-width: 960px;
  margin: 0 auto;
  padding: 60px 24px;
}

.selector-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

.selector-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 48px;
}

.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.campaign-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--blue);
  opacity: 0;
  transition: opacity 0.25s;
}

.campaign-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.campaign-card:hover::before { opacity: 1; }

.campaign-card-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--blue);
  margin-bottom: 8px;
}

.campaign-card-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.campaign-card-period {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.campaign-card-integrations {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.integration-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(127, 65, 249, 0.1);
  color: var(--blue-light);
  border: 1px solid rgba(127, 65, 249, 0.2);
}

.integration-badge.active { background: rgba(16, 185, 129, 0.1); color: var(--green); border-color: rgba(16, 185, 129, 0.2); }

/* ============ DASHBOARD LAYOUT ============ */
.dashboard {
  padding: 24px 32px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ============ FUNNEL VISUALIZATION ============ */
.funnel-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

.funnel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.funnel-title-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--blue-glow);
  color: var(--blue-light);
}

.funnel-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 8px;
}

.funnel-step {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.funnel-step-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-glow);
  border: 2px solid var(--border);
  margin-bottom: 12px;
  transition: all 0.3s;
}

.funnel-step-icon svg {
  width: 24px;
  height: 24px;
  color: var(--blue-light);
}

.funnel-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.funnel-step-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
}

.funnel-step-value.loading {
  color: var(--text-muted);
  font-size: 16px;
}

.funnel-arrow {
  flex: 0 0 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 16px;
}

.funnel-arrow-line {
  width: 40px;
  height: 2px;
  background: var(--border-light);
  position: relative;
}

.funnel-arrow-line::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  border: 5px solid transparent;
  border-left: 6px solid var(--border-light);
}

.funnel-arrow-rate {
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 4px;
}

.funnel-arrow-rate.good { color: var(--green); background: rgba(16, 185, 129, 0.1); }
.funnel-arrow-rate.medium { color: var(--amber); background: rgba(245, 158, 11, 0.1); }
.funnel-arrow-rate.bad { color: var(--red); background: rgba(239, 68, 68, 0.1); }

/* ============ METRIC CARDS ============ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}

.metric-card:hover { border-color: var(--border-light); }

.metric-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.metric-card-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
}

.metric-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.metric-card-value.currency { color: var(--green); }
.metric-card-value.highlight { color: var(--blue); }

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

.tab-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ CHARTS ============ */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}

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

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

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

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.data-table tr:hover td { background: rgba(127, 65, 249, 0.04); }

/* ============ LOADING / EMPTY ============ */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
  gap: 12px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

/* ============ SENDFLOW GROUPS TABLE ============ */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.group-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.group-card-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.group-card-stat { display: flex; align-items: center; gap: 4px; }
.group-card-stat strong { color: var(--text-primary); font-weight: 700; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .topbar { padding: 12px 16px; }
  .dashboard { padding: 16px; }
  .funnel-container { padding: 20px; }
  .funnel-steps { gap: 0; }
  .funnel-step { min-width: 100px; }
  .funnel-step-value { font-size: 20px; }
  .funnel-arrow { flex: 0 0 30px; }
  .funnel-arrow-line { width: 20px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .selector-screen { padding: 32px 16px; }
}

/* ============================================================
   PREMIUM POLISH - Animations, Transitions, Depth, Glassmorphism
   ============================================================ */

/* ============ KEYFRAME ANIMATIONS ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 15px rgba(127, 65, 249, 0.3), 0 0 0 0 rgba(127, 65, 249, 0.4); }
  50% { box-shadow: 0 4px 25px rgba(127, 65, 249, 0.5), 0 0 0 10px rgba(127, 65, 249, 0); }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(127, 65, 249, 0.3); }
  50% { border-color: rgba(127, 65, 249, 0.6); }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.05); }
  50% { transform: translate(-10px, -40px) scale(0.95); }
  75% { transform: translate(-30px, -10px) scale(1.02); }
}

@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-40px, 20px) scale(0.97); }
  50% { transform: translate(20px, 30px) scale(1.05); }
  75% { transform: translate(30px, -20px) scale(0.98); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes slideGradient {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

/* ============ AMBIENT BACKGROUND - Orbes de luz ============ */
body {
  position: relative;
  overflow-x: hidden;
  background: #0b0a14;
}

body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(127, 65, 249, 0.12) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: orbFloat1 15s ease-in-out infinite;
}

body::after {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(155, 109, 255, 0.08) 0%, transparent 70%);
  bottom: -50px;
  left: -50px;
  animation: orbFloat2 18s ease-in-out infinite;
}

/* Everything above the orbs */
.topbar, .selector-screen, .dashboard, .config-screen {
  position: relative;
  z-index: 1;
}

/* ============ PAGE LOAD ENTRANCE ANIMATIONS ============ */
.topbar {
  animation: fadeInDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.selector-screen {
  animation: fadeIn 0.6s ease-out;
}

.selector-title {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.selector-subtitle {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.campaign-card {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.campaign-card:nth-child(1) { animation-delay: 0.08s; }
.campaign-card:nth-child(2) { animation-delay: 0.16s; }
.campaign-card:nth-child(3) { animation-delay: 0.24s; }
.campaign-card:nth-child(4) { animation-delay: 0.32s; }
.campaign-card:nth-child(5) { animation-delay: 0.40s; }
.campaign-card:nth-child(6) { animation-delay: 0.48s; }

.funnel-container {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.funnel-step {
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.funnel-step:nth-child(1) { animation-delay: 0.15s; }
.funnel-step:nth-child(2) { animation-delay: 0.25s; }
.funnel-step:nth-child(3) { animation-delay: 0.35s; }
.funnel-step:nth-child(4) { animation-delay: 0.45s; }
.funnel-step:nth-child(5) { animation-delay: 0.55s; }
.funnel-step:nth-child(6) { animation-delay: 0.65s; }
.funnel-step:nth-child(7) { animation-delay: 0.75s; }

.funnel-arrow {
  animation: fadeIn 0.4s ease-out both;
}

.funnel-arrow:nth-child(2) { animation-delay: 0.2s; }
.funnel-arrow:nth-child(4) { animation-delay: 0.3s; }
.funnel-arrow:nth-child(6) { animation-delay: 0.4s; }
.funnel-arrow:nth-child(8) { animation-delay: 0.5s; }
.funnel-arrow:nth-child(10) { animation-delay: 0.6s; }

.metrics-grid {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.metric-card {
  animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.metric-card:nth-child(1) { animation-delay: 0.1s; }
.metric-card:nth-child(2) { animation-delay: 0.17s; }
.metric-card:nth-child(3) { animation-delay: 0.24s; }
.metric-card:nth-child(4) { animation-delay: 0.31s; }
.metric-card:nth-child(5) { animation-delay: 0.38s; }
.metric-card:nth-child(6) { animation-delay: 0.45s; }
.metric-card:nth-child(7) { animation-delay: 0.52s; }
.metric-card:nth-child(8) { animation-delay: 0.59s; }

.tabs-container {
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.chart-container {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

.config-section {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.config-section:nth-child(1) { animation-delay: 0.05s; }
.config-section:nth-child(2) { animation-delay: 0.12s; }
.config-section:nth-child(3) { animation-delay: 0.19s; }
.config-section:nth-child(4) { animation-delay: 0.26s; }
.config-section:nth-child(5) { animation-delay: 0.33s; }
.config-section:nth-child(6) { animation-delay: 0.40s; }

/* ============ TOPBAR - Glassmorphism forte ============ */
.topbar {
  background: rgba(18, 17, 30, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(127, 65, 249, 0.15);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

/* ============ BUTTONS - Glow pulsante no primary ============ */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.btn:hover::before {
  transform: translateX(100%);
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
  transition-duration: 0.1s;
}

.btn-primary {
  background: linear-gradient(135deg, #7F41F9, #9B6DFF);
  border: none;
  box-shadow: 0 4px 20px rgba(127, 65, 249, 0.4);
  animation: pulseGlow 3s ease-in-out infinite;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #9B6DFF, #b794ff);
  box-shadow: 0 8px 30px rgba(127, 65, 249, 0.5);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 10px rgba(127, 65, 249, 0.3);
  animation: none;
}

/* ============ CAMPAIGN CARDS - Gradient border animado ============ */
.campaign-card {
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  background-image: linear-gradient(var(--bg-card), var(--bg-card)),
                     linear-gradient(135deg, var(--border), var(--border));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.campaign-card:hover {
  background-image: linear-gradient(var(--bg-card), var(--bg-card)),
                     linear-gradient(135deg, #7F41F9, #9B6DFF, #7F41F9);
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35),
              0 0 40px rgba(127, 65, 249, 0.15);
}

.campaign-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #7F41F9, #9B6DFF, #7F41F9);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.35s;
  animation: slideGradient 3s linear infinite;
}

.campaign-card:hover::before { opacity: 1; }

.campaign-card:active {
  transform: translateY(-2px);
  transition-duration: 0.1s;
}

/* ============ METRIC CARDS - Glow border + hover accent ============ */
.metric-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(26, 24, 48, 1) 0%, var(--bg-card) 100%);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), var(--blue-light), var(--blue), transparent);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s;
  animation: slideGradient 2s linear infinite;
}

.metric-card:hover {
  border-color: rgba(127, 65, 249, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25),
              0 0 30px rgba(127, 65, 249, 0.08);
}

.metric-card:hover::before { opacity: 1; }

.metric-card:hover .metric-card-value { color: var(--text-primary); }
.metric-card:hover .metric-card-value.currency { color: var(--green-light); }
.metric-card:hover .metric-card-value.highlight { color: var(--blue-light); }

/* ============ FUNNEL - Glow icons + animated connector ============ */
.funnel-step-icon {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, rgba(127, 65, 249, 0.2), rgba(127, 65, 249, 0.05));
  border: 1.5px solid rgba(127, 65, 249, 0.35);
  box-shadow: 0 4px 20px rgba(127, 65, 249, 0.15);
}

.funnel-step:hover .funnel-step-icon {
  border-color: var(--blue-light);
  box-shadow: 0 0 30px rgba(127, 65, 249, 0.4), 0 0 60px rgba(127, 65, 249, 0.15);
  transform: scale(1.1);
  background: linear-gradient(135deg, rgba(127, 65, 249, 0.3), rgba(127, 65, 249, 0.1));
}

.funnel-container {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(26, 24, 48, 0.8) 100%);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.funnel-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(127, 65, 249, 0.4), transparent);
}

.funnel-container::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(127, 65, 249, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* ============ TABS - Underline slide + glow ============ */
.tab-btn {
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(127, 65, 249, 0);
}

.tab-btn:hover::after,
.tab-btn.active::after {
  width: 100%;
  box-shadow: 0 0 12px rgba(127, 65, 249, 0.4);
}

.tab-btn:hover { color: var(--text-primary); }

/* Tab panel transition */
.tab-panel.active {
  display: block;
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============ CHART CONTAINERS - Depth + glow ============ */
.chart-container {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(26, 24, 48, 0.9) 100%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s, border-color 0.3s;
}

.chart-container:hover {
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.25);
  border-color: rgba(127, 65, 249, 0.25);
}

.chart-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(127, 65, 249, 0.25), transparent);
}

/* ============ GROUP CARDS ============ */
.group-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.group-card:hover {
  border-color: rgba(127, 65, 249, 0.3);
  background: var(--bg-card);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ============ TABLE ROWS ============ */
.data-table tr { transition: background 0.2s ease; }
.data-table tr:hover td { background: rgba(127, 65, 249, 0.06); }
.data-table tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--blue); }

/* ============ INTEGRATION BADGES ============ */
.integration-badge {
  transition: all 0.25s ease;
}

.integration-badge:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ============ CONFIG PAGE ============ */
.selector-item {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.selector-item:hover {
  background: rgba(127, 65, 249, 0.08);
  padding-left: 20px;
}

.selector-item.selected {
  background: rgba(127, 65, 249, 0.12);
  border-left: 3px solid var(--blue);
}

.selected-tag {
  transition: all 0.25s ease;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.selected-tag:hover {
  background: rgba(127, 65, 249, 0.25);
  transform: scale(1.06) translateY(-1px);
}

.config-section {
  background: linear-gradient(135deg, rgba(26, 24, 48, 0.95), rgba(18, 17, 30, 0.95));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(45, 41, 82, 0.6);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.config-section:hover {
  border-color: rgba(127, 65, 249, 0.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* ============ FOCUS STATES ============ */
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--blue);
}

.btn-save:focus-visible,
.btn-load:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--blue);
}

.tab-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--blue);
  border-radius: 4px;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(127, 65, 249, 0.2), 0 0 20px rgba(127, 65, 249, 0.08);
  outline: none;
}

.campaign-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--blue);
}

/* ============ SKELETON LOADERS ============ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long { width: 90%; }
.skeleton-value { height: 32px; width: 80px; border-radius: 6px; }
.skeleton-circle { width: 56px; height: 56px; border-radius: 16px; }

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.skeleton-card .skeleton-text,
.skeleton-card .skeleton-value {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card-hover) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-chart { height: 300px; border-radius: var(--radius); }

.funnel-step-value.loading { color: transparent; position: relative; }

.funnel-step-value.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

/* ============ SELECTOR TITLE - Gradient text ============ */
.selector-title {
  background: linear-gradient(135deg, #ffffff 0%, #9B6DFF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============ BADGES ============ */
.funnel-title-badge { box-shadow: 0 0 15px rgba(127, 65, 249, 0.25); }
.funnel-arrow-rate.good { box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
.funnel-arrow-rate.bad { box-shadow: 0 0 10px rgba(239, 68, 68, 0.2); }
.integration-badge.active { box-shadow: 0 0 10px rgba(16, 185, 129, 0.15); }

/* ============ VALUE ANIMATIONS ============ */
.metric-card-value.updated,
.funnel-step-value.updated {
  animation: countUp 0.4s ease-out;
}

.funnel-step-value { transition: color 0.3s, transform 0.3s; }

/* ============ LOADING STATES ============ */
.btn.refreshing svg { animation: spin 0.8s linear infinite; }
.btn.refreshing { pointer-events: none; opacity: 0.7; }

.spinner {
  border-color: rgba(127, 65, 249, 0.2);
  border-top-color: var(--blue);
}

/* ============ TOAST ============ */
.toast {
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* ============ SAVE BUTTON ============ */
.btn-save {
  box-shadow: 0 4px 20px rgba(127, 65, 249, 0.35);
  background: linear-gradient(135deg, #7F41F9, #9B6DFF);
  transition: all 0.3s;
}

.btn-save:hover {
  box-shadow: 0 8px 30px rgba(127, 65, 249, 0.45);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #9B6DFF, #b794ff);
}

.btn-save:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(127, 65, 249, 0.3);
}

/* ============ EMPTY STATE ============ */
#empty-state {
  display: flex;
  justify-content: center;
  margin-top: 60px;
  animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.empty-state-card {
  display: flex;
  align-items: center;
  gap: 32px;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(26, 24, 48, 0.8) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  max-width: 600px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.empty-state-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(127, 65, 249, 0.4), transparent);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  min-width: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(127, 65, 249, 0.2), rgba(127, 65, 249, 0.05));
  border: 1px solid rgba(127, 65, 249, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite, borderGlow 4s ease-in-out infinite;
  box-shadow: 0 8px 30px rgba(127, 65, 249, 0.15);
}

.empty-state-icon svg {
  width: 34px;
  height: 34px;
  color: var(--blue-light);
}

.empty-state-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.empty-state-btn {
  display: inline-flex;
  text-decoration: none;
  font-size: 14px;
  padding: 10px 22px;
  width: fit-content;
}

@media (max-width: 768px) {
  .empty-state-card {
    flex-direction: column;
    text-align: center;
    padding: 32px 24px;
    gap: 20px;
  }
  .empty-state-content { align-items: center; }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  body::before, body::after { display: none; }

  .metric-card:hover,
  .group-card:hover,
  .funnel-step:hover .funnel-step-icon {
    transform: none;
  }

  .campaign-card:hover {
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
