:root {
  --fondo: #fafafa;
  --card: #ffffff;
  --inchiostro: #111113;
  --grigio: #6f6f77;
  --grigio-chiaro: #a1a1aa;
  --bordo: rgba(17, 17, 19, 0.09);
  --campo: #f4f4f5;
  --carta: #fffefb;
  --accento: #e2552c;
}

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

/* ---------- the invoice card ---------- */
.inv {
  position: relative;
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  padding: clamp(16px, 4.4vmin, 22px);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 18px 48px -18px rgba(17, 17, 19, 0.16);
}

.inv__head { display: flex; align-items: center; gap: 10px; }
.inv__mark {
  flex: none; width: 28px; height: 28px; padding: 5px; border-radius: 8px;
  background: var(--inchiostro);
  fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.inv__brand { font-size: 14.5px; font-weight: 640; letter-spacing: -0.01em; flex: 1; }
.inv__brand span { color: var(--grigio-chiaro); font-weight: 500; }
.inv__state {
  font-size: 11.5px; font-weight: 600; color: var(--grigio);
  padding: 3px 9px; border-radius: 99px; background: var(--campo); border: 1px solid var(--bordo);
}

.inv__body { margin-top: clamp(14px, 4vmin, 20px); }
.inv__top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.inv__no { font-size: 12px; color: var(--grigio); font-weight: 560; letter-spacing: 0.02em; }
.inv__client { margin-top: 2px; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.inv__amount { font-size: clamp(22px, 6.4vmin, 26px); font-weight: 680; letter-spacing: -0.03em; font-stretch: 94%; }
.inv__meta { margin-top: 6px; font-size: 12px; color: var(--grigio-chiaro); }
.inv__meta span { margin: 0 3px; }

.inv__items { list-style: none; margin-top: clamp(10px, 3vmin, 14px); border-top: 1px solid var(--bordo); }
.inv__items li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: clamp(7px, 2vmin, 9px) 0;
  font-size: 13px; color: var(--grigio);
  border-bottom: 1px solid var(--bordo);
}
.inv__items li span:last-child { color: var(--inchiostro); font-weight: 560; }

.inv__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: clamp(14px, 4vmin, 18px);
}
.inv__file { font-size: 12px; color: var(--grigio-chiaro); white-space: nowrap; }
.inv__file span { margin: 0 2px; }

/* ---------- the button ---------- */
.dl {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px 0 13px;
  border: 0; border-radius: 99px;
  background: var(--inchiostro); color: #fff;
  font: inherit; font-size: 14px; font-weight: 600; font-stretch: 100%;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 8px 18px -8px rgba(17, 17, 19, 0.55);
  transition: box-shadow 0.25s;
}
.dl:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
.dl.is-hover { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 12px 22px -8px rgba(17, 17, 19, 0.6); }
@media (hover: hover) { .dl:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 12px 22px -8px rgba(17, 17, 19, 0.6); } }

.dl__fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.16));
  transform-origin: 0 50%; transform: scaleX(0);
  pointer-events: none;
}
.dl__icon { position: relative; width: 20px; height: 20px; flex: none; }
.dl__icon svg { position: absolute; inset: 0; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.dl__ring, .dl__pdf, .dl__check { opacity: 0; }
.ring__bg { stroke: rgba(255, 255, 255, 0.2); }
.ring__fg { stroke: #fff; transform: rotate(-90deg); transform-origin: 12px 12px; }
.dl__pdf { stroke-width: 1.6; }
.pdf__band { fill: var(--accento); stroke: none; }
.dl__label { position: relative; display: inline-block; }

/* ---------- the sheet ---------- */
.sheet {
  --f: 0px;
  position: absolute;
  left: 50%; top: clamp(58px, 15vmin, 66px);
  width: 152px; height: 198px;
  margin-left: -76px;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  filter: drop-shadow(0 14px 22px rgba(17, 17, 19, 0.16)) drop-shadow(0 2px 4px rgba(17, 17, 19, 0.08));
}
.sheet__paper {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 60% at 20% 0%, rgba(255, 255, 255, 0.9), transparent 60%),
    var(--carta);
  border-radius: 6px;
  padding: 13px 12px 12px;
  clip-path: polygon(0 0, calc(100% - var(--f)) 0, 100% var(--f), 100% 100%, 0 100%);
  overflow: hidden;
}
.sheet__flap {
  position: absolute; right: 0; top: 0;
  width: var(--f); height: var(--f);
  background: linear-gradient(225deg, transparent 50%, #e9e6df 50%, #f6f4ef 78%);
  border-bottom-left-radius: 3px;
  box-shadow: -2px 2px 4px rgba(17, 17, 19, 0.1);
}
.sheet__head { display: flex; justify-content: space-between; align-items: baseline; }
.sheet__brand { font-size: 8.5px; font-weight: 700; letter-spacing: -0.01em; }
.sheet__word { font-size: 7px; font-weight: 600; color: var(--grigio-chiaro); text-transform: uppercase; letter-spacing: 0.12em; }
.sheet__no { margin-top: 10px; font-size: 11px; font-weight: 680; letter-spacing: -0.01em; }
.sheet__to { margin-top: 2px; font-size: 6.6px; color: var(--grigio); }
.sheet__rows { margin-top: 11px; display: grid; gap: 7px; }
.row { position: relative; display: flex; justify-content: space-between; gap: 6px; font-size: 7px; height: 10px; align-items: center; }
.row .sk { position: absolute; left: 0; right: 0; top: 2px; height: 6px; border-radius: 3px; background: #ecebe7; transform-origin: 0 50%; }
.row .tx { color: var(--grigio); }
.row .am { font-weight: 640; }
.sheet__rule { display: block; margin-top: 10px; height: 1px; background: var(--inchiostro); opacity: 0.8; transform-origin: 0 50%; }
.sheet__total { display: flex; justify-content: space-between; margin-top: 6px; font-size: 8.5px; font-weight: 700; }
.sheet__stamp {
  position: absolute; right: 12px; bottom: 30px;
  padding: 2px 6px; border: 1.4px solid var(--accento); border-radius: 4px;
  color: var(--accento); font-size: 8px; font-weight: 760; text-transform: uppercase; letter-spacing: 0.1em;
  transform: rotate(-9deg); opacity: 0;
}
.sheet__tag {
  position: absolute; left: 0; bottom: 34px;
  padding: 6px 14px 6px 12px;
  background: var(--accento); color: #fff;
  font-size: 22px; font-weight: 760; letter-spacing: 0.02em;
  border-radius: 0 6px 6px 0;
}

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

@media (max-width: 360px) {
  .dl { padding: 0 13px 0 11px; font-size: 13px; }
}
