:root {
  --bg:       #080b10;
  --surface:  #0f1318;
  --surface2: #161b23;
  --border:   rgba(255,255,255,.07);
  --text:     #e2e8f0;
  --muted:    #64748b;
  --accent:   #22d97a;
  --accent2:  #3b82f6;
  --red:      #f43f5e;
  --yellow:   #f59e0b;
  --radius:   12px;
  --sidebar:  220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; font-size: 14px; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(34,217,122,.08) 0%, transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; }
.logo-icon { font-size: 28px; line-height: 1; }
.logo-name { font-size: 18px; font-weight: 700; }
.logo-sub  { font-size: 11px; color: var(--muted); }
.alert-error {
  background: rgba(244,63,94,.12); border: 1px solid rgba(244,63,94,.3);
  color: var(--red); border-radius: 8px; padding: 10px 14px; margin-bottom: 1rem; font-size: 13px;
}
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
  transition: border-color .2s;
}
.field input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: 11px;
  background: var(--accent); color: #000; font-weight: 700; font-size: 14px;
  border: none; border-radius: 8px; cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }

/* ── Layout ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 0;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 20px; border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 700;
}
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(34,217,122,.08); color: var(--accent);
}
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-user { font-size: 11px; color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.btn-logout {
  display: block; text-align: center; padding: 7px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 12px;
  transition: color .15s;
}
.btn-logout:hover { color: var(--red); }

/* ── Main ── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title  { font-size: 18px; font-weight: 700; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(34,217,122,.5);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,217,122,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(34,217,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,217,122,0); }
}
.topbar-right { display: flex; gap: 10px; }
.select-sm {
  padding: 6px 10px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 13px; outline: none; cursor: pointer;
}

/* ── Sections ── */
.section { display: none; padding: 24px 28px; flex-direction: column; gap: 20px; }
.section.active { display: flex; }

/* ── Metrics ── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.metric-card.green { border-color: rgba(34,217,122,.25); background: rgba(34,217,122,.04); }
.metric-card.red   { border-color: rgba(244,63,94,.25);  background: rgba(244,63,94,.04); }
.metric-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 700; }
.metric-card.green .metric-value { color: var(--accent); }
.metric-card.red   .metric-value { color: var(--red); }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.badge-live {
  font-size: 9px; font-weight: 700; letter-spacing: .08em;
  background: var(--accent); color: #000; padding: 2px 6px; border-radius: 4px;
}
.chart-wrap { padding: 20px; }

/* ── Live Feed ── */
.live-feed { padding: 12px 0; max-height: 320px; overflow-y: auto; }
.feed-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; border-bottom: 1px solid var(--border); font-size: 12px;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.feed-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  white-space: nowrap;
}
.feed-badge.complete  { background: rgba(34,217,122,.15); color: var(--accent); }
.feed-badge.abandon   { background: rgba(244,63,94,.15);  color: var(--red); }
.feed-badge.pageview  { background: rgba(59,130,246,.15); color: var(--accent2); }
.feed-badge.start     { background: rgba(245,158,11,.15); color: var(--yellow); }
.feed-url  { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { color: var(--muted); white-space: nowrap; }

/* ── Funil ── */
.funnel-wrap { padding: 24px 28px; display: flex; flex-direction: column; gap: 10px; }
.funnel-row  { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 140px; font-size: 12px; color: var(--muted); text-align: right; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: var(--surface2); border-radius: 4px; height: 28px; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 4px; display: flex; align-items: center; padding: 0 10px; transition: width .6s ease; }
.funnel-count { font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; }
.funnel-pct   { width: 60px; font-size: 12px; color: var(--muted); text-align: right; flex-shrink: 0; }

/* ── Abandon steps ── */
.abandon-wrap { padding: 20px 28px; display: flex; flex-direction: column; gap: 10px; }

/* ── Tables ── */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); }
td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.tag-ok  { background: rgba(34,217,122,.12); color: var(--accent); }
.tag-err { background: rgba(244,63,94,.12);  color: var(--red); }
.tag-neu { background: rgba(255,255,255,.07); color: var(--muted); }

/* ── Install ── */
.install-desc { padding: 14px 20px 0; color: var(--muted); font-size: 13px; }
.install-desc code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.code-block {
  position: relative; margin: 12px 20px 20px;
  background: #0a0e14; border: 1px solid var(--border); border-radius: 8px;
}
.code-block pre { padding: 16px; overflow-x: auto; font-size: 12px; line-height: 1.6; color: #a5f3cb; white-space: pre-wrap; word-break: break-all; }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 11px; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; transition: color .15s;
}
.copy-btn:hover { color: var(--accent); }
