:root {
  --fondo: #fafafa;
  --carta: #ffffff;
  --inchiostro: #0d0d12;
  --grigio: #6b6b76;
  --tenue: #a3a3ad;
  --linea: rgba(13, 13, 18, 0.08);
  --organic: #3346d3;
  --paid: #7f8ef1;
  --referral: #c5ccfb;
  --su: #11845b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  position: relative;
  width: min(92vw, 520px);
  background: var(--carta);
  border: 1px solid var(--linea);
  border-radius: 20px;
  padding: clamp(14px, 3.2vh, 24px) clamp(16px, 4vw, 26px) clamp(12px, 2.6vh, 20px);
  box-shadow: 0 1px 2px rgba(13, 13, 18, 0.04), 0 18px 40px -18px rgba(13, 13, 18, 0.16);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  font-size: clamp(14px, 2.2vh, 16px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card__sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--grigio);
}

.card__range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 12px;
  color: var(--grigio);
  background: var(--fondo);
  border: 1px solid var(--linea);
  border-radius: 999px;
  padding: 5px 9px 5px 11px;
  cursor: default;
}

.card__range svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.total {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: clamp(8px, 2vh, 16px);
}

.total__num {
  font-size: clamp(26px, 5.4vh, 36px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
}

.total__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--su);
  background: rgba(17, 132, 91, 0.09);
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  font-variant-numeric: tabular-nums;
}

.total__delta svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.total__vs { font-size: 12px; color: var(--tenue); }

/* rolling digits: each digit is a column of 0-9 that slides; the separators stay still */
.roll { display: inline-block; height: 1em; overflow: hidden; line-height: 1; }
.roll__col { display: flex; flex-direction: column; }
.roll__col span { display: block; height: 1em; text-align: center; }
.roll__sep { display: inline-block; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: clamp(10px, 2.2vh, 16px);
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--chip-ink);
  background: var(--chip-bg);
  transition: color 0.25s, background-color 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.chip__check { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.chip.is-off {
  color: var(--tenue);
  background: transparent;
  border-color: var(--linea);
}

.chip:focus-visible { outline: 2px solid var(--organic); outline-offset: 2px; }

@media (hover: hover) {
  .chip:hover { box-shadow: 0 0 0 3px rgba(51, 70, 211, 0.08); }
}

.chart {
  position: relative;
  height: clamp(104px, 30vh, 210px);
  margin-top: clamp(10px, 2.4vh, 18px);
}

.chart__grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart__grid span { display: block; height: 1px; background: var(--linea); }
.chart__grid span:last-child { background: rgba(13, 13, 18, 0.14); }

.chart__bars {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n, 12), 1fr);
  gap: clamp(4px, 1.2vw, 9px);
  align-items: end;
}

.col {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
}

/* the soft track behind the hovered week */
.col__track {
  position: absolute;
  inset: -6px -3px 0;
  border-radius: 8px;
  background: rgba(51, 70, 211, 0.06);
  opacity: 0;
}

.col__stack {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
}

.seg {
  display: block;
  width: 100%;
  height: 0;
  border-radius: 2px;
}

.seg + .seg { margin-bottom: 2px; }
.seg.is-top { border-radius: 5px 5px 2px 2px; }
.seg--organic { background: var(--organic); }
.seg--paid { background: var(--paid); }
.seg--referral { background: var(--referral); }

.axis {
  display: grid;
  grid-template-columns: repeat(var(--n, 12), 1fr);
  gap: clamp(4px, 1.2vw, 9px);
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--tenue);
  font-variant-numeric: tabular-nums;
}

.axis span { text-align: center; white-space: nowrap; transition: color 0.2s; }
.axis span.is-on { color: var(--inchiostro); }

.tip {
  position: absolute;
  top: 0;
  left: 0;
  width: 148px;
  padding: 10px 11px 9px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--linea);
  border-radius: 12px;
  box-shadow: 0 12px 28px -10px rgba(13, 13, 18, 0.22), 0 2px 6px rgba(13, 13, 18, 0.06);
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}

.tip__week { font-size: 11px; color: var(--grigio); }

.tip__mix {
  display: flex;
  gap: 2px;
  height: 5px;
  margin: 7px 0 8px;
}

.tip__mix i { display: block; height: 100%; border-radius: 3px; }
.tip__mix i:nth-child(1) { background: var(--organic); }
.tip__mix i:nth-child(2) { background: var(--paid); }
.tip__mix i:nth-child(3) { background: var(--referral); }

.tip__row,
.tip__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.tip__row span { font-weight: 550; }
.tip__row.is-off { opacity: 0.35; }
.tip__row b,
.tip__total b { font-weight: 600; display: inline-flex; }

.tip__total {
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid var(--linea);
  color: var(--grigio);
}

.tip__total b { color: var(--inchiostro); }

.ghost {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  fill: #0d0d12;
  stroke: #ffffff;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}

@media (max-width: 420px) {
  .total__vs { display: none; }
  .tip { width: 132px; padding: 8px 9px; }
  .axis { font-size: 9.5px; }
}
