@font-face {
  font-family: 'Century Gothic';
  src: url('fonts/centurygothic.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Actay Wide';
  src: url('fonts/ActayWide-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --font-body: 'Century Gothic', system-ui, -apple-system, sans-serif;
  --font-head: 'Actay Wide', 'Century Gothic', system-ui, sans-serif;
  --bg: #0a0a0b;
  --surface: #131316;
  --surface-2: #1c1c20;
  --stroke: #2a2a30;
  --stroke-strong: #3a3a42;
  --text: #f5f5f7;
  --muted: #8a8a93;
  --muted-2: #5e5e66;
  --accent: #ffffff;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 18px 16px 48px;
  max-width: 520px;
  margin: 0 auto;
}

/* Заголовочный шрифт Actay Wide */
.brand-text strong,
.card-code,
.stat-value,
.qr-timer,
.stats-row b,
.discount-banner strong,
.progress-head strong {
  font-family: var(--font-head);
  font-weight: 700;
}

/* Топбар */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 54px; height: 54px; border-radius: 12px; object-fit: contain;
  background: #fff; padding: 4px; display: block;
}
.brand-text strong { font-size: 16px; font-weight: 600; display: block; line-height: 1.1; letter-spacing: -0.01em; }
.brand-text small { color: var(--muted); font-size: 12px; }
.brand-badge {
  border: 1px solid var(--stroke-strong); color: var(--muted);
  font-weight: 500; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px;
}

/* Табы */
.tabs {
  position: relative; display: flex; background: var(--surface);
  border: 1px solid var(--stroke); border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.tab {
  flex: 1; border: none; background: none; color: var(--muted);
  font-family: inherit; font-weight: 500; font-size: 14px; padding: 9px;
  border-radius: 9px; cursor: pointer; position: relative; z-index: 2; transition: color 0.2s;
}
.tab.is-active { color: var(--bg); }
.tab-glider {
  position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 9px;
  background: var(--accent); z-index: 1;
  transition: transform 0.3s cubic-bezier(0.4, 0.8, 0.3, 1), width 0.3s;
}

/* Вьюхи */
.view { display: none; animation: fade 0.3s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Карточки */
.card {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 20px; margin-bottom: 12px;
}
.card-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.card-hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.card-hint b { color: var(--text); font-weight: 600; }

/* Карта клиента */
.client-card { display: flex; gap: 18px; align-items: center; }
.qr-wrap { flex-shrink: 0; }
.qr-frame {
  position: relative; width: 108px; height: 108px; border-radius: 12px; padding: 9px;
  background: #ffffff; display: grid; place-items: center; transition: opacity 0.25s;
}
.qr-frame img { width: 100%; height: 100%; display: block; }
.qr-frame.expired img { opacity: 0.12; }
.qr-expired {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #0a0a0b; font-size: 13px; font-weight: 600; text-align: center;
}

/* Статус QR / таймер */
.qr-status-card { display: flex; align-items: center; justify-content: space-between; }
.qr-timer { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 6px; letter-spacing: 0.02em; }
.qr-timer.expired { color: var(--muted); }
.qr-status-card .btn { padding: 11px 16px; }
.card-meta { min-width: 0; }
.card-code {
  font-weight: 700; font-size: 38px; line-height: 1.05; letter-spacing: 0.04em;
  color: var(--text); margin: 6px 0; font-variant-numeric: tabular-nums;
}

/* Статы */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .card { margin-bottom: 0; }
.stat-value { font-weight: 700; font-size: 26px; margin: 10px 0 2px; letter-spacing: -0.02em; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }

/* Прогресс */
.progress-card { margin-top: 12px; }
.progress-head { margin-bottom: 6px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.progress-head strong { font-size: 15px; font-weight: 600; }
.progress-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.progress-count {
  flex-shrink: 0; font-family: var(--font-head); font-size: 18px; font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.progress-count small { color: var(--muted); font-weight: 400; }

/* Степпер */
.steps { display: flex; align-items: center; margin: 20px 0 14px; }
.step { display: flex; align-items: center; }
.step:not(:last-child) { flex: 1; }
.node {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--stroke); color: var(--muted); background: var(--surface-2);
  font-variant-numeric: tabular-nums; transition: all 0.4s cubic-bezier(0.4, 0.8, 0.3, 1);
}
.node.reward { width: auto; height: 30px; padding: 0 12px; border-radius: 999px; border-style: dashed; border-color: var(--stroke-strong); color: var(--text); }
.node.filled { background: var(--accent); border-color: var(--accent); color: var(--bg); transform: scale(1.08); }
.link { flex: 1; height: 2px; background: var(--stroke); margin: 0 6px; border-radius: 2px; transition: background 0.5s; }
.link.filled { background: var(--accent); }

/* Баннер скидки */
.discount-banner {
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
  background: var(--accent); color: var(--bg);
}
.discount-banner strong { font-size: 15px; font-weight: 700; display: block; }
.discount-banner p { font-size: 13px; margin-top: 3px; color: #3a3a42; }

/* История */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.timeline li {
  display: flex; gap: 14px; align-items: center; background: var(--surface);
  border: 1px solid var(--stroke); border-radius: 12px; padding: 14px 16px;
  animation: fade 0.35s ease both;
}
.tl-marker { width: 8px; height: 8px; border-radius: 50%; background: var(--text); flex-shrink: 0; }
.tl-marker.muted { background: var(--muted-2); }
.tl-body { flex: 1; min-width: 0; }
.tl-body strong { font-size: 14px; font-weight: 600; }
.tl-body span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-amount { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.tl-amount.muted { color: var(--muted); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty p { font-size: 14px; }

/* Касса */
.field-label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin: 18px 0 8px; }
.muted-note { color: var(--muted-2); font-weight: 400; }
.code-input { display: flex; gap: 8px; margin-top: 10px; }
.code-input input {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--stroke);
  border-radius: 11px; padding: 13px 15px; color: var(--text); font-family: inherit;
  font-size: 18px; font-weight: 600; letter-spacing: 0.06em; outline: none; transition: border-color 0.2s;
  font-variant-numeric: tabular-nums;
}
.code-input input:focus { border-color: var(--stroke-strong); }
.code-input input::placeholder { color: var(--muted-2); font-weight: 400; }

.btn {
  border: 1px solid transparent; border-radius: 11px; padding: 13px 18px; font-family: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: opacity 0.15s, transform 0.1s; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--stroke-strong); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--stroke-strong); width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.form-error { color: var(--text); font-size: 13px; margin-top: 12px; opacity: 0.7; }

.btn-scan {
  width: 100%; margin-top: 10px; background: transparent; color: var(--text);
  border: 1px solid var(--stroke-strong);
}

/* Оверлей сканера */
.scan-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 8, 10, 0.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px;
}
.scan-stage { position: relative; width: min(80vw, 320px); aspect-ratio: 1; border-radius: 20px; overflow: hidden; background: #000; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 14%; border: 2px solid #fff; border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.scan-hint { color: var(--muted); font-size: 14px; text-align: center; }
.scan-overlay .btn { min-width: 160px; }

.client-found {
  display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border-radius: 12px; padding: 14px; margin-top: 18px; border: 1px solid var(--stroke);
}
.cf-avatar {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: var(--bg); background: var(--accent); flex-shrink: 0;
}
.cf-info { flex: 1; min-width: 0; }
.cf-info strong { font-size: 15px; font-weight: 600; }
.cf-info span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.cf-discount {
  border: 1px solid var(--stroke-strong); color: var(--text); font-weight: 600;
  padding: 6px 11px; border-radius: 999px; font-size: 13px;
}

.stats-card .stats-row { display: flex; gap: 8px; margin-top: 14px; }
.stats-row > div { flex: 1; text-align: center; background: var(--surface-2); border-radius: 11px; padding: 14px 8px; border: 1px solid var(--stroke); }
.stats-row b { font-weight: 700; font-size: 20px; display: block; letter-spacing: -0.02em; }
.stats-row span { color: var(--muted); font-size: 11px; }

/* Лоадер */
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 60px 0; color: var(--muted); }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--stroke); border-top-color: var(--text); animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Тост */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 200%);
  background: var(--surface); border: 1px solid var(--stroke-strong); color: var(--text);
  padding: 13px 20px; border-radius: 12px; font-weight: 500; font-size: 14px;
  z-index: 50; max-width: 90%; text-align: center;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.4, 0.8, 0.3, 1), opacity 0.3s, visibility 0.3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; }
.toast.accent { background: var(--accent); color: var(--bg); border-color: var(--accent); }
