:root {
  --ink: #13322b;
  --gray: #414042;
  --muted: #5e6662;
  --line: #e4e1db;
  --paper: #f6f5f2;
  --card: #ffffff;
  --green: #2bc600;
  --green-soft: #e8f6df;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 "DM Sans", "Segoe UI", sans-serif;
}

img { display: block; }

button, input, textarea { font: inherit; color: inherit; }

h1, h2, p { margin: 0; }

h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }

h2 { font-size: 1rem; font-weight: 600; }

.partner {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hint, .updated, .series-summary { color: var(--muted); font-size: 0.875rem; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.7rem; }

.brand img, .gate-card img { height: 36px; width: auto; }

.partner-logo { width: 36px; border-radius: 50%; }

.cross { color: var(--muted); font-size: 1.15rem; line-height: 1; }

.account {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 0.28rem 0.8rem 0.28rem 0.28rem;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.avatar {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.account .out { color: var(--muted); font-weight: 500; }

.top-actions { display: flex; align-items: center; gap: 1rem; }

main {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
  display: grid;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

.hero .kpis { grid-template-columns: 1fr 1fr; }

.ask-card { display: flex; flex-direction: column; }

.ask-card .thread {
  max-height: 9.5rem;
  overflow: auto;
  margin: 0.75rem 0;
}

.ask-card .bubble { max-width: 100%; }

.ask-card .ask { flex-direction: column; align-items: stretch; }

.ask-card .ask button { align-self: flex-end; }

.ask-card .info-pop { left: auto; right: 0; }

.section-head, .export {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.kpis, .funnel, .retention {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.funnel, .retention { grid-template-columns: repeat(3, 1fr); }

.kpi, .step, .retain {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.card .retain { border: 0; background: #f7f6f3; padding: 0.9rem; }

.figure {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.with-info { display: inline-flex; align-items: center; gap: 0.4rem; }

.label { display: flex; align-items: center; gap: 0.35rem; color: var(--gray); margin-top: 0.25rem; }

.info { position: relative; display: inline-flex; }

.info-btn {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: 1px solid #cfcbc4;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.info-pop {
  display: none;
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.4rem);
  left: 0;
  width: min(18rem, 70vw);
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--gray);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(19, 50, 43, 0.08);
}

.info:hover .info-pop,
.info:focus-within .info-pop,
.info.open .info-pop { display: block; }

.kpi:last-child .info-pop,
.step:last-child .info-pop,
.retain:last-child .info-pop { left: auto; right: 0; }

.sub { color: var(--muted); font-size: 0.875rem; margin-top: 0.35rem; }

.track {
  height: 8px;
  margin-top: 0.9rem;
  border-radius: 99px;
  background: #e7eee4;
  overflow: hidden;
}

.fill { height: 100%; background: var(--green); border-radius: 99px; }

.range {
  display: flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: #eef1ee;
  flex: none;
}

.range button, .text, .button, .ask button, .gate button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.range button {
  background: transparent;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  color: var(--muted);
}

.range button[aria-pressed="true"] {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(19, 50, 43, 0.08);
}

.chart-wrap { position: relative; height: 320px; margin-top: 1rem; }

.chart-short { height: 240px; }

.week-title { margin-top: 1.6rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.1rem;
  margin-top: 0.75rem;
  color: var(--gray);
  font-size: 0.8125rem;
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: -1px;
}

.swatch.bar { background: rgba(43, 198, 0, 0.85); }
.swatch.avg { background: #7c8a84; }
.swatch.pct { background: #13322b; }
.swatch.pct-avg { background: #2bc600; }

.series-summary { margin-top: 0.75rem; }

.bar-row { display: grid; grid-template-columns: 8.5rem 1fr auto; gap: 0.75rem; align-items: center; margin-top: 0.7rem; }

.bar-row .track { margin-top: 0; }

.count { font-variant-numeric: tabular-nums; color: var(--gray); font-size: 0.875rem; }

.button, .ask button, .gate button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.text { background: transparent; color: var(--muted); padding: 0.4rem 0.2rem; }

.banner, .status {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 1rem;
}

.thread { display: grid; gap: 0.6rem; margin: 1rem 0; }

.bubble {
  max-width: 40rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  white-space: pre-wrap;
}

.bubble.user { justify-self: end; background: var(--green-soft); }

.bubble.assistant { background: #f4f3f0; }

.ask { display: flex; gap: 0.75rem; align-items: flex-end; }

.ask textarea, .gate input {
  width: 100%;
  border: 1px solid #d9d6d0;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: white;
  resize: vertical;
}

.ask textarea:focus, .gate input:focus, .range button:focus-visible, .button:focus-visible, .text:focus-visible, .info-btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.gate-card {
  width: min(24rem, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.5rem;
}

.gate-card h1 { margin: 1rem 0; }

.gate-card .brand { margin-bottom: 0.25rem; }

.fine { margin-top: 1rem; color: var(--muted); font-size: 0.8rem; }

.fine a, .legal a { color: var(--ink); }

.legal {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0 0 2.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.gate label { display: block; color: var(--muted); font-size: 0.875rem; }

.gate input { margin: 0.35rem 0 0.9rem; }

.gate button { width: 100%; }

.error { min-height: 1.2rem; margin-top: 0.75rem; color: #9a3412; font-size: 0.875rem; }

.empty { color: var(--muted); margin-top: 0.8rem; }

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; }
  .kpis, .funnel, .retention { grid-template-columns: 1fr 1fr; }
  .section-head, .export, .ask { flex-direction: column; align-items: stretch; }
}

@media (max-width: 560px) {
  .kpis, .funnel, .retention { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
}
