/* ============================================================
   «Гимназия Фитнес» — Telegram Mini App
   Дизайн «АТЛЕТИКА»: тёмная editorial-тема, фиксированная.
   Палитра форсируется через бренд-переменные и НЕ зависит
   от темы Telegram (tg theme vars оставлены как fallback).
   ============================================================ */

:root {
  /* Бренд-палитра (форсированная тёмная тема) */
  --c-base:        #0E0F11;  /* глубокий графит / почти-чёрный */
  --c-base-2:      #16181C;  /* фон на тон светлее */
  --c-surface:     #1C1F24;  /* поверхности (строки, карточки) */
  --c-surface-2:   #23272E;  /* поверхность при hover/active */
  --c-text:        #F2F3F5;  /* off-white основной текст */
  --c-muted:       #8A8F98;  /* приглушённый текст */
  --c-faint:       #5B616B;  /* совсем тихий текст */
  --c-accent:      #C8FF00;  /* энергичный лайм / шартрез */
  --c-accent-soft: rgba(200, 255, 0, 0.12);
  --c-on-accent:   #0E0F11;  /* текст на акценте */
  --c-line:        rgba(255, 255, 255, 0.08);  /* hairline-разделители */
  --c-line-strong: rgba(255, 255, 255, 0.14);

  /* State-цвета */
  --c-ok:    #B6F500;
  --c-err:   #FF5247;
  --c-warn:  #FFB020;

  /* Tg fallback (на случай контекстов, где переменные не заданы) */
  --tg-fallback-bg: var(--tg-theme-bg-color, var(--c-base));

  --font-head: "Oswald", "Archivo Narrow", -apple-system, sans-serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius:  14px;
  --radius-l: 20px;
  --pad: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-base);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* лёгкий тематический градиент-фон под графит */
  background:
    radial-gradient(120% 60% at 85% -10%, rgba(200,255,0,0.06), transparent 60%),
    var(--c-base);
  min-height: 100vh;
}

::selection { background: var(--c-accent); color: var(--c-on-accent); }

/* ---------- Иконки (line-SVG) ---------- */
.ico {
  width: 1.4em;
  height: 1.4em;
  display: inline-block;
  vertical-align: middle;
  flex: none;
  color: currentColor;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(14, 15, 17, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--c-line);
  padding: var(--safe-top) 18px 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
  padding: 13px 0;
}
.club { display: flex; align-items: center; gap: 12px; min-width: 0; }
.club-mark {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--c-accent);
  color: var(--c-on-accent);
}
.club-mark .ico { width: 24px; height: 24px; }
.club-text { min-width: 0; }
.club-name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--c-text);
}
.club-name-accent { color: var(--c-accent); margin-left: 5px; }
.club-sub {
  font-size: 12.5px;
  color: var(--c-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--c-warn);
  border: 1px solid rgba(255, 176, 32, 0.4);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.demo-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-warn);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.18);
}
/* Вариант АДМИН: акцентный (лайм), отличается от янтарного ДЕМО. */
.demo-badge.admin {
  color: var(--c-accent, #C8FF00);
  border-color: rgba(200, 255, 0, 0.4);
}
.demo-badge.admin .dot {
  background: var(--c-accent, #C8FF00);
  box-shadow: 0 0 0 3px rgba(200, 255, 0, 0.18);
}

/* ============================================================
   LAYOUT
   ============================================================ */
main {
  padding: 18px 18px calc(96px + var(--safe-bottom));
  max-width: 680px;
  margin: 0 auto;
}

/* Stagger reveal */
.tab-panel > * { animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tab-panel > * { animation: none !important; }
}

/* Микро-лейблы разделов */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin: 26px 2px 12px;
}
.eyebrow .ico { width: 18px; height: 18px; color: var(--c-accent); }
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--c-line);
  margin-left: 4px;
}
.eyebrow:first-child { margin-top: 4px; }

/* ============================================================
   HERO (кабинет)
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-l);
  background:
    linear-gradient(155deg, #1d2126 0%, #131519 70%);
  border: 1px solid var(--c-line);
  padding: 22px 22px 24px;
  margin-bottom: 6px;
}
.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.9;
}
.hero-bg svg { position: absolute; right: -30px; top: -10px; width: 230px; height: 230px; }
.hero-eyebrow {
  font-family: var(--font-head);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 8px;
}
.hero-name {
  position: relative;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(30px, 9vw, 44px);
  line-height: 0.98;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--c-text);
  margin: 0;
  max-width: 70%;
}
.hero-tag {
  position: relative;
  margin-top: 12px;
  font-size: 13px;
  color: var(--c-muted);
  max-width: 75%;
}

/* ============================================================
   STATS — крупные числа стадионным шрифтом
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--c-line);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 14px 0 4px;
}
.stat {
  background: var(--c-surface);
  padding: 18px 16px 16px;
  position: relative;
}
.stat-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--c-muted);
  margin-bottom: 10px;
}
.stat-head .ico { width: 16px; height: 16px; color: var(--c-accent); }
.stat-lbl {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.stat-val {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 38px;
  line-height: 1;
  color: var(--c-text);
  letter-spacing: 0.01em;
}
.stat-val .unit {
  font-size: 16px;
  color: var(--c-muted);
  font-weight: 500;
  margin-left: 4px;
}

/* ============================================================
   СТРОКИ (абонементы, история) — hairline editorial
   ============================================================ */
.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--c-line);
}
.row:first-child { border-top: 1px solid var(--c-line); }
.row-main { min-width: 0; flex: 1; }
.row-title {
  font-weight: 600;
  font-size: 15.5px;
  color: var(--c-text);
  letter-spacing: 0.005em;
}
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--c-muted);
}
.row-meta .m { display: inline-flex; align-items: center; gap: 6px; }
.row-meta .m .ico { width: 14px; height: 14px; color: var(--c-faint); }
.row-meta b {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  color: var(--c-text);
  letter-spacing: 0.02em;
}
.row-aside { text-align: right; flex: none; }

/* ============================================================
   BADGE / STATUS PILL
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-head);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .ico { width: 13px; height: 13px; }
.badge.active, .badge.paid {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  border-color: rgba(200, 255, 0, 0.25);
}
.badge.pending {
  background: rgba(255, 176, 32, 0.12);
  color: var(--c-warn);
  border-color: rgba(255, 176, 32, 0.3);
}
.badge.expired, .badge.inactive, .badge.failed {
  background: rgba(255, 82, 71, 0.12);
  color: var(--c-err);
  border-color: rgba(255, 82, 71, 0.28);
}

/* ============================================================
   КАТАЛОГ
   ============================================================ */
.svc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--c-line);
}
.svc:first-of-type { border-top: 1px solid var(--c-line); }
.svc-main { min-width: 0; flex: 1; }
.svc-name {
  font-weight: 600;
  font-size: 15.5px;
  color: var(--c-text);
}
.svc-dur {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--c-muted);
}
.svc-dur .ico { width: 14px; height: 14px; color: var(--c-faint); }
.svc-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: none;
}
.svc-price {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 26px;
  line-height: 1;
  color: var(--c-text);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.svc-price .cur { font-size: 15px; color: var(--c-muted); margin-left: 3px; }

/* ============================================================
   КНОПКА
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--c-accent);
  color: var(--c-on-accent);
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.96); }
.btn:disabled {
  background: var(--c-surface-2);
  color: var(--c-muted);
  cursor: default;
  filter: none;
}

/* ============================================================
   СЕГМЕНТ-КОНТРОЛ ПЕРИОДА (Неделя / Месяц / Всё время)
   ============================================================ */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 12px;
}
.segmented .seg {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 9px 8px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented .seg:hover { color: var(--c-text); }
.segmented .seg.active {
  background: var(--c-accent);
  color: var(--c-on-accent);
}

/* ============================================================
   ПРИВЯЗКА ТЕЛЕФОНА (форма)
   ============================================================ */
.link-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.link-label {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.input {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 17px;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.input:focus {
  border-color: var(--c-accent);
  background: var(--c-surface-2);
}
.input::placeholder { color: var(--c-faint); }
.link-submit {
  justify-content: center;
  width: 100%;
  padding: 14px 16px;
}
.link-err {
  color: var(--c-err);
  font-size: 14px;
  text-align: center;
}

/* ============================================================
   СОСТОЯНИЯ: loading / empty / error
   ============================================================ */
.state {
  text-align: center;
  color: var(--c-muted);
  padding: 56px 20px;
}
.state .state-ico {
  display: inline-flex;
  width: 56px; height: 56px;
  align-items: center; justify-content: center;
  border-radius: 16px;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  margin-bottom: 16px;
  color: var(--c-faint);
}
.state .state-ico .ico { width: 28px; height: 28px; }
.state-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text);
}
.state-sub { font-size: 13px; margin-top: 6px; }
.state.error .state-ico { color: var(--c-err); border-color: rgba(255,82,71,0.3); }
.state.error .state-title { color: var(--c-err); }

.spinner {
  width: 30px; height: 30px;
  border: 2.5px solid var(--c-line-strong);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.4s; }
}

/* ============================================================
   TABBAR
   ============================================================ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(14, 15, 17, 0.9);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--c-line);
  padding: 6px 6px var(--safe-bottom);
  z-index: 40;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--c-muted);
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  transition: color 0.18s ease;
}
.tab-ico { display: inline-flex; }
.tab-ico .ico { width: 24px; height: 24px; transition: transform 0.18s ease; }
.tab.active { color: var(--c-accent); }
.tab.active .tab-ico .ico { transform: translateY(-1px); }
.tab.active::before {
  content: "";
  position: absolute;
  top: -6px;
  width: 26px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--c-accent);
  box-shadow: 0 0 12px rgba(200, 255, 0, 0.5);
}

/* ============================================================
   КАРТОЧКА АБОНЕМЕНТА — читаемая иерархия (задача B)
   ============================================================ */
.subs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sub-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}
.sub-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--c-accent);
  opacity: 0.85;
}
.sub-card.is-soon::before { background: var(--c-warn); }

.sub-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sub-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: var(--c-text);
  text-transform: uppercase;
}
.sub-top .badge { margin-top: 2px; }

.sub-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  align-items: flex-end;
}
.sub-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}
.sub-num {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 40px;
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--c-accent);
}
.sub-metric.warn .sub-num { color: var(--c-warn); }
.sub-num.sub-inf { color: var(--c-text); }
.sub-unit {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.sub-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-warn);
}
.sub-note .ico { width: 15px; height: 15px; color: var(--c-warn); }

.sub-foot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--c-faint);
}
.sub-foot .ico { width: 14px; height: 14px; color: var(--c-faint); }
.sub-note + .sub-foot { margin-top: 8px; }

/* ============================================================
   ПРОПУСК (QR) — задача A
   ============================================================ */
.pass-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-l);
  padding: 22px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.qr-frame {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
.qr-svg { display: block; width: 100%; height: 100%; }

.pass-meta {
  width: 100%;
  margin: 20px 0 4px;
  display: flex;
  flex-direction: column;
}
.pass-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--c-line);
}
.pass-row:first-child { border-top: 1px solid var(--c-line); }
.pass-lbl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.pass-lbl .ico { width: 16px; height: 16px; color: var(--c-accent); }
.pass-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
}
.pass-val.mono {
  font-family: var(--font-head);
  letter-spacing: 0.12em;
  color: var(--c-accent);
}

.pass-scan {
  width: 100%;
  justify-content: center;
  padding: 15px 16px;
  margin-top: 18px;
  font-size: 14px;
}
.pass-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--c-faint);
  text-align: center;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-line-strong);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 100;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Кнопка отмены неоплаченной покупки в истории */
.cancel-btn {
  margin-top: 8px;
  background: transparent;
  color: var(--danger, #FF5247);
  border: 1px solid rgba(255,82,71,0.5);
  border-radius: 8px;
  padding: 5px 12px;
  font: 600 12px/1 "Oswald", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.cancel-btn:active { transform: scale(0.97); }
.cancel-btn:disabled { opacity: 0.5; }
