:root {
  /* Бренд — фиксированные оттенки, не зависят от темы. */
  --burgundy: #7B1E3A;
  --burgundy-light: #9B2E50;
  --burgundy-dark: #5B0E2A;

  --font-display: "Unbounded", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Liberation Mono", Menlo, Consolas, monospace;

  /* Чек — физический объект, лежит на прилавке. Бумага и чернила всегда одного цвета,
     как у настоящего чека — меняется только освещение прилавка (тема). */
  --paper: #faf6ec;
  --paper-text: #2a2420;
  --paper-muted: rgba(42, 36, 32, 0.56);
  --paper-faint: rgba(42, 36, 32, 0.14);
  --ink: var(--burgundy);

  /* Прилавок — тёмное помещение магазина вечером. */
  --counter: #0a0a0a;
  --counter-glow: rgba(155, 46, 80, 0.22);
  --chrome-text: #f5f2f3;
  --chrome-muted: #a8a3a5;
  --chrome-surface: rgba(255, 255, 255, 0.08);

  /* Акцент на прилавке (не на бумаге) — светлее бургунди на тёмном фоне,
     чтобы не "тонуть" в черноте. */
  --counter-accent: var(--burgundy-light);

  color-scheme: dark;
}

[data-theme="light"] {
  /* Светлый прилавок — днём, через витрину. Чек остаётся той же бумагой. */
  --counter: #e9e4dd;
  --counter-glow: rgba(123, 30, 58, 0.1);
  --chrome-text: #1a1a1a;
  --chrome-muted: #6e6e6e;
  --chrome-surface: rgba(0, 0, 0, 0.06);
  --counter-accent: var(--burgundy);

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--counter);
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease;
}

img { max-width: 100%; display: block; }

/* Лёгкое зерно — прилавок не плоский. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.counter-glow {
  position: fixed;
  top: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 70vw;
  max-width: 760px;
  height: 50vh;
  background: radial-gradient(circle, var(--counter-glow), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

/* Плавающие элементы шапки — тема и скачать, без полноценного nav. */
.chrome-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 14px;
  pointer-events: none;
}

.chrome-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--chrome-text);
  opacity: 0.85;
  pointer-events: auto;
}

.chrome-brand img { width: 22px; height: 22px; border-radius: 6px; }

.theme-toggle {
  pointer-events: auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--chrome-surface);
  background: var(--chrome-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--chrome-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Сам чек ---------- */

.receipt-wrap {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(72px + env(safe-area-inset-top, 0px)) 20px calc(48px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 760px) {
  .receipt-wrap { max-width: 640px; }
}

@media (min-width: 1100px) {
  .receipt-wrap { max-width: 860px; }
}

@media (min-width: 1500px) {
  .receipt-wrap { max-width: 1040px; }
}

@media (min-width: 1900px) {
  .receipt-wrap { max-width: 1160px; }
}

/* На широкой бумаге фиксированные по размеру элементы (кнопка, фото) не должны
   просто растягиваться/кучковаться слева — подгоняем, чтобы заполняли ширину разумно. */
@media (min-width: 760px) {
  .btn-total { max-width: 480px; }
  .receipt-photos { justify-content: center; }
}

@media (min-width: 1100px) {
  .receipt-photo { width: 168px; }
  .receipt-step-shot .receipt-photo { width: 150px; }
}

@media (min-width: 1500px) {
  .receipt-photo { width: 190px; }
  .receipt-step-shot .receipt-photo { width: 164px; }
}

/* Углы прилавка на широких экранах — чтобы не было пустой черноты по бокам,
   пока чек один занимает центр. Чисто декоративно, приглушено, не мешает контенту. */
.corner-deco {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  color: var(--counter-accent);
  opacity: 0.45;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--counter-accent) 50%, transparent));
  display: none;
}

.corner-deco svg { display: block; width: 100%; height: 100%; }

@media (min-width: 1020px) {
  .corner-deco { display: block; }
  .corner-deco--tl { top: 14vh; left: 5vw; width: 74px; transform: rotate(-9deg); }
  .corner-deco--tr { top: 16vh; right: 5vw; width: 92px; transform: rotate(7deg); }
  .corner-deco--bl { bottom: 12vh; left: 6vw; width: 84px; transform: rotate(-6deg); }
  .corner-deco--br { bottom: 10vh; right: 5.5vw; width: 78px; transform: rotate(8deg); }
}

@media (min-width: 1300px) {
  .corner-deco--tl { left: 9vw; width: 90px; }
  .corner-deco--tr { right: 9vw; width: 110px; }
  .corner-deco--bl { left: 10vw; width: 98px; }
  .corner-deco--br { right: 9.5vw; width: 92px; }
}

@media (min-width: 1700px) {
  .corner-deco--tl { width: 106px; }
  .corner-deco--tr { width: 128px; }
  .corner-deco--bl { width: 114px; }
  .corner-deco--br { width: 108px; }
}

.receipt {
  position: relative;
}

.receipt-edge {
  height: 14px;
  background: var(--paper);
  -webkit-mask-image: linear-gradient(135deg, transparent 50%, #000 50%), linear-gradient(-135deg, transparent 50%, #000 50%);
  -webkit-mask-size: 14px 14px;
  -webkit-mask-repeat: repeat-x;
  mask-image: linear-gradient(135deg, transparent 50%, #000 50%), linear-gradient(-135deg, transparent 50%, #000 50%);
  mask-size: 14px 14px;
  mask-repeat: repeat-x;
}

.receipt-edge--bottom { transform: scaleY(-1); }

.receipt-body {
  position: relative;
  background: var(--paper);
  color: var(--paper-text);
  font-family: var(--font-mono);
  padding: 8px 28px 32px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.55);
}

/* Лёгкое зерно самой бумаги — чек не идеально гладкий. */
.receipt-body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.receipt-body > * {
  position: relative;
  z-index: 1;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed var(--paper-faint);
  margin: 22px 0;
}

.receipt-center { text-align: center; }

/* Шапка чека */
.receipt-letterhead {
  text-align: center;
  padding-top: 18px;
}

.receipt-store-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 10px;
  border-radius: 12px;
}

.receipt-store-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.receipt-meta {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--paper-muted);
  text-transform: uppercase;
}

.barcode-strip {
  height: 30px;
  margin-top: 14px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--paper-text) 0px, var(--paper-text) 2px,
    transparent 2px, transparent 5px,
    var(--paper-text) 5px, var(--paper-text) 8px,
    transparent 8px, transparent 10px,
    var(--paper-text) 10px, var(--paper-text) 13px,
    transparent 13px, transparent 19px,
    var(--paper-text) 19px, var(--paper-text) 20px,
    transparent 20px, transparent 24px
  );
  opacity: 0.85;
}

/* Hero — единственное место с крупной типографикой display-начертания,
   как заголовок, пробитый кассой жирнее обычной строки. */
.receipt-hero {
  padding-top: 26px;
}

.receipt-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.18;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  max-width: 480px;
}

.receipt-hero p {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--paper-muted);
  margin: 0 0 22px;
  max-width: 420px;
}

.btn-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  padding: 16px 20px;
  border-radius: 10px;
  box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--burgundy) 60%, transparent);
  border: none;
  cursor: pointer;
}

.btn-total span:first-child {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.75;
  text-transform: uppercase;
}

.btn-total span:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-total svg { width: 18px; height: 18px; }

.receipt-version-line {
  margin-top: 10px;
  font-size: 11px;
  color: var(--paper-muted);
  text-align: center;
}

.btn-secondary {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 1px;
  width: fit-content;
  margin-inline: auto;
}

/* Состав — фичи как строки чека */
.receipt-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-muted);
  margin-bottom: 14px;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  padding: 7px 0;
}

.receipt-line-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.receipt-line-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--ink);
  opacity: 0.8;
}

.receipt-line b { font-weight: 600; }

.receipt-line .mark { color: var(--ink); font-weight: 700; flex: 0 0 auto; }

.receipt-line-note {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--paper-muted);
  margin: -2px 0 10px;
  max-width: 430px;
}

.receipt-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 18px;
  padding: 16px 6px;
  border-top: 1px dashed var(--paper-faint);
  border-bottom: 1px dashed var(--paper-faint);
}

.receipt-stat {
  text-align: center;
  padding: 0 6px;
  border-right: 1px dashed var(--paper-faint);
}

.receipt-stat:last-child { border-right: none; }

/* Тарифы — строки цен, как в настоящем чеке: название товара слева, цена справа. */
.price {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
  flex: 0 0 auto;
}

.price small {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 3px;
}

.price-highlight {
  position: relative;
  margin: 6px -14px 14px;
  padding: 14px 14px 12px;
  border: 1px dashed var(--ink);
  border-radius: 8px;
}

.price-highlight .receipt-line { padding: 0 0 6px; }

.price-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}

.receipt-pricing-note {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--paper-muted);
  margin-top: 4px;
}

.receipt-stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
}

.receipt-stat span {
  display: block;
  font-size: 9.5px;
  color: var(--paper-muted);
  margin-top: 3px;
  line-height: 1.3;
}

/* Фото с витрины — приклеенные скриншоты */
.receipt-photos {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 18px 6px 10px;
  margin: 0 -6px;
  -webkit-overflow-scrolling: touch;
}

.receipt-photo {
  position: relative;
  flex: 0 0 auto;
  width: clamp(128px, 36vw, 150px);
}

.receipt-photo-frame {
  position: relative;
  aspect-ratio: 1080 / 2400;
  background: #050505;
  border-radius: 20px;
  padding: 7px;
  box-shadow: 0 14px 28px -10px rgba(0, 0, 0, 0.45);
}

.receipt-photo-frame::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 11px;
  background: #050505;
  border-radius: 0 0 8px 8px;
  z-index: 2;
}

.receipt-photo-screen {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.receipt-photo-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.receipt-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  width: 54px;
  height: 20px;
  background: rgba(250, 240, 200, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.3);
  z-index: 3;
}

.receipt-photo:nth-child(even) .receipt-tape { transform: translateX(-50%) rotate(3deg); }

.receipt-photo-caption {
  text-align: center;
  font-size: 10.5px;
  color: var(--paper-muted);
  margin-top: 8px;
}

/* Инструкция */
.receipt-step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  font-size: 13.5px;
  line-height: 1.55;
}

.receipt-step-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  flex: 0 0 auto;
  font-size: 13px;
  padding-top: 1px;
}

.receipt-step b { font-weight: 600; }

.receipt-step-shot {
  margin: 10px 0 4px 32px;
}

.receipt-step-shot .receipt-photo { width: clamp(118px, 34vw, 140px); }

.receipt-step-shot-caption {
  font-family: var(--font-body);
  font-size: 10.5px;
  color: var(--paper-muted);
  margin-top: 6px;
}

/* iOS строка */
.receipt-ios-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 4px 0 14px;
}

.receipt-ios-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--paper-muted);
  border: 1px dashed var(--paper-faint);
  padding: 3px 9px;
  border-radius: 999px;
}

.receipt-ios-note {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--paper-muted);
  margin-top: -6px;
  max-width: 420px;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--paper-faint);
  padding: 9px 14px;
  border-radius: 999px;
}

.btn-whatsapp svg { width: 14px; height: 14px; }

/* Подвал чека */
.receipt-footer {
  text-align: center;
  padding-top: 6px;
}

.receipt-thanks {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.receipt-footer p {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--paper-muted);
  margin: 0 0 16px;
}

.receipt-footer-version {
  font-size: 10.5px;
  color: var(--paper-muted);
  letter-spacing: 0.04em;
}

@media (min-width: 620px) {
  .receipt-body { padding: 8px 40px 40px; }
}

/* Маленькие телефоны (iPhone SE и похожие) — четыре колонки статистики и
   кнопка с длинным текстом уже не помещаются без переразбивки. */
@media (max-width: 380px) {
  .receipt-wrap { padding-left: 14px; padding-right: 14px; }
  .receipt-body { padding-left: 18px; padding-right: 18px; }

  .receipt-stats {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 12px;
  }

  .receipt-stat:nth-child(2n) { border-right: none; }

  .btn-total {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .btn-total span:last-child { font-size: 14px; }

  .receipt-ios-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .receipt-step-shot { margin-left: 20px; }
}
