/* Цвета берём из темы Telegram — светлая и тёмная тема работают сами. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2f7de1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #2fa55a;
  --radius: 14px;
  --tabs-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

#view {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom));
}

h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 22px 4px 8px; }

.loading, .empty { text-align: center; color: var(--hint); padding: 40px 16px; }
.hint { color: var(--hint); font-size: 14px; }
.center { text-align: center; }
.error { color: var(--danger); padding: 12px 4px; }
.mt { margin-top: 12px; }

/* --- карта --- */
.card {
  border-radius: 20px;
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, #3b2a20 0%, #7a4a2b 55%, #c08a4f 100%);
  box-shadow: 0 8px 24px rgba(60, 35, 15, .28);
}
.card-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; opacity: .85; }
.card-balance { font-size: 44px; font-weight: 700; line-height: 1.1; margin-top: 18px; }
.card-balance small { font-size: 16px; font-weight: 500; opacity: .85; margin-left: 6px; }
.card-number { margin-top: 14px; font-size: 17px; letter-spacing: .14em; font-variant-numeric: tabular-nums; opacity: .92; }

.panel { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-top: 12px; }

.qr { width: 100%; max-width: 230px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 6px; }
.qr svg { display: block; width: 100%; height: auto; }

.code {
  font: 700 30px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .12em; text-align: center; margin: 14px 0 4px;
}

/* --- списки --- */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; }
.row + .row { border-top: 1px solid var(--bg); }
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--bg); }
.row.dim { opacity: .5; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-sub { color: var(--hint); font-size: 13px; overflow-wrap: anywhere; }
.row-side { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.plus { color: var(--ok); }
.minus { color: var(--text); }
.chev { color: var(--hint); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--bg); white-space: nowrap; }

/* --- формы --- */
.btn {
  display: block; width: 100%; min-height: 48px; padding: 12px 16px; margin-top: 12px;
  border: 0; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--bg); color: var(--text); }
.btn.ghost { background: transparent; color: var(--danger); }
.btn.small { display: inline-block; width: auto; min-height: 36px; padding: 6px 14px; margin: 0; font-size: 14px; }

.input {
  display: block; width: 100%; min-height: 48px; padding: 11px 14px; margin-top: 10px;
  border: 1px solid transparent; border-radius: 12px; outline: none;
  background: var(--bg); color: var(--text); font: inherit;
}
.input:focus { border-color: var(--accent); }
.input.big { font-size: 24px; font-weight: 600; text-align: center; }
textarea.input { min-height: 80px; resize: vertical; }
label.field { display: block; margin-top: 12px; font-size: 13px; color: var(--hint); }
label.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; min-height: 44px; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.back { display: inline-block; padding: 6px 2px 12px; color: var(--accent); cursor: pointer; background: none; border: 0; font: inherit; }

.success { text-align: center; padding: 22px 12px; }
.success .big { font-size: 34px; font-weight: 700; color: var(--ok); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--hint); font-size: 13px; }

/* --- картинки наград --- */
.reward-img { display: block; width: 100%; height: 170px; object-fit: cover; border-radius: 10px; margin-bottom: 12px; background: var(--bg); }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg); }
.photo-preview img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-top: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* --- нижние вкладки --- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs[hidden] { display: none; }
.tab {
  flex: 1; max-width: 120px; height: var(--tabs-h); border: 0; background: none; cursor: pointer;
  color: var(--hint); font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab i { font-style: normal; font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tab.active { color: var(--accent); }
.tab.active i { filter: none; opacity: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 20; max-width: 88%;
  background: rgba(30, 30, 32, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
}
