@font-face {
  font-family: 'Bricolage';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url('/static/bricolage-var.woff2') format('woff2');
}

:root {
  --bg: #0b0c10;
  --surface: #14171e;
  --surface-2: #1b1f28;
  --fg: #f2efe8;
  --fg-2: #b5b8c0;
  --fg-3: #8d919b;
  --line: rgba(242, 239, 232, 0.13);
  --accent: #ff4d2e;
  --accent-soft: rgba(255, 77, 46, 0.16);
  --track: rgba(242, 239, 232, 0.08);
  --ui: 'Bricolage', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.5 var(--ui);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
h1, h2 { font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(28px, 5vw, 44px); font-stretch: 85%; }
h2 { font-size: 20px; }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--fg-2); }
.small { font-size: 13px; }

/* ---- header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 10px var(--gutter);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11, 12, 16, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 20px; font-stretch: 85%; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top nav a {
  text-decoration: none; color: var(--fg-2); padding: 10px 14px; border-radius: 999px; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center;
}
.top nav a:hover { color: var(--fg); }
.top nav a[aria-current='page'] { color: var(--fg); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.logout button, .periods a {
  font: inherit; color: var(--fg-2); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer;
}
.logout button:hover { color: var(--fg); border-color: var(--fg-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

main { max-width: 1240px; margin: 0 auto; padding: 28px var(--gutter) 64px; display: grid; gap: 24px; }
.lead { color: var(--fg-2); max-width: 62ch; margin-top: -8px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.periods { display: flex; gap: 6px; flex-wrap: wrap; }
.periods a { text-decoration: none; display: inline-flex; align-items: center; }
.periods a[aria-current='page'] { color: var(--bg); background: var(--fg); border-color: var(--fg); font-weight: 600; }

/* ---- strip of headline numbers */
.strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.strip > div { background: var(--surface); padding: 18px 20px; display: grid; gap: 2px; }
.strip b { font-size: clamp(30px, 6vw, 46px); font-weight: 700; font-stretch: 80%; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.strip span { color: var(--fg-2); font-size: 15px; }
@media (min-width: 760px) { .strip { grid-template-columns: repeat(4, 1fr); } }

/* ---- cards and panels */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.muted-card { background: transparent; border-style: dashed; }
.two { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }
.empty { color: var(--fg-2); }
.empty strong { color: var(--fg); }
.empty.big { background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; padding: 28px; font-size: 18px; }
.note { color: var(--fg-3); font-size: 14px; }
.more { gap: 6px; color: var(--accent); text-decoration: none; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.more:hover { text-decoration: underline; }

/* ---- tables */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.metrics th, .metrics td, .plain th, .plain td { padding: 10px 0; border-bottom: 1px solid var(--line); text-align: right; font-weight: 400; }
.metrics thead th, .plain thead th { color: var(--fg-3); font-size: 14px; padding-top: 0; }
.metrics th[scope='row'], .plain th[scope='row'], .plain thead th:first-child { text-align: left; color: var(--fg-2); }
.metrics td { font-size: 20px; font-weight: 600; }
.metrics tr:last-child th, .metrics tr:last-child td, .plain tr:last-child th, .plain tr:last-child td { border-bottom: 0; }
.plain td { color: var(--fg); }

/* ---- formula tooltips */
.tip { border-bottom: 1px dotted var(--fg-3); cursor: help; position: relative; }
.tip::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 8px); z-index: 10; width: max-content; max-width: min(300px, 80vw);
  background: var(--fg); color: var(--bg); font-size: 14px; line-height: 1.4; padding: 10px 12px; border-radius: 10px; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity 0.12s; pointer-events: none; font-weight: 400; font-stretch: 100%;
}
.tip:hover::after, .tip:focus::after { opacity: 1; visibility: visible; }
.strip .tip::after, td .tip::after { left: 0; }
.defs { color: var(--fg-2); border-top: 1px solid var(--line); padding-top: 16px; }
.defs summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--fg); }
.defs ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 8px; max-width: 80ch; }

/* ---- funnel */
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.frow { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.flabel { font-weight: 600; }
.fnum { font-variant-numeric: tabular-nums; }
.fnum b { font-size: 20px; }
.fdrop { color: var(--fg-3); font-size: 13px; margin-top: 4px; }
.bar { display: block; width: 100%; height: 12px; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar .track { fill: var(--track); }
.bar .fill { fill: var(--accent); }
.bar.alt .fill { fill: var(--fg); }

/* ---- charts */
.hist { display: grid; gap: 8px; }
.cols { width: 100%; height: 130px; display: block; }
.cols .fill { fill: var(--accent); }
.cols g:hover .fill { fill: #ff6a4f; }
.hist-labels { list-style: none; margin: 0; padding: 0; display: flex; }
.hist-labels li { flex: 1; display: grid; gap: 0; text-align: center; font-size: 12px; color: var(--fg-3); min-width: 0; line-height: 1.25; }
.hist-labels b { color: var(--fg); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hist-labels.dense li { font-size: 10px; }
.hist-labels.dense b { font-size: 11px; }
@media (max-width: 640px) { .hist-labels.dense b { display: none; } }
.big-pair { display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--fg-2); }
.big-pair b { color: var(--fg); font-size: 32px; font-weight: 700; font-stretch: 80%; letter-spacing: -0.02em; margin-right: 4px; }

/* ---- login */
body.bare main { min-height: 100vh; display: grid; place-items: center; padding-top: 24px; }
.login { width: min(380px, 100%); display: grid; gap: 14px; justify-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 32px; }
.login form { display: grid; gap: 10px; width: 100%; margin-top: 8px; }
.login label { color: var(--fg-2); font-size: 15px; }
input[type='password'] { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; width: 100%; }
input[type='password']:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
button.primary { font: inherit; font-weight: 700; color: var(--bg); background: var(--accent); border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; cursor: pointer; }
button.primary:hover { background: #ff6a4f; }
.error { color: #ff9a86; font-size: 15px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 640px) {
  .top { gap: 8px; }
  .top nav { min-width: 0; }
  .top nav a { padding: 10px 11px; }
  .brand span { display: none; }
  .logout button { padding: 8px 12px; }
}
@media (max-width: 640px) {
  .top nav a { padding: 10px 8px; font-size: 15px; }
  .logout button { padding: 8px 10px; font-size: 14px; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; }
  .brand { flex: 1; }
  .top nav { order: 3; flex-basis: 100%; }
  .brand span { display: inline; }
}

/* ---- verdict cards, retention grid, interest line */
.verdict { display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border-left: 6px solid var(--fg-3); }
.verdict.yes { border-left-color: #5ad08b; }
.verdict.notyet { border-left-color: #f2b84b; }
.verdict.early { border-left-color: var(--fg-3); }
.vword { font-size: clamp(30px, 6vw, 40px); font-weight: 800; font-stretch: 80%; letter-spacing: -0.02em; line-height: 1; }
.verdict.yes .vword { color: #7fe3a5; }
.verdict.notyet .vword { color: #f6c768; }
.verdict.early .vword { color: var(--fg-2); }
.vreason { color: var(--fg-2); font-size: 15px; }
.signals { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.sig { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'name val' 'light delta'; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.sig:last-child { border-bottom: 0; }
.sig-name { grid-area: name; color: var(--fg-2); }
.sig-val { grid-area: val; text-align: right; font-size: 22px; font-variant-numeric: tabular-nums; }
.sig-light { grid-area: light; font-size: 13px; color: var(--fg-3); }
.sig-delta { grid-area: delta; text-align: right; font-size: 13px; }
.sig.green .sig-light { color: #7fe3a5; }
.sig.amber .sig-light { color: #f6c768; }
.sig.red .sig-light { color: #ff9a86; }
.delta.up { color: #7fe3a5; }
.delta.down { color: #ff9a86; }
.interest { color: var(--fg-2); }
.interest b { color: var(--fg); font-size: 22px; margin-right: 4px; }
.windows summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--fg-2); }
.scroll { overflow-x: auto; }
.cohort { width: 100%; border-collapse: collapse; min-width: 420px; }
.cohort th, .cohort td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); font-weight: 400; font-variant-numeric: tabular-nums; }
.cohort thead th { color: var(--fg-3); font-size: 14px; }
.cohort th[scope='row'], .cohort thead th:first-child { text-align: left; color: var(--fg-2); }
.cohort td b { display: block; font-size: 17px; font-weight: 600; }
.cohort .sub { display: block; font-size: 11px; color: var(--fg-2); }
.cohort td.h-none { color: var(--fg-3); }
.cohort td.h0 { background: transparent; }
.cohort td.h1 { background: rgba(255, 77, 46, 0.10); }
.cohort td.h2 { background: rgba(255, 77, 46, 0.20); }
.cohort td.h3 { background: rgba(255, 77, 46, 0.32); }
.cohort td.h4 { background: rgba(255, 77, 46, 0.46); }
.cohort td.h5 { background: rgba(255, 77, 46, 0.62); }
.cohort td.partial { outline: 1px dashed var(--fg-3); outline-offset: -3px; }
