:root {
  --tinta: #2d3f5c;
  --tinta-suave: #5a6a84;
  --menta: #8acbb0;
  --menta-clara: #e3f3ec;
  --menta-osc: #2f7a5e;
  --salmon: #f6a08a;
  --durazno: #f2b880;
  --crema: #fde5c8;
  --fondo: #f5faf8;
  --papel: #ffffff;
  --rojo: #c82a2a;
  --linea: #d5dde5;
  --error: #b3261e;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(45, 63, 92, .08), 0 8px 24px -12px rgba(45, 63, 92, .25);
  /* punto tejido: filas de "V" como en una mantita */
  --tejido: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='16' viewBox='0 0 22 16'%3E%3Cg fill='none' stroke='%238acbb0' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M2 2 L11 13'/%3E%3Cpath d='M20 2 L11 13'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font: 18px/1.5 "Atkinson Hyperlegible", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--menta-osc); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }

/* ---------- franja tejida con el logo ---------- */
.franja {
  height: 92px;
  background: var(--menta-clara) var(--tejido) repeat;
  background-size: 22px 16px;
  border-bottom: 3px solid var(--menta);
}
.sello {
  width: 144px;
  margin: -72px auto 0;
  background: var(--papel);
  border-radius: 50%;
  padding: 22px;
  box-shadow: var(--sombra);
  position: relative;
}
.sello img { width: 100%; height: auto; }

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}
.titulo { text-align: center; margin: 14px 0 26px; }
.titulo h1 { font-size: 1.75rem; letter-spacing: -.01em; }
.titulo p { color: var(--tinta-suave); margin-top: 8px; }

/* ---------- formularios ---------- */
.hoja {
  background: var(--papel);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 22px 18px;
}
.campo { margin-bottom: 20px; }
.campo:last-of-type { margin-bottom: 0; }
label, .etiqueta { display: block; font-weight: 700; margin-bottom: 8px; }
.ayuda { font-size: .88rem; color: var(--tinta-suave); margin-top: 6px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 14px 14px;
  border: 2px solid var(--linea);
  border-radius: 10px;
  background: #fff;
  min-height: 54px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--menta-osc); box-shadow: 0 0 0 3px rgba(47, 122, 94, .18); }
input[aria-invalid="true"] { border-color: var(--error); }

.montos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  font: inherit; font-weight: 700;
  border: 2px solid var(--linea);
  background: #fff;
  color: var(--tinta);
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 46px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.con-signo { position: relative; }
.con-signo span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--tinta-suave); }
.con-signo input { padding-left: 46px; font-weight: 700; }

.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opcion {
  font: inherit; text-align: left;
  border: 2px solid var(--linea);
  background: #fff; color: var(--tinta);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  min-height: 74px;
}
.opcion b { display: block; font-size: 1.05rem; }
.opcion small { color: var(--tinta-suave); font-size: .85rem; }
.opcion[aria-pressed="true"] { border-color: var(--menta-osc); background: var(--menta-clara); box-shadow: inset 0 0 0 1px var(--menta-osc); }

.boton {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  font: inherit; font-weight: 700; font-size: 1.1rem;
  padding: 16px 20px;
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  background: var(--tinta);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.boton:hover { background: #24334b; }
.boton:disabled { opacity: .6; cursor: progress; }
.boton.claro { background: var(--menta-clara); color: var(--tinta); border: 2px solid var(--menta); }
.boton.claro:hover { background: #d3ecdf; }
.boton.wa { background: #1f8f4e; }
.boton.wa:hover { background: #197a42; }
.botones { display: grid; gap: 10px; margin-top: 18px; }
:focus-visible { outline: 3px solid var(--salmon); outline-offset: 2px; }

.error {
  background: #fdecea; color: var(--error);
  border-radius: 10px; padding: 12px 14px; margin-top: 14px; font-weight: 700;
}
.error:empty { display: none; }
.nota { font-size: .9rem; color: var(--tinta-suave); text-align: center; margin-top: 16px; }

/* ---------- esperando el pago ---------- */
.espera { text-align: center; }
.espera .monto-grande { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.espera .quien { color: var(--tinta-suave); }
.pasos { text-align: left; margin: 20px 0 0; padding: 0; list-style: none; counter-reset: p; }
.pasos li { counter-increment: p; position: relative; padding: 0 0 14px 44px; }
.pasos li::before {
  content: counter(p);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--crema); color: var(--tinta);
  font-weight: 700; display: grid; place-items: center;
}
.numero-yappy { font-size: 1.5rem; font-weight: 700; letter-spacing: .02em; }
.ovillo {
  width: 54px; height: 54px; margin: 18px auto 6px;
  border-radius: 50%;
  border: 5px solid var(--menta-clara);
  border-top-color: var(--menta-osc);
  animation: girar 1.1s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.yappy-caja { margin-top: 18px; display: flex; justify-content: center; min-height: 56px; }

/* ---------- el recibo (igual al talonario) ---------- */
.recibo {
  position: relative;
  background: var(--papel);
  border-radius: 6px;
  box-shadow: var(--sombra);
  padding: 30px 18px 22px;
  overflow: hidden;
}
.recibo::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px;
  background: var(--tejido) repeat-x; background-size: 16px 12px;
}
.recibo .cabeza { display: grid; grid-template-columns: 74px 1fr; gap: 14px; align-items: center; }
.recibo .cabeza img { width: 74px; }
.recibo .fundacion b { display: block; font-size: 1rem; letter-spacing: .01em; }
.recibo .fundacion span { display: block; font-size: .78rem; color: var(--tinta-suave); line-height: 1.35; }
.recibo .tira {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px;
  margin: 18px 0 8px; padding-bottom: 10px; border-bottom: 2px solid var(--tinta);
}
.recibo .tira .tipo { font-weight: 700; font-size: .85rem; }
.recibo .num { color: var(--rojo); font-weight: 700; font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.recibo dl { margin: 0; }
.recibo .renglon { padding: 10px 0 8px; border-bottom: 1px solid var(--linea); }
.recibo dt { font-size: .78rem; color: var(--tinta-suave); }
.recibo dd { margin: 2px 0 0; font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.recibo .suma dd { font-size: 1.5rem; }
.recibo .letras { font-weight: 400; font-size: .92rem; color: var(--tinta-suave); display: block; }
.recibo .pagos { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .85rem; color: var(--tinta-suave); }
.recibo .pagos span::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--tinta-suave); border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.recibo .pagos .si { color: var(--tinta); font-weight: 700; }
.recibo .pagos .si::before { background: var(--tinta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E") center/100%; border-color: var(--tinta); }
.recibo .firma { margin-top: 16px; font-size: .85rem; color: var(--tinta-suave); text-align: right; }
.recibo .firma b { color: var(--tinta); }
.anulado-sello {
  position: absolute; top: 46%; left: 50%;
  transform: translate(-50%, -50%) rotate(-14deg);
  border: 5px solid var(--rojo); color: var(--rojo);
  font-weight: 700; font-size: 2.6rem; letter-spacing: .08em;
  padding: 2px 18px; border-radius: 10px; opacity: .75;
  background: rgba(255, 255, 255, .6);
}

.listo { text-align: center; margin-bottom: 18px; }
.listo h1 { font-size: 1.5rem; }
.listo p { color: var(--tinta-suave); margin-top: 4px; }

/* ---------- lanas por color ---------- */
.lanas { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.lana-caja { position: relative; display: grid; }
.lana {
  position: relative;
  font: inherit; color: var(--tinta);
  background: #fff;
  border: 2px solid var(--linea);
  border-radius: 12px;
  padding: 8px 4px 6px;
  min-height: 78px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.lana .bola {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c, #ddd);
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, .12), inset 3px 3px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(45, 63, 92, .15);
}
.lana .n { font-weight: 700; font-size: 1rem; line-height: 1; }
.lana .p { font-size: .72rem; color: var(--tinta-suave); line-height: 1; }
.lana[data-cant] { border-color: var(--menta-osc); background: var(--menta-clara); box-shadow: inset 0 0 0 1px var(--menta-osc); }
.lana[data-cant]::after {
  content: "×" attr(data-cant);
  position: absolute; top: -8px; right: -6px;
  background: var(--tinta); color: #fff;
  font-size: .78rem; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.lana:disabled { opacity: .45; cursor: not-allowed; }
.lana:disabled .p { text-decoration: none; }
.lana-caja .menos {
  position: absolute; top: -8px; left: -6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--salmon); color: var(--tinta);
  font: inherit; font-weight: 700; line-height: 1; cursor: pointer;
}
.total-lanas {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  background: var(--crema); border-radius: 12px; padding: 12px 14px;
}
.total-lanas b { font-size: 1.5rem; grid-row: span 2; }
.total-lanas span { font-size: .9rem; }
.vaciar { justify-self: start; background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--tinta-suave); text-decoration: underline; cursor: pointer; }
.chip.zona { font-weight: 400; padding: 8px 14px; }
.chip.zona[aria-checked="true"] { background: var(--tinta); border-color: var(--tinta); color: #fff; font-weight: 700; }

.oculto { display: none !important; }

@media (min-width: 560px) {
  main { padding-top: 28px; }
  .recibo { padding: 36px 30px 26px; }
  .recibo .cabeza { grid-template-columns: 96px 1fr; }
  .recibo .cabeza img { width: 96px; }
  .recibo .fundacion b { font-size: 1.15rem; }
  .recibo .dos { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ovillo { animation: none; border-top-color: var(--menta); }
}

@media print {
  body { background: #fff; }
  .franja, .sello, .listo, .botones, .nota, .no-imprimir { display: none !important; }
  main { padding: 0; max-width: none; }
  .recibo { box-shadow: none; border: 1px solid var(--linea); }
}
