/* Stage that holds the live preview receipt */
.stage { padding: 20px 0 10px; }
.stage[hidden] { display: none; }
.stage:not([hidden]) { animation: stagefade 350ms ease; }
@keyframes stagefade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.receipt-wrap {
  display: flex;
  justify-content: center;
  perspective: 1500px;
  padding: 30px 0 20px;
}

.receipt {
  background: var(--paper);
  color: var(--paper-ink);
  font-family: 'VT323', 'Courier New', monospace;
  width: 760px;
  max-width: calc(100vw - 32px);
  padding: 36px 40px 30px;
  position: relative;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.55)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.018) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.05), transparent 60%);
  transform: rotate(-0.5deg);
  font-size: 21px;
  line-height: 1.25;
  clip-path: polygon(
    0% 6px, 5% 0, 10% 6px, 15% 0, 20% 6px, 25% 0, 30% 6px, 35% 0,
    40% 6px, 45% 0, 50% 6px, 55% 0, 60% 6px, 65% 0, 70% 6px, 75% 0,
    80% 6px, 85% 0, 90% 6px, 95% 0, 100% 6px,
    100% calc(100% - 6px), 95% 100%, 90% calc(100% - 6px), 85% 100%,
    80% calc(100% - 6px), 75% 100%, 70% calc(100% - 6px), 65% 100%,
    60% calc(100% - 6px), 55% 100%, 50% calc(100% - 6px), 45% 100%,
    40% calc(100% - 6px), 35% 100%, 30% calc(100% - 6px), 25% 100%,
    20% calc(100% - 6px), 15% 100%, 10% calc(100% - 6px), 5% 100%,
    0 calc(100% - 6px)
  );
}
.receipt-wrap .receipt { animation: print 700ms cubic-bezier(0.2, 0.9, 0.25, 1); }
@keyframes print {
  from { transform: translateY(-30px) rotate(-0.5deg); opacity: 0; }
  to { transform: translateY(0) rotate(-0.5deg); opacity: 1; }
}

.r-head { text-align: center; }
.r-head .logo { font-size: 36px; letter-spacing: 0.05em; font-weight: bold; }
.r-head .sub { font-size: 20px; letter-spacing: 0.3em; margin-top: 2px; }
.r-head .meta { font-size: 17px; margin-top: 8px; letter-spacing: 0.04em; opacity: 0.85; }
.r-head .meta.mode { letter-spacing: 0.08em; }
.r-head .meta.mode .warn { color: #b54a1c; }

.divider { border-top: 1px dashed var(--paper-ink); margin: 10px -2px; opacity: 0.5; }
.divider.solid { border-top: 1.5px solid var(--paper-ink); opacity: 0.85; }

/* Two-column body layout — keeps receipt short & wide enough for phones */
.r-body {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.r-body .col {
  flex: 1 1 0;
  min-width: 0;
}
.r-body .col + .col {
  border-left: 1px dashed var(--paper-ink);
  padding-left: 28px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 21px;
  margin: 0;
  white-space: nowrap;
}
.row.big { font-size: 26px; font-weight: bold; margin: 6px 0; }
.row .leader {
  flex: 1;
  border-bottom: 1.5px dotted var(--paper-ink);
  margin-bottom: 5px;
  opacity: 0.45;
  align-self: flex-end;
  height: 2px;
  min-width: 8px;
}
.row .key { white-space: nowrap; flex-shrink: 0; }
.row .val { white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.sub-row {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  padding-left: 16px;
  opacity: 0.85;
  margin: 0;
  gap: 8px;
  white-space: nowrap;
}
.sub-row .k { flex: 0 1 auto; }
.sub-row .v { font-variant-numeric: tabular-nums; flex-shrink: 0; }

.note {
  font-size: 16px;
  text-align: center;
  opacity: 0.7;
  margin: 2px 0 4px;
  font-style: italic;
}

.section-title {
  font-size: 18px;
  letter-spacing: 0.2em;
  text-align: center;
  margin: 6px 0 6px;
  font-weight: bold;
}

.barcode {
  margin: 14px auto 4px;
  display: flex;
  gap: 0;
  height: 40px;
  justify-content: center;
  align-items: stretch;
}
.barcode span { display: block; }

.serial { text-align: center; font-size: 17px; letter-spacing: 0.25em; margin-top: 4px; }

.r-foot { text-align: center; font-size: 17px; margin-top: 14px; line-height: 1.45; }
.r-foot .stars { letter-spacing: 0.4em; font-size: 19px; }
.r-foot .smol { font-size: 13px; margin-top: 12px; opacity: 0.55; line-height: 1.45; }

/* Mobile: stack the two columns and shrink the receipt */
@media (max-width: 720px) {
  .receipt {
    width: 100%;
    max-width: 92vw;
    font-size: 17px;
    padding: 26px 22px 22px;
    transform: rotate(-0.3deg);
  }
  .r-body { flex-direction: column; gap: 0; }
  .r-body .col + .col {
    border-left: none;
    border-top: 1px dashed var(--paper-ink);
    padding-left: 0;
    padding-top: 12px;
    margin-top: 12px;
  }
  .row { font-size: 17px; }
  .row.big { font-size: 20px; }
  .sub-row { font-size: 14px; }
  .r-head .logo { font-size: 28px; }
  .r-head .sub { font-size: 16px; }
}
