/* ── Переменные ───────────────────────────────────────────────── */
:root {
  --bg:           var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text:         var(--tg-theme-text-color, #111111);
  --text-hint:    var(--tg-theme-hint-color, #8c8c8c);
  --accent:       var(--tg-theme-button-color, #2ea6ff);
  --accent-text:  var(--tg-theme-button-text-color, #ffffff);
  --link:         var(--tg-theme-link-color, #2ea6ff);
  --border:       rgba(0,0,0,0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --gap: 12px;
}

/* ── Сброс ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

img { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── Утилиты ──────────────────────────────────────────────────── */
.container { padding: 0 16px; max-width: 600px; margin: 0 auto; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.text-hint { color: var(--text-hint); font-size: 13px; }
.text-accent { color: var(--accent); }

/* ── Шапка страницы ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 18px; font-weight: 600; }
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Карточка ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card + .card { margin-top: var(--gap); }
.card-body { padding: 14px 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { font-size: 13px; color: var(--text-hint); }

/* ── Список-секция ────────────────────────────────────────────── */
.section { margin-top: 24px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 16px;
  margin-bottom: 8px;
}

/* ── Ячейка-строка ────────────────────────────────────────────── */
.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: opacity 0.15s;
}
.cell:active { opacity: 0.7; }
.cell + .cell { border-top: 1px solid var(--border); }
.cell-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: var(--bg);
}
.cell-content { flex: 1; min-width: 0; }
.cell-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-subtitle { font-size: 13px; color: var(--text-hint); margin-top: 2px; }
.cell-right { color: var(--text-hint); font-size: 18px; flex-shrink: 0; }

/* ── Главная кнопка ───────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-align: center;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Тег-бейдж ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-hint);
}
.badge-accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

/* ── Форма ────────────────────────────────────────────────────── */
.form-group { margin-top: 16px; }
.form-label { font-size: 13px; color: var(--text-hint); margin-bottom: 6px; display: block; }
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.form-input::placeholder { color: var(--text-hint); }
select.form-input { appearance: none; cursor: pointer; }

/* ── Ценник ───────────────────────────────────────────────────── */
.price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.price-secondary {
  font-size: 13px;
  color: var(--text-hint);
}

/* ── Счётчик ──────────────────────────────────────────────────── */
.counter {
  display: flex;
  align-items: center;
  gap: 12px;
}
.counter-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.counter-btn:active { background: var(--accent); color: var(--accent-text); }
.counter-value { font-size: 16px; font-weight: 600; min-width: 24px; text-align: center; }

/* ── Спиннер ──────────────────────────────────────────────────── */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.spinner::after {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Пустое состояние ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-hint);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Ошибка ───────────────────────────────────────────────────── */
.error-banner {
  background: #fff0f0;
  color: #c0392b;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  margin: 16px 0;
  display: none;
}
.error-banner.visible { display: block; }

/* ── Фиксированный футер с кнопкой ───────────────────────────── */
.sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
