:root {
  --ink: #1c1915;
  --muted: #5e584f;
  --paper: #f3efe6;
  --card: #faf7f1;
  --line: #e0d8cb;
  --forest: #1b3d30;
  --forest-2: #245443;
  --cream: #f6f1e7;
  --brass: #8d6a2f;
  --expansion: #2f7d52;
  --retained: #1b3d30;
  --contraction: #b0863c;
  --churn: #8c3b34;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(141, 106, 47, 0.08), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px 7vw 24px;
  background: var(--forest);
  color: var(--cream);
  border-bottom: 4px solid var(--brass);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand:focus-visible { outline: 2px solid white; outline-offset: 4px; }

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--cream);
  color: var(--forest);
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #d9c7a2;
}

h1 {
  margin: 2px 0 0;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.top-side { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

.nav {
  color: var(--cream);
  text-decoration: none;
  font-weight: 600;
}
.nav[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.nav:hover { color: white; }
.nav:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.top-side form { margin: 0; }
.nav-button {
  font: inherit;
  font-weight: 600;
  color: var(--cream);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.nav-button:hover { color: white; }
.nav-button:focus-visible { outline: 2px solid white; outline-offset: 3px; }

main.login { max-width: 32rem; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 14px 10px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a[aria-current="page"] {
  color: var(--forest);
  border-bottom-color: var(--forest);
}
.tabs a:hover { color: var(--ink); }
.tabs a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.summary { margin: 0 0 22px; }
.summary tr.total th,
.summary tr.total td { font-weight: 700; }
.freq { width: 100%; min-width: 0; }
.freq .track { width: 42%; }
.track-bar {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: #e7efe9;
  overflow: hidden;
}
.track-bar span {
  display: block;
  height: 100%;
  background: var(--forest);
  border-radius: 999px;
}

.cadence {
  margin: 0;
  color: #e7efe9;
  font-size: 0.95rem;
}

.csv {
  color: var(--forest);
  background: var(--cream);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.csv:hover { background: white; }
.csv:focus-visible { outline: 2px solid white; outline-offset: 3px; }

main {
  padding: 28px 7vw 64px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.banner {
  background: #f8f1df;
  border: 1px solid #e3d2a4;
  border-radius: 16px;
  padding: 16px 18px;
  color: #3f3420;
}

.banner p { margin: 0; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 28px 36px;
  align-items: start;
}

.hero > *,
.split > * {
  min-width: 0;
}

.hero .eyebrow { color: var(--brass); }

.figure {
  margin: 8px 0 0;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: clamp(4.5rem, 10vw, 7.4rem);
  line-height: 0.85;
  letter-spacing: -0.04em;
  font-variant-numeric: lining-nums;
}

.figure.dollars {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.lede { margin: 14px 0 0; max-width: 38rem; font-size: 1.05rem; }

.formula {
  margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.92rem;
}

.grr { margin: 8px 0 0; color: var(--forest-2); }
.grr span { color: var(--muted); }

.parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin: 0;
}

.parts div { margin: 0; }

.parts dt {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.parts dd {
  margin: 2px 0 0;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.parts .sub {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0;
}

.expansion dd { color: var(--expansion); }
.contraction dd { color: #8a6424; }
.churn dd { color: var(--churn); }

.bar {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 14px;
  margin-top: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.seg { display: block; height: 100%; min-width: 0; }
.seg.retained { background: var(--retained); }
.seg.expansion { background: var(--expansion); }
.seg.contraction { background: var(--contraction); }
.seg.churn { background: var(--churn); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.82rem;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 6px;
}
.swatch.retained { background: var(--retained); }
.swatch.expansion { background: var(--expansion); }
.swatch.contraction { background: var(--contraction); }
.swatch.churn { background: var(--churn); }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

h2 {
  margin: 0 0 12px;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
}

h3 {
  margin: 18px 0 8px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-head p { margin: 0 0 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; max-width: 100%; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 860px;
}

table.compact { min-width: 0; }

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
  white-space: nowrap;
}

th { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
tbody th { font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; }

.num { text-align: right; }
.nrr { font-weight: 700; }

.vs { display: block; font-weight: 500; color: var(--muted); font-size: 0.78rem; letter-spacing: 0; text-transform: none; }

.pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f3e6c8;
  color: #6d5016;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 1px;
}

tr.is-hero,
tr.is-selected { background: #f3f7f4; }
tr.is-partial { color: var(--muted); }

tbody th a { color: inherit; text-decoration: none; }
tbody th a:hover { text-decoration: underline; }
tbody th a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.picker { display: grid; gap: 14px; min-width: 0; }
.asof { margin: 0; color: var(--muted); }
.range-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  max-width: 100%;
}
.range-form .field { display: grid; gap: 4px; min-width: 0; max-width: 100%; }
.range-form .field-preset { flex: 1 1 16rem; }
.range-form .field-date { flex: 1 1 9.5rem; }
.range-form .field-compare { flex: 1 1 14rem; }
.range-form label { font-size: 0.85rem; color: var(--muted); }
.range-form input,
.range-form select,
.range-form button {
  font: inherit;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 40px;
  max-width: 100%;
}
.range-form input,
.range-form select { width: 100%; min-width: 0; }
.range-form button {
  align-self: flex-end;
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
  font-weight: 600;
  cursor: pointer;
}
.range-form button:hover { background: var(--forest-2); }
.range-form button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.range-detail { margin: 0; font-variant-numeric: tabular-nums; }
.newcomers { margin: 8px 0 0; color: var(--muted); }
.chart-wrap { overflow-x: auto; max-width: 100%; }
.chart { width: 100%; min-width: 0; height: auto; display: block; }
.chart .line { fill: none; }
.chart .line.existing { stroke: #1b3d30; stroke-width: 2.5; }
.chart .line.winback { stroke: #8d6a2f; stroke-width: 2.5; }
.chart .line.new { stroke: #2f7d52; stroke-width: 2.5; }
.chart .line.nrr { stroke: #1b3d30; stroke-width: 2.5; }
.chart .line.grr { stroke: #8d6a2f; stroke-width: 2; stroke-dasharray: 5 4; }
.chart .line.prior { stroke: #8d6a2f; stroke-width: 2; stroke-dasharray: 5 4; }
.chart .line.expansion { stroke: #2f7d52; stroke-width: 2; }
.chart .line.contraction { stroke: #b0863c; stroke-width: 2; stroke-dasharray: 5 4; }
.chart .line.churn { stroke: #8c3b34; stroke-width: 2.5; }
.chart .guide { stroke: #c4b49a; stroke-dasharray: 2 4; }
.chart .grid { stroke: #efe8dc; }
.chart .axis { fill: #5e584f; font-size: 13px; font-family: "Avenir Next", "Segoe UI", sans-serif; }
.chart-form { margin-bottom: 4px; }
.chart .bar.existing { fill: #1b3d30; }
.chart .bar.winback { fill: #8d6a2f; }
.chart .bar.new { fill: #2f7d52; }
.chart .hit { fill: transparent; }
.chart .dot.existing { fill: #1b3d30; }
.chart .dot.winback { fill: #8d6a2f; }
.chart .dot.new { fill: #2f7d52; }
.chart text.series { font-size: 13px; font-weight: 600; }
.chart text.series.existing { fill: #1b3d30; }
.chart text.series.winback { fill: #8d6a2f; }
.chart text.series.new { fill: #2f7d52; }
.chart .dot.nrr { fill: #1b3d30; }
.chart .dot.grr { fill: #8d6a2f; }
.chart .dot.prior { fill: #8d6a2f; }
.chart .dot.expansion { fill: #2f7d52; }
.chart .dot.contraction { fill: #b0863c; }
.chart .dot.churn { fill: #8c3b34; }
.chart .dot.selected { stroke: #8d6a2f; stroke-width: 3; }
.chart a:hover .dot.nrr,
.chart a:focus-visible .dot.nrr { stroke: #8d6a2f; stroke-width: 2; }
.chart a:hover .dot.prior,
.chart a:focus-visible .dot.prior { stroke: #1b3d30; stroke-width: 2; }
.swatch.nrr { background: var(--forest); }
.swatch.grr { background: var(--brass); }
.swatch.guide { background: transparent; border: 1px dashed #c4b49a; }
.swatch.existing { background: var(--forest); }
.swatch.winback { background: var(--brass); }
.swatch.new { background: var(--expansion); }

.segments { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.segments a {
  color: var(--ink);
  background: white;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}
.segments a[aria-current="page"] {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.segments a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.lag { margin-top: 14px; }

.delta {
  margin: 8px 0 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.mix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 0; }
.mix div { margin: 0; }
.mix dt {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.mix dd {
  margin: 2px 0 0;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

.pager { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; }
.pager a { color: var(--forest); font-weight: 600; }

.note { color: var(--muted); font-size: 0.92rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.tabs a {
  color: var(--ink);
  background: white;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}
.tabs a:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.tabset:not(:has(:target)) a[href="#table"],
.tabset:not(:has(#table)):not(:has(:target)) a[href="#notes"],
.tabset:has(#table:target) a[href="#table"],
.tabset:has(#notes:target) a[href="#notes"],
.tabset:has(#sales:target) a[href="#sales"] {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.tab-panel { display: none; }
.tabset:not(:has(:target)) #table,
.tabset:not(:has(#table)):not(:has(:target)) #notes,
.tab-panel:target { display: block; }

.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drop {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1.5px dashed var(--brass);
  border-radius: 12px;
  padding: 14px;
  background: var(--cream);
  cursor: pointer;
}
.drop.is-over,
.drop.has-file { border-color: var(--forest); background: #e7efe9; }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }

.upload-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  min-width: 0;
}
.upload-form .field { display: grid; gap: 4px; min-width: 0; max-width: 100%; }
.upload-form label { font-size: 0.85rem; color: var(--muted); }
.upload-form input[type="file"],
.upload-form input[type="text"],
.upload-form input[type="password"] {
  font: inherit;
  width: 100%;
  max-width: 32rem;
  min-width: 0;
}
.upload-form input[type="text"],
.upload-form input[type="password"] {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}
.upload-form button {
  justify-self: start;
  font: inherit;
  font-weight: 600;
  color: var(--cream);
  background: var(--forest);
  border: 1px solid var(--forest);
  border-radius: 10px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
.upload-form button:hover { background: var(--forest-2); }
.upload-form button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.upload-form button.button-quiet {
  color: var(--forest);
  background: transparent;
}
.upload-form button.button-quiet:hover { background: #e7efe9; }
.upload-error,
.upload-notice {
  border-radius: 16px;
  padding: 16px 18px;
  overflow-wrap: anywhere;
}
.upload-error {
  background: #f8ebe6;
  border: 1px solid #e2c2ba;
  color: #6d2e28;
}
.upload-notice {
  background: #e7f0ea;
  border: 1px solid #c5d9cc;
  color: var(--forest);
}
.upload-error p,
.upload-notice p { margin: 0; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
}

ol { margin: 0; padding-left: 1.2rem; }
ol li { margin: 0 0 8px; }

.facts { margin: 0; display: grid; gap: 10px; }
.facts div { display: grid; grid-template-columns: 9.5rem 1fr; gap: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .top { flex-direction: column; align-items: flex-start; }
  .hero, .split, .drops { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
  .facts div { grid-template-columns: 1fr; gap: 2px; }
  .parts, .mix { grid-template-columns: 1fr; }
  .parts dd { font-size: 1.35rem; }
  .formula, .lede, .range-detail, .newcomers { overflow-wrap: anywhere; }
  .range-form { align-items: stretch; }
}

@media print {
  .top { border-bottom: 2px solid black; }
  .csv, .banner, .tabs { display: none; }
  .tab-panel { display: block; }
  body { background: white; }
  .panel { break-inside: avoid; box-shadow: none; }
}
