:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --testo: #121419;
  --testo-2: #5c6270;
  --testo-3: #9da2ad;
  --linea: #eceef2;
  --traccia: #e3e6eb;
  --accento: #13905c;        /* the single accent: paid, the timeline, the stamp */
  --accento-velo: #e8f5ee;
  --ombra-1: rgba(18, 20, 25, 0.05);
  --ombra-2: rgba(18, 20, 25, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
  /* everything inside is measured in em: the card grows with the width and the height of the window */
  font-size: clamp(10.5px, min(3.55vw, 2.62vh), 17px);
}

.inv {
  position: relative;
  width: min(30em, calc(100vw - 24px));
  padding: 1.35em 1.4em 1.2em;
  border-radius: 1.25em;
  background: var(--carta);
  border: 1px solid var(--linea);
  box-shadow:
    0 1px 2px var(--ombra-1),
    0 0.9em 2.4em -0.9em var(--ombra-2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-variant-numeric: tabular-nums;
}

/* ---- head ---- */
.inv__head { display: flex; align-items: center; justify-content: space-between; gap: 1em; }
.inv__id { display: flex; flex-direction: column; gap: 0.15em; }
.inv__label { font-size: 0.72em; color: var(--testo-3); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 520; }
.inv__no { font-size: 1.12em; font-weight: 640; letter-spacing: -0.01em; font-stretch: 112%; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 1.9em;
  padding: 0 0.8em;
  border-radius: 99em;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--testo-2);
  background: #f2f3f6;
  box-shadow: inset 0 0 0 1px rgba(18, 20, 25, 0.04);
  transition: background-color 0.5s ease, color 0.5s ease;
}
.inv[data-s="1"] .pill, .inv[data-s="2"] .pill { color: var(--testo); background: #eef0f4; }
.inv[data-s="3"] .pill { color: var(--accento); background: var(--accento-velo); }

/* the rolling windows: one line tall, their width set by the script from a hidden probe */
.roll { position: relative; display: inline-grid; overflow: hidden; vertical-align: top; line-height: 1.25; }
.roll__line { grid-area: 1 / 1; white-space: nowrap; }
.roll__probe { position: absolute; left: 0; top: 0; visibility: hidden; white-space: nowrap; pointer-events: none; }

/* ---- client ---- */
.inv__client {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-top: 1.1em;
  padding-bottom: 1em;
  border-bottom: 1px solid var(--linea);
}
.mono {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.3em;
  height: 2.3em;
  border-radius: 50%;
  background: #f1f2f5;
  color: var(--testo-2);
  font-size: 0.85em;
  font-weight: 640;
  letter-spacing: 0.02em;
}
.client { display: flex; flex-direction: column; gap: 0.12em; min-width: 0; }
.client__name { font-weight: 600; font-size: 0.95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client__due { font-size: 0.76em; color: var(--testo-3); }
.inv__from { margin-left: auto; font-size: 0.72em; color: var(--testo-3); white-space: nowrap; }

/* ---- rows ---- */
.rows { list-style: none; margin-top: 0.55em; }
.row { position: relative; }
.row__in {
  padding: 0.55em 0.55em;
  margin: 0 -0.55em;
  border-radius: 0.7em;
  transition: transform 0.45s cubic-bezier(.3, 1.45, .5, 1), background-color 0.35s ease, box-shadow 0.35s ease;
}
.row__main { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; }
.row__name { font-size: 0.92em; font-weight: 520; }
.row__amt { font-size: 0.92em; font-weight: 560; }
.row__more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.45s cubic-bezier(.2, .8, .2, 1); }
.row__more-in {
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 1em;
  font-size: 0.74em;
  color: var(--testo-3);
  opacity: 0;
  transform: translateY(-0.3em);
  transition: opacity 0.3s ease, transform 0.45s ease;
}
.row__vat { color: var(--testo-2); }
.row.is-open .row__in {
  transform: translateY(-2px);
  background: #fafbfc;
  box-shadow: 0 1px 0 var(--linea), 0 0.5em 1.1em -0.6em rgba(18, 20, 25, 0.18);
}
.row.is-open .row__more { grid-template-rows: 1fr; }
.row.is-open .row__more-in { opacity: 1; transform: none; padding-top: 0.3em; }
@media (hover: hover) {
  .row:hover .row__in {
    transform: translateY(-2px);
    background: #fafbfc;
    box-shadow: 0 1px 0 var(--linea), 0 0.5em 1.1em -0.6em rgba(18, 20, 25, 0.18);
  }
  .row:hover .row__more { grid-template-rows: 1fr; }
  .row:hover .row__more-in { opacity: 1; transform: none; padding-top: 0.3em; }
}

/* ---- total and stamp ---- */
.inv__total {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 0.5em;
  padding-top: 0.85em;
  border-top: 1px dashed var(--traccia);
}
.total__label { display: flex; flex-direction: column; gap: 0.2em; font-size: 0.82em; color: var(--testo-2); font-weight: 520; }
.total__vat { font-size: 0.86em; color: var(--testo-3); font-weight: 450; }
.total { font-size: 1.75em; font-weight: 660; letter-spacing: -0.02em; font-stretch: 108%; transition: color 0.6s ease; }
.inv[data-s="3"] .total { color: var(--accento); }

.stamp {
  position: absolute;
  left: 27%;
  top: -0.35em;
  width: 7.6em;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.stamp__in { display: block; }
.stamp__svg { display: block; width: 100%; height: auto; overflow: visible; }
.stamp__ring { fill: none; stroke: var(--accento); stroke-width: 2.6; }
.stamp__ring--thin { stroke-width: 1; opacity: 0.7; }
.stamp__word { fill: var(--accento); font: 760 20px "Mona Sans Variable", system-ui, sans-serif; font-stretch: 125%; letter-spacing: 3px; }
.stamp__date { fill: var(--accento); font: 600 6.4px "Mona Sans Variable", system-ui, sans-serif; letter-spacing: 1.4px; opacity: 0.85; }

/* ---- timeline: four thin ticks on a hairline, never dots ---- */
.tl {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 1.15em;
}
.tl__track {
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  top: 0.6em;
  height: 2px;
  border-radius: 2px;
  background: var(--traccia);
  overflow: hidden;
}
.tl__fill { position: absolute; inset: 0; background: var(--accento); transform-origin: 0 50%; transform: scaleX(0); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.45em; }
.tick { height: 1.2em; display: grid; place-items: center; }
.tick__mark {
  width: 2px;
  height: 0.75em;
  border-radius: 2px;
  background: var(--traccia);
  transition: background-color 0.4s ease, height 0.4s ease;
}
.step__label { font-size: 0.7em; color: var(--testo-3); transition: color 0.4s ease; }
.step.is-on .tick__mark { background: var(--accento); height: 1.15em; }
.step.is-on .step__label { color: var(--testo); }

/* ---- foot ---- */
.inv__foot { display: flex; align-items: center; justify-content: space-between; gap: 0.8em; margin-top: 1.15em; }
.btn { flex: none; border-radius: 99em; }
.btn__face {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  height: 2.6em;
  padding: 0 1.05em 0 0.9em;
  border-radius: 99em;
  background: var(--testo);
  color: #fff;
  font-size: 0.88em;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 0.45em 1em -0.5em rgba(18, 20, 25, 0.55);
  transition: background-color 0.45s ease, color 0.45s ease, box-shadow 0.45s ease;
}
.inv[data-s="1"] .btn__face, .inv[data-s="2"] .btn__face {
  background: #fff;
  color: var(--testo);
  box-shadow: inset 0 0 0 1px #dfe2e8, 0 1px 2px var(--ombra-1);
}
.btn__icons { position: relative; width: 1.15em; height: 1.15em; flex: none; }
.ic { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.ic[data-ic="0"] { opacity: 1; }
.btn:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
@media (hover: hover) {
  .btn:hover .btn__face { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 0.6em 1.3em -0.5em rgba(18, 20, 25, 0.6); }
  .inv[data-s="1"] .btn:hover .btn__face, .inv[data-s="2"] .btn:hover .btn__face { box-shadow: inset 0 0 0 1px #c9cdd5, 0 2px 5px var(--ombra-1); }
}
.note { min-width: 0; font-size: 0.76em; color: var(--testo-3); text-align: right; }
.note .roll { max-width: 100%; }

@media (max-width: 380px) {
  .inv__from { display: none; }
}
