:root {
  --bg: #0b1120;
  --panel: #131c31;
  --panel-2: #1b2741;
  --line: #243149;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #15233f 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Top bar / nav ---- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px; height: 56px;
  background: rgba(11, 17, 32, .8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.mainnav a.active { color: var(--text); background: var(--panel-2); }
.logout button {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.logout button:hover { color: var(--text); border-color: var(--muted); }

/* ---- Layout ---- */
.content { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.content-centered { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #101829 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- Login ---- */
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; width: 340px; max-width: 100%; text-align: center;
}
.login-card h1 { margin-bottom: 2px; }
.login-card form { display: grid; gap: 14px; margin-top: 20px; text-align: left; }
.login-card label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font: inherit; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
button.primary, .login-card button {
  background: var(--accent); color: #04121f; border: none; border-radius: 8px;
  padding: 10px; font-weight: 700; cursor: pointer;
}
button { font: inherit; }
.alert.error { background: rgba(248,113,113,.12); border: 1px solid var(--bad); color: #fecaca; padding: 9px 12px; border-radius: 8px; font-size: 13px; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: block; color: var(--text);
}
.kpi:hover { text-decoration: none; }
a.kpi:hover { border-color: var(--muted); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi-sub { color: var(--muted); font-size: 11px; }
.kpi.warn { border-color: var(--bad); }
.kpi.warn .kpi-value { color: var(--bad); }
.kpi.accent { border-color: var(--accent); }
.kpi.accent .kpi-value { color: var(--accent); }

/* ---- Segmented control ---- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: none; padding: 6px 12px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #04121f; font-weight: 700; }

/* ---- Chart ---- */
.chart-wrap { position: relative; height: 300px; margin-top: 8px; }

/* ---- Tables ---- */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.grid tr:hover td { background: rgba(255,255,255,.02); }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Filters ---- */
.filters { display: flex; gap: 14px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filters label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.filters select { width: auto; min-width: 130px; }
.filters button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 9px 16px; border-radius: 8px; cursor: pointer; }

/* ---- Retention heatmap ---- */
table.retention td.num { color: var(--muted); }
table.retention td.empty { background: transparent; }
table.retention td.heat { text-align: center; font-size: 12px; color: #03121d; font-weight: 600; border-radius: 4px; }
.heat-0 { background: #1e3a5f; color: #9fb6d0; } .heat-1 { background: #1f4e79; color: #cfe0f0; }
.heat-2 { background: #1d6296; } .heat-3 { background: #1a78b3; } .heat-4 { background: #1894c9; }
.heat-5 { background: #25abd6; } .heat-6 { background: #38bdf8; } .heat-7 { background: #5fcef9; }
.heat-8 { background: #8adcfb; } .heat-9 { background: #bdeefd; }

/* ---- Funnel ---- */
.funnel-row { margin-bottom: 14px; }
.funnel-meta { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 13px; gap: 10px; }
.funnel-name { font-weight: 600; }
.funnel-nums { color: var(--muted); }
.funnel-bar { position: relative; height: 22px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.funnel-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 6px; }
.funnel-fill.entered { background: var(--accent-2); opacity: .35; }
.funnel-fill.completed { background: var(--accent); }
.funnel-total { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; font-size: 15px; }
.badge { background: var(--panel-2); color: var(--muted); border-radius: 5px; padding: 1px 6px; font-size: 11px; }

/* ---- Horizontal bars (progression) ---- */
.hbar-row { display: grid; grid-template-columns: 130px 1fr 56px; gap: 10px; align-items: center; margin-bottom: 8px; }
.hbar-label { font-size: 13px; color: var(--muted); }
.hbar { background: var(--bg); border-radius: 6px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.hbar-fill.ok { background: var(--ok); } .hbar-fill.warn { background: var(--warn); } .hbar-fill.bad { background: var(--bad); }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---- Error detail ---- */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 2px 0 0; }
pre.stack {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; overflow: auto; font-size: 12px; line-height: 1.5; max-height: 420px; white-space: pre-wrap; word-break: break-word;
}

/* ---- Feedback ---- */
.fb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.fb-msg { white-space: pre-wrap; word-break: break-word; margin-bottom: 12px; }
.fb-actions { display: flex; gap: 8px; align-items: center; }
.fb-actions select { width: auto; }
.fb-actions input { flex: 1; }
.fb-actions button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.cat-bug { background: rgba(248,113,113,.18); color: #fca5a5; }
.cat-suggestion { background: rgba(167,139,250,.18); color: #c4b5fd; }
.cat-other { background: rgba(139,155,180,.18); color: #cbd5e1; }
.status-new { background: rgba(56,189,248,.18); color: #7dd3fc; }
.status-triaged { background: rgba(251,191,36,.18); color: #fcd34d; }
.status-resolved { background: rgba(52,211,153,.18); color: #6ee7b7; }
