:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --muted: #6b6b8a;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --sidebar-w: 220px;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a1040 0%, var(--bg) 70%);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 420px;
  box-shadow: 0 0 80px #6366f120;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo .dot {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.login-logo span { font-size: 11px; color: var(--muted); display: block; }
.login-card h2 { font-size: 18px; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s;
}
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; width: 100%; justify-content: center; }
.btn-primary:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.error-msg { color: var(--red); font-size: 12px; margin-top: 8px; display: none; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 7px;
  flex-shrink: 0;
}
.sidebar-logo .text h2 { font-size: 14px; font-weight: 700; }
.sidebar-logo .text span { font-size: 10px; color: var(--muted); }

nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; padding: 12px 8px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  user-select: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: #6366f118; color: var(--accent); }
.nav-item .icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.env-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.env-badge.prod { background: #10b98120; color: var(--green); }
.env-badge.stage { background: #f59e0b20; color: var(--yellow); }
.env-badge.dev { background: #3b82f620; color: var(--blue); }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-left h1 { font-size: 18px; font-weight: 700; }
.topbar-left p { font-size: 12px; color: var(--muted); }
.topbar-controls { display: flex; align-items: center; gap: 8px; }

select, input[type="date"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
select:focus, input[type="date"]:focus { outline: none; border-color: var(--accent); }

.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: #3a3a5a; }
.card-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 8px; }
.card-value { font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1; margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-value.green { color: var(--green); }
.card-value.red { color: var(--red); }
.card-value.accent { color: var(--accent); }
.card-value.yellow { color: var(--yellow); }
.card-value.disabled { color: var(--muted); font-size: 18px; }

/* ── Section ── */
.section { margin-bottom: 32px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 15px; font-weight: 600; }
.section-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Table ── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
th { padding: 10px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
td { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; }
tr:hover td { background: #ffffff04; }

/* ── Funnel ── */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-step {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.funnel-bar-wrap { flex: 1; background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width 0.5s ease; }
.funnel-label { width: 220px; font-size: 12px; color: var(--muted); }
.funnel-count { width: 60px; text-align: right; font-size: 14px; font-weight: 600; }

/* ── Service status ── */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.service-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.service-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.service-name { font-size: 14px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.warn { background: var(--yellow); }
.status-dot.err { background: var(--red); }
.service-metrics { display: flex; flex-direction: column; gap: 6px; }
.metric-row { display: flex; justify-content: space-between; font-size: 12px; }
.metric-row span:first-child { color: var(--muted); }
.metric-row span:last-child { font-weight: 500; }

/* ── Revenue disabled ── */
.disabled-banner {
  background: linear-gradient(135deg, #1a1030, #0f1520);
  border: 1px solid #6366f130;
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin-bottom: 24px;
}
.disabled-banner .icon { font-size: 48px; margin-bottom: 16px; }
.disabled-banner h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.disabled-banner p { color: var(--muted); max-width: 480px; margin: 0 auto; line-height: 1.6; }
.schema-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  background: #10b98115;
  border: 1px solid #10b98130;
  border-radius: 20px;
  font-size: 12px;
  color: var(--green);
  margin-top: 16px;
  font-weight: 500;
}

/* ── Loading / empty ── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
  gap: 10px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 48px; color: var(--muted); }
.empty .icon { font-size: 36px; margin-bottom: 12px; }

/* ── Env comparison ── */
.env-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.env-col {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.env-col-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.env-col-body { padding: 16px; }
.env-stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.env-stat:last-child { border-bottom: none; }
.env-stat span:first-child { color: var(--muted); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; transform: translateY(10px);
  transition: all 0.2s;
  z-index: 999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* ── Tag ── */
.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.tag.green { background: #10b98120; color: var(--green); }
.tag.red { background: #ef444420; color: var(--red); }
.tag.yellow { background: #f59e0b20; color: var(--yellow); }
.tag.blue { background: #3b82f620; color: var(--blue); }
.tag.purple { background: #6366f120; color: var(--accent); }

/* ── Refresh indicator ── */
.last-updated { font-size: 11px; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .env-grid { grid-template-columns: 1fr; }
}
