:root {
  --fondo: #f2f2f3;
  --card: #ffffff;
  --inchiostro: #141416;
  --grigio: #6f6f77;
  --grigio-chiaro: #a9a9b1;
  --bordo: rgba(20, 20, 22, 0.09);
  --campo: #f6f6f7;
  --accento: #17804c;
  --accento-chiaro: #e8f5ee;
  --accento-bordo: rgba(23, 128, 76, 0.45);
  --accento-velo: rgba(23, 128, 76, 0.12);
  --errore: #d6392b;
  --pic-a: #efe6d8;
  --pic-b: #dfe5d6;
}

* { 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: start center;
  padding: 14px;
  overflow: hidden;
}

.sum {
  width: min(372px, 100%);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  padding: clamp(14px, 3.6vmin, 22px);
  box-shadow: 0 1px 2px rgba(20, 20, 22, 0.04), 0 24px 54px -26px rgba(20, 20, 22, 0.22);
}

.sum__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sum__brand { font-size: 13.5px; font-weight: 660; letter-spacing: -0.01em; }
.sum__crumb { color: var(--grigio-chiaro); font-weight: 500; }
.sum__title { font-size: 12px; color: var(--grigio); }

.items { list-style: none; margin-top: clamp(10px, 2.6vmin, 16px); display: grid; gap: clamp(6px, 1.6vmin, 10px); }
.item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.item__pic {
  width: clamp(32px, 8vmin, 38px); height: clamp(32px, 8vmin, 38px);
  border-radius: 10px;
  display: grid; place-items: center;
}
.item__pic--a { background: var(--pic-a); }
.item__pic--b { background: var(--pic-b); }
.item__pic svg { width: 60%; height: 60%; fill: none; stroke: rgba(20, 20, 22, 0.55); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.item__txt { display: grid; min-width: 0; }
.item__name { font-size: 13px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__meta { font-size: 11.5px; color: var(--grigio); }
.item__price { font-size: 13px; font-weight: 560; }

/* the promo area: the field and the chip share the same place */
.promo { position: relative; margin-top: clamp(12px, 3vmin, 18px); }

.field {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 44px;
  padding: 0 4px 0 11px;
  border-radius: 12px;
  background: var(--campo);
  border: 1px solid var(--bordo);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.field.is-focus { background: #fff; border-color: rgba(20, 20, 22, 0.24); box-shadow: 0 0 0 4px rgba(20, 20, 22, 0.05); }
.field.is-wrong { background: #fff; border-color: var(--errore); box-shadow: 0 0 0 4px rgba(214, 57, 43, 0.11); }
.field__icon { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--grigio); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.field.is-wrong .field__icon { stroke: var(--errore); }

.field__text {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  height: 100%;
  font-size: 14px; font-weight: 560;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}
.field__ph { position: absolute; left: 0; color: var(--grigio-chiaro); font-weight: 480; letter-spacing: 0; }
.field__typed { display: inline-flex; }
.field__typed span { display: inline-block; }
.caret { display: inline-block; width: 1.5px; height: 18px; margin-left: 1px; background: var(--inchiostro); border-radius: 1px; opacity: 0; }

.field__input {
  position: absolute; inset: 0;
  width: calc(100% - 84px);
  opacity: 0;
  font-size: 16px;
  border: 0;
  cursor: text;
}

.apply {
  position: relative;
  flex: none;
  height: 34px; min-width: 72px;
  padding: 0 14px;
  border: 0; border-radius: 9px;
  background: #e7e7ea;
  color: #9b9ba3;
  font: inherit; font-size: 13px; font-weight: 620;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}
.apply.is-ready { background: var(--inchiostro); color: #fff; }
.apply__label { display: inline-block; }
.apply__spin {
  position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  fill: none; stroke-width: 2.2; stroke-linecap: round;
  opacity: 0;
}
.apply__spin circle { stroke: rgba(255, 255, 255, 0.25); }
.apply__spin path { stroke: #fff; }

.chip {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  height: 44px;
  padding: 0 6px 0 11px;
  border-radius: 12px;
  background: var(--accento-chiaro);
  border: 1px dashed var(--accento-bordo);
  color: var(--accento);
  white-space: nowrap;
  visibility: hidden;
}
.chip__icon { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--accento); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chip__code { font-size: 13.5px; font-weight: 680; letter-spacing: 0.06em; }
.chip__save { font-size: 13px; font-weight: 560; opacity: 0.85; }
.chip__x {
  display: grid; place-items: center;
  width: 28px; height: 28px; margin-left: 2px;
  border: 0; border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}
.chip__x svg { width: 14px; height: 14px; fill: none; stroke: var(--accento); stroke-width: 2; stroke-linecap: round; }

.error {
  display: flex; align-items: center; gap: 6px;
  height: 0; overflow: hidden;
  font-size: 12px; color: var(--errore);
  opacity: 0;
}
.error svg { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--errore); stroke-width: 1.8; stroke-linecap: round; }

.lines { margin-top: clamp(12px, 3vmin, 18px); border-top: 1px solid var(--bordo); padding-top: clamp(8px, 2.2vmin, 12px); }
.line { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--grigio); line-height: 1; padding: clamp(4px, 1.1vmin, 6px) 0; }
.line dd { color: var(--inchiostro); font-weight: 520; }
.line--disc { display: block; height: 0; padding: 0; overflow: hidden; }
.line__in { display: flex; justify-content: space-between; align-items: center; padding: clamp(4px, 1.1vmin, 6px) 0; }
.line__code { display: inline-block; margin-left: 4px; padding: 2px 6px; border-radius: 6px; background: var(--accento-chiaro); color: var(--accento); font-size: 10.5px; font-weight: 660; letter-spacing: 0.06em; }
.line dd.line__neg { color: var(--accento); }
.line--total { margin-top: 4px; padding-top: clamp(8px, 2.2vmin, 12px); border-top: 1px solid var(--bordo); color: var(--inchiostro); font-size: 14px; font-weight: 620; }

/* the total: every digit sits on its own wheel, each wheel one fixed width wide */
.total { display: inline-flex; align-items: center; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; height: 1.15em; overflow: hidden; }
.total .ch { display: inline-block; text-align: center; }
.total .wheel { display: inline-block; position: relative; width: 0.6em; height: 1.15em; overflow: hidden; }
.total .wheel__strip { position: absolute; left: 0; top: 0; width: 100%; display: flex; flex-direction: column; }
.total .wheel__strip span { display: block; height: 1.15em; line-height: 1.15em; text-align: center; }

.saved { height: 0; overflow: hidden; text-align: right; font-size: 11.5px; color: var(--accento); font-weight: 560; opacity: 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.pointer {
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px;
  fill: #111; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  opacity: 0;
  pointer-events: none;
  z-index: 50;
}

@media (hover: hover) {
  .apply.is-ready:hover { background: #2a2a2e; }
  .chip__x:hover { background: var(--accento-velo); }
}
