:root {
  --fondo: #ffffff;
  --card: #ffffff;
  --inchiostro: #111113;
  --grigio: #6f6f77;
  --grigio-chiaro: #a1a1aa;
  --bordo: rgba(17, 17, 19, 0.08);
  --traccia: #f2f2f4;
  --pillola: #ffffff;
  --scheda: #f3f3f5;
  --meglio: #1f9d55;
}

* { 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: 12px;
}

/* ---------- the card ---------- */
.spend {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  padding: clamp(14px, 3.4vh, 20px) clamp(14px, 4vw, 20px) clamp(12px, 2.8vh, 16px);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 12px 32px -12px rgba(17, 17, 19, 0.14);
}

.spend__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spend__title { display: flex; align-items: center; gap: 9px; min-width: 0; }

.spend__mark {
  width: 26px;
  height: 26px;
  flex: none;
  padding: 4px;
  border-radius: 8px;
  background: var(--inchiostro);
  fill: #ffffff;
  stroke: none;
}
.spend__mark .spend__vein { fill: none; stroke: var(--inchiostro); stroke-width: 1.4; stroke-linecap: round; }

.spend__name { font-size: 14px; font-weight: 640; letter-spacing: -0.01em; line-height: 1.15; }
.spend__range { font-size: 11.5px; color: var(--grigio); line-height: 1.3; white-space: nowrap; }

/* ---------- Week / Month / Year ---------- */
.tabs {
  position: relative;
  display: flex;
  flex: none;
  padding: 3px;
  border-radius: 999px;
  background: var(--scheda);
}

.tabs__pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--pillola);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.1), 0 2px 6px -2px rgba(17, 17, 19, 0.12);
}

.tabs__tab {
  position: relative;
  border: 0;
  background: none;
  font: inherit;
  font-size: 11.5px;
  font-weight: 560;
  font-stretch: 100%;
  color: var(--grigio);
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, font-stretch 0.25s;
}
.tabs__tab.is-on { color: var(--inchiostro); font-stretch: 112%; }
.tabs__tab:focus-visible { outline: 2px solid var(--t2, #4f46e5); outline-offset: 1px; }
@media (hover: hover) {
  .tabs__tab:not(.is-on):hover { color: var(--inchiostro); }
}

/* ---------- donut and legend ---------- */
.spend__body {
  display: flex;
  align-items: center;
  gap: clamp(12px, 4vw, 22px);
  margin-top: clamp(10px, 3vh, 18px);
}

.donut {
  position: relative;
  flex: none;
  width: min(156px, 40vw, 36vh);
  aspect-ratio: 1;
}

.donut__svg { width: 100%; height: 100%; overflow: visible; display: block; }
.donut__track { fill: none; stroke: var(--traccia); stroke-width: 18; }
.slice { cursor: pointer; }
.slice path { fill: none; stroke-linecap: butt; }

.donut__center {
  position: absolute;
  inset: 22%;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}
.donut__label {
  font-size: 10.5px;
  color: var(--grigio);
  line-height: 1.2;
  white-space: nowrap;
}
.donut__value {
  font-size: min(22px, 6vw, 5.4vh);
  font-weight: 680;
  font-stretch: 104%;
  letter-spacing: -0.02em;
  line-height: 1.15;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: 1px;
}
.donut__note {
  font-size: 10.5px;
  font-weight: 560;
  color: var(--grigio-chiaro);
  line-height: 1.2;
  height: 1.2em;
}

/* the rolling digits: one window per character, a column of 0-9 inside */
.roll { display: block; height: 1.15em; line-height: 1.15em; overflow: hidden; position: relative; }
.roll__col { display: flex; flex-direction: column; }
.roll__col span { display: block; height: 1.15em; line-height: 1.15em; text-align: center; }
.roll--sym { overflow: visible; }

.legend {
  list-style: none;
  flex: 1;
  min-width: 0;
  display: grid;
  gap: min(9px, 1.6vh);
}

.row {
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 0;
}
.row__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1.25;
}
.row__name { font-weight: 540; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__amt { display: flex; font-weight: 600; color: var(--inchiostro); white-space: nowrap; line-height: 1.15; }
.row__bar {
  margin-top: 4px;
  height: 3px;
  border-radius: 3px;
  background: var(--traccia);
  overflow: hidden;
}
.row__fill { height: 100%; width: 100%; border-radius: 3px; transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- footer ---------- */
.spend__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: clamp(10px, 2.6vh, 16px);
  padding-top: clamp(9px, 2.2vh, 12px);
  border-top: 1px solid var(--bordo);
}
.spend__trend { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--meglio); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spend__insight { font-size: 11.5px; color: var(--grigio); }
.spend__insight b { color: var(--inchiostro); font-weight: 600; }

/* ---------- the drawn pointer of the autopilot ---------- */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #111113;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  z-index: 5;
}

@media (max-width: 380px) {
  .tabs__tab { padding: 5px 8px; font-size: 11px; }
  .row__top { font-size: 11.5px; }
  .spend__range { font-size: 11px; }
}
