:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 { font-size: 20px; font-weight: 600; }
h1 .subtle { color: var(--text-muted); font-weight: 400; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

.header-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }

#refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#refresh-btn:hover { background: var(--accent-light); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.cards.small { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}
.card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.card-value { font-size: 28px; font-weight: 700; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

/* Funnel */
.funnel-summary { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
.funnel { display: flex; flex-direction: column; gap: 8px; }

.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.funnel-label { width: 200px; font-size: 13px; color: var(--text-muted); text-align: right; }
.funnel-bar-wrap { flex: 1; background: var(--bg); border-radius: 4px; height: 28px; position: relative; }
.funnel-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  min-width: 2px;
  transition: width 0.3s ease;
}
.funnel-count { width: 60px; font-size: 13px; font-weight: 600; }

.conversions { margin-top: 16px; display: flex; gap: 24px; flex-wrap: wrap; }
.conversion-item { font-size: 13px; color: var(--text-muted); }
.conversion-item strong { color: var(--text); }

/* Badge */
.badge {
  background: var(--accent);
  color: white;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  margin-left: 8px;
}

/* Filters */
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-btn {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Table */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: rgba(99, 102, 241, 0.05); }

.stage-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.stage-registered { background: #1e293b; color: #94a3b8; }
.stage-verified { background: #1e3a5f; color: #60a5fa; }
.stage-active_free { background: #14532d; color: #4ade80; }
.stage-intel_paid { background: #3b0764; color: #c084fc; }
.stage-professional_paid { background: #4c1d95; color: #a78bfa; }
.stage-churned { background: #451a03; color: #fb923c; }
.stage-suspended { background: #450a0a; color: #fca5a5; }

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

/* Error */
.error-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.error-banner button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards.small { grid-template-columns: repeat(2, 1fr); }
  .funnel-label { width: 120px; font-size: 11px; }
}
