:root {
  color-scheme: dark;
  --bg: #07060b;
  --card: #121018;
  --card-2: #181422;
  --line: #2c2438;
  --ink: #f6f3fb;
  --muted: #9b93a8;
  --purple: #c084fc;
  --purple-deep: #9933cc;
  --mint: #5eead4;
  --bad: #fb7185;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(820px 380px at 110% -10%, rgba(153, 51, 204, .34), transparent 58%),
    radial-gradient(640px 320px at -12% -8%, rgba(94, 234, 212, .08), transparent 52%),
    var(--bg);
  font: 15px/1.5 "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}
a { color: var(--purple); }
code { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, monospace; color: #f5e9ff; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 22px 88px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-name { display: flex; flex-direction: column; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.brand-name small, .kicker {
  color: var(--purple);
  letter-spacing: .18em;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.app-icon {
  width: 40px; height: 40px; object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 8px 16px rgba(153, 51, 204, .45));
}
nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
nav a, button, select, input { font: inherit; }
nav a {
  color: var(--muted); text-decoration: none;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid transparent;
}
nav a.on { color: #fff; background: #1c1428; border-color: #3d2a58; }
.kicker { margin: 0; }
h1 { margin: 6px 0 18px; font-size: 40px; line-height: 1; letter-spacing: -0.045em; font-weight: 700; }
h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.03em; }
h3 { margin: 14px 0 6px; font-size: 15px; }
.lede { margin: -8px 0 22px; max-width: 68ch; color: var(--muted); }
.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 42%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
  min-width: 0;
}
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-items: end; }
#pixel-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#pixel-filters .ss { grid-column: 3 / span 3; max-width: none; }
#pixel-filters button.primary { grid-column: 6; width: 100%; }
label {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase;
}
input, select, button {
  height: 40px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; background: #0c0a12; color: var(--ink); width: 100%;
}
button { cursor: pointer; font-weight: 650; width: auto; }
button.primary { background: var(--purple-deep); color: #fff; border-color: transparent; }
.kpis, .kpis-5, .funnel, .spend-grid { display: grid; gap: 12px; }
.kpis, .funnel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.spend-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.kpi, .step {
  min-width: 0; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(76deg, rgba(192, 132, 252, .12), rgba(192, 132, 252, 0));
}
.kpi .muted, .step .muted {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.kpi .value, .step .value { margin-top: 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.04em; line-height: 1.1; }
.kpi .delta { margin-top: 6px; min-height: 16px; font-size: 12px; font-weight: 600; color: var(--muted); }
.note, .warn, .pending, .lede { font-size: 13px; line-height: 1.5; }
.note { margin: 8px 0 0; color: #ddd6ea; }
.src {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: rgba(153, 51, 204, .12); border: 1px solid rgba(192, 132, 252, .28);
  color: #f3e8ff; font: 12px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
}
.src span { margin-right: 6px; font-family: inherit; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--purple); }
.warn { background: rgba(251, 113, 133, .1); border: 1px solid rgba(251, 113, 133, .35); border-radius: 12px; padding: 12px 14px; color: #fecdd3; }
.pending { background: #181422; border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.table-wrap { width: 100%; overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-3 > *, .grid-2 > * { min-width: 0; }
.snippet, pre {
  margin: 10px 0 0; padding: 14px 16px; overflow: auto; border-radius: 14px;
  background: #0c0a10; border: 1px solid #2a2236; border-left: 3px solid var(--purple-deep);
  color: #f3e8ff; font: 13px/1.55 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap;
}
.bar { height: 6px; margin-top: 12px; border-radius: 99px; background: #241c2e; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--purple); }
.ss { position: relative; min-width: 0; z-index: 5; }
.ss-list {
  display: none; position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  width: min(640px, 72vw); max-height: 320px; overflow: auto;
  background: #14111b; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.ss-list.open { display: block; }
.ss-head {
  position: sticky; top: 0; padding: 8px 12px; background: #1c1428;
  border-bottom: 1px solid var(--line);
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.ss-list label {
  display: grid; grid-template-columns: 16px 52px 16px 72px minmax(0, 1fr);
  align-items: center; column-gap: 8px; text-transform: none; letter-spacing: 0;
  font-weight: 500; color: var(--ink); font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.ss-list input[type="checkbox"] { width: 16px; height: 16px; margin: 0; padding: 0; }
.ss-list .ss-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-box { height: 280px; margin-top: 12px; }
.cell-open, .cell-acquired { color: var(--muted); }
button.live { border-radius: 999px; padding: 7px 14px; height: auto; background: transparent; color: var(--bad); border-color: rgba(251, 113, 133, .45); }
button.live.on { background: var(--bad); color: #1a0610; border-color: transparent; }
.live-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.live-status { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--bad); animation: live-pulse 1.4s ease-out infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 7px rgba(251, 113, 133, 0); } }
.live-scroll { max-height: 460px; overflow: auto; margin-top: 14px; }
.live-table { width: 100%; min-width: 720px; table-layout: fixed; }
.live-table .c-time { width: 84px; }
.live-table .c-event { width: 124px; }
.live-table .c-source { width: 110px; }
.live-table .c-campaign { width: 34%; }
.live-table th, .live-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; padding: 10px 12px; }
.live-table th { position: sticky; top: 0; z-index: 1; background: #14111b; }
.live-table .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.live-table .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.live-table td.stack { white-space: normal; }
.live-table .clip-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-table .dash { color: #4b445c; }
.ev { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.ev.view { background: #241c2e; color: #ddd6ea; }
.ev.product { background: rgba(125, 211, 252, .15); color: #7dd3fc; }
.ev.search { background: rgba(251, 191, 36, .15); color: #fcd34d; }
.ev.cart { background: rgba(192, 132, 252, .18); color: #e9d5ff; }
.ev.checkout { background: rgba(251, 113, 133, .15); color: #fda4af; }
.ev.purchase { background: rgba(94, 234, 212, .15); color: var(--mint); }
.ev.other { background: #181422; color: var(--muted); }
.live-table tr.is-new td { animation: live-in 1.6s ease; }
@keyframes live-in { from { background: rgba(192, 132, 252, .2); } to { background: transparent; } }
.live-empty td { color: var(--muted); text-align: center; padding: 28px 12px; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
#campaign-selected { margin: 10px 0 0; }
ul.note { padding-left: 18px; }
.who { color: var(--muted); font-size: 13px; padding: 0 4px; }
nav form { margin: 0; }
nav button.ghost {
  height: auto; width: auto; padding: 7px 14px; border-radius: 999px;
  background: transparent; color: var(--muted); border-color: transparent; font-weight: 600;
}
nav button.ghost:hover { color: var(--ink); }
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); margin: 0; }
.gate-card .brand { margin-bottom: 18px; }
.gate-card h1 { margin-bottom: 16px; }
.gate-card form { display: grid; gap: 12px; }
.gate-card button.primary { width: 100%; }
.gate-card .warn { margin: 0; }
@media (max-width: 980px) {
  h1 { font-size: 32px; }
  #pixel-filters, .kpis, .kpis-5, .funnel, .grid-2, .grid-3, .spend-grid { grid-template-columns: 1fr 1fr; }
  #pixel-filters .ss, #pixel-filters button.primary { grid-column: auto; }
}
@media (max-width: 640px) {
  .top { align-items: flex-start; flex-direction: column; }
  .kpis, .kpis-5, .funnel, .grid-2, .grid-3, #pixel-filters, .spend-grid { grid-template-columns: 1fr; }
}
