@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #0F0F0F;
  --card: #161616;
  --chip: #1E1E1E;
  --border: #222222;
  --text: #F2F2F2;
  --muted: #6E6E73;
  --faint: #4E4E54;
  --accent: #FFD000;
  --accent-ink: #0F0F0F;
  --up: #3DDC84;
  --down: #FF4D4D;
  --hover: #1A1A1A;
  --grid: #1C1C1C;
  --radius: 12px;
  --radius-sm: 8px;
  --side: 240px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "Geist", sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button, select, input { font: inherit; color: inherit; }
a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.side {
  width: var(--side);
  flex: 0 0 var(--side);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--chip); color: var(--text); }
.side-foot { margin-top: auto; padding: 0 10px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.side-foot b { color: var(--text); font-weight: 500; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 13.5px; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn.btn-small { padding: 5px 12px; font-size: 13.5px; border-radius: 999px; flex: 0 0 auto; }

/* Main */
main { flex: 1; min-width: 0; padding: 28px 36px 72px; max-width: 1280px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.top h1 { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.top-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.export-status { margin: 0; color: var(--muted); font-size: 14px; min-height: 0; }
.export-status:empty { display: none; }
.range { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.range button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.range button:hover { color: var(--text); }
.range button[aria-pressed="true"] { background: var(--chip); color: var(--text); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; min-height: 0; margin: 6px 0 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 8px 6px 14px; font-size: 14.5px; color: var(--text);
}
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 8px; border-radius: 999px; font-size: 15px; }
.chip button:hover { color: var(--text); }

.lead { color: var(--text); font-size: 17px; max-width: 820px; margin: 6px 0 24px; text-wrap: pretty; }
.lead b, .summary b { color: var(--text); font-weight: 600; }

/* Sections */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 22px;
  scroll-margin-top: 16px;
  transition: border-color 0.4s ease;
}
.section.flash { border-color: var(--accent); }
.section h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.summary { color: var(--text); margin: 0 0 18px; font-size: 15px; text-wrap: pretty; }
.section h3 { font-size: 15px; font-weight: 500; color: var(--text); margin: 22px 0 8px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 36px; }

/* Charts */
.chart { position: relative; width: 100%; height: 310px; margin: 6px 0 10px; touch-action: pan-y; }
.chart.short { height: 230px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 13px; }
.chart .vlabel { font-size: 13px; font-weight: 600; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .bar { transition: opacity 0.15s ease; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.clickable { cursor: pointer; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text); font-size: 14px; margin-top: 4px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

.hbars { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
.hbar {
  display: grid; grid-template-columns: minmax(100px, 200px) minmax(0, 1fr) auto; align-items: center; gap: 14px;
  border: 0; background: transparent; padding: 5px 6px; border-radius: 6px; text-align: left; width: 100%;
}
button.hbar { cursor: pointer; }
button.hbar:hover { background: var(--hover); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar .track { display: block; height: 12px; background: var(--chip); border-radius: 6px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--muted); border-radius: 6px; }
.hbar.focus .fill { background: var(--accent); }
.hbar .val { color: var(--text); min-width: 128px; text-align: right; }

/* First hour funnel */
.funnel { display: flex; flex-direction: column; margin: 8px 0 16px; }
.fstep { padding: 8px 6px; border-radius: var(--radius-sm); outline: none; }
.fstep:hover, .fstep:focus-visible { background: var(--hover); }
.fhead { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.fname { font-weight: 600; font-size: 16px; }
.fnums { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); font-size: 14.5px; }
.fnums b { color: var(--text); font-size: 17px; font-weight: 600; }
.fbar { display: flex; justify-content: center; background: var(--chip); border-radius: 6px; height: 30px; }
.ffill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.fstep.drop .ffill { background: var(--down); }
.fstep.drop .fname { color: var(--down); }
.fgap { display: flex; justify-content: center; color: var(--muted); font-size: 14px; padding: 4px 0; text-align: center; }
.fgap.drop { color: var(--down); font-weight: 600; }
.fwhy { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.fstep.untracked .fnums { color: var(--text); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 14px; }
th:first-child, td:first-child { text-align: left; }
td:first-child { white-space: normal; min-width: 120px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--hover); }
tbody tr.selected td { background: var(--chip); }
td.muted, .muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.kv td:first-child { color: var(--muted); }
.kv td { padding: 9px 10px; }
.kv td:last-child { font-weight: 500; }

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  color: var(--text);
  font-size: 15px;
}
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.note { color: var(--muted); font-size: 14px; margin: 12px 0 0; }

.insight { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.insight:last-child { border-bottom: 0; }
.insight p { margin: 0; text-wrap: pretty; }
.insight .tag { color: var(--muted); font-size: 14px; margin-right: 8px; }
.insight a { color: var(--accent); white-space: nowrap; text-decoration: none; font-size: 15px; }
.insight a:hover { text-decoration: underline; }

.btn {
  border: 1px solid var(--border); background: var(--chip); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 18px; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn[disabled] { color: var(--muted); cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #FFDA33; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login .brand { padding: 0; }
.login-card { display: flex; flex-direction: column; gap: 10px; padding: 26px 24px; margin: 0; }
.login-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.login-lead { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.login-card label { font-size: 14px; color: var(--text); font-weight: 500; }
.login-card input {
  background: var(--page); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 16px; color: var(--text); width: 100%;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login-error { margin: 0; color: var(--down); font-size: 14.5px; }
.login-card .btn { margin-top: 8px; font-size: 15.5px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg button { border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14.5px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--chip); color: var(--text); }

.tip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--chip); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; min-width: 150px;
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 16px; line-height: 1.6; }
.tip .r span:last-child { font-weight: 500; }
.tip .r span:first-child { color: var(--muted); }

.loading { color: var(--muted); padding: 24px 0; }
.view { transition: opacity 0.15s ease; }
.view.busy { opacity: 0.5; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .side {
    width: auto; height: auto; flex: 0 0 auto; position: sticky; top: 0; z-index: 5; background: var(--page);
    flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; flex: 0 0 auto; }
  .side .brand span:last-child { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav a { white-space: nowrap; padding: 8px 12px; }
  .side-foot { display: none; }
  .side-user { padding: 0; border: 0; flex: 0 0 auto; }
  .side-user span { display: none; }
  main { padding: 18px 16px 56px; }
  .top h1 { font-size: 24px; }
  .lead { font-size: 16px; }
  .top-tools { width: 100%; }
  .top-tools .btn { width: 100%; }
  .range { width: 100%; }
  .range button { flex: 1; padding: 8px 2px; font-size: 14px; }
  .section { padding: 18px 16px; margin-bottom: 18px; }
  table { font-size: 14.5px; }
  th, td { padding: 9px 8px; }
  .cols { grid-template-columns: 1fr; }
  .chart { height: 250px; }
  .chart.short { height: 210px; }
  .hbar { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .hbar .track { grid-column: 1 / -1; grid-row: 2; }
  .hbar .val { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
