/* ═══════════════════════════════════════════════════════════════════════════
   Battle Pass TOP GAME — общие стили мини-аппов (гость + касса)

   Отдаётся как /app/app.css, подключается обеими страницами: /app и
   /app/cashier. Один файл на два приложения, потому что живут они в одном
   Telegram-клиенте, у них общая палитра и общий набор компонентов (карточки,
   кнопки, плашки, прогресс-бары, состояния загрузки). Держать это в двух
   <style> — гарантированно разъехаться через месяц.

   ТЕМА. Базовая палитра светлая, html.dark переключает на тёмную. Поверх
   любой из них скрипт страницы кладёт цвета из Telegram.WebApp.themeParams
   инлайном в <html style="--surface:…">. Поэтому в правилах ниже нет «голых»
   цветов — только переменные; исключение одно: QR-код, он обязан оставаться
   чёрным по белому в любой теме, иначе камера кассира его не возьмёт.

   ВЁРСТКА. Один столбец под узкий экран телефона, ничего не завязано на
   ширину больше 320px. Нижняя навигация фиксирована, поэтому у body есть
   нижний отступ + env(safe-area-inset-bottom) под «шторку» iPhone.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --surface:     #f2f2f7;
  --card:        #ffffff;
  --track:       #e6e6ea;
  --grid:        #e6e6ea;
  --text-1:      #0b0b0b;
  --text-2:      #6d6d72;
  --accent:      #2a78d6;
  --accent-text: #ffffff;
  --good:        #0a8a3c;
  --warn:        #c98500;
  --serious:     #e34948;
  --gold:        #d99b1c;
  --shadow:      0 1px 3px rgba(0, 0, 0, .07);
  --overlay-bg:  rgba(0, 0, 0, .55);
}

html.dark {
  --surface:     #17171a;
  --card:        #232326;
  --track:       #34343a;
  --grid:        #34343a;
  --text-1:      #ffffff;
  --text-2:      #a8a8b3;
  --accent:      #4e9bf0;
  --accent-text: #ffffff;
  --good:        #35b866;
  --warn:        #e0a334;
  --serious:     #ef6b6b;
  --gold:        #e8b647;
  --shadow:      none;
  --overlay-bg:  rgba(0, 0, 0, .7);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* !important нужен: .overlay и .btn-row задают display, и без него скрытый
   через атрибут hidden блок остался бы видимым. */
[hidden] { display: none !important; }

body {
  background: var(--surface);
  color: var(--text-1);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 10px 12px calc(78px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
body.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ── Шапка ──────────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 2px 2px 12px;
}
header h1 { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
header .stamp { color: var(--text-2); font-size: 12.5px; text-align: right; }

/* ── Карточки и типографика ─────────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card h2 {
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.card h2 .sub { color: var(--text-2); font-weight: 400; font-size: 12px; }
.h3 { font-size: 15.5px; font-weight: 700; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; line-height: 1.4; }
.center { text-align: center; }
.mb4 { margin-bottom: 4px; }
.mb8 { margin-bottom: 8px; }
.mt8 { margin-top: 8px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .5px;
        font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; align-items: flex-start; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sep { height: 1px; background: var(--grid); margin: 10px 0; }

/* ── Плашки и чипы ──────────────────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--track); color: var(--text-2);
}
.pill.ok   { background: color-mix(in srgb, var(--good) 16%, transparent);    color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent);    color: var(--warn); }
.pill.bad  { background: color-mix(in srgb, var(--serious) 16%, transparent); color: var(--serious); }
.pill.info { background: color-mix(in srgb, var(--accent) 16%, transparent);  color: var(--accent); }

.xp-chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.xp-chip.done { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }

/* ── Прогресс-бары ──────────────────────────────────────────────────────── */
.bar {
  height: 8px; border-radius: 4px; background: var(--track);
  overflow: hidden; margin: 7px 0 4px;
}
.bar i {
  display: block; height: 100%; border-radius: 4px; background: var(--accent);
  transition: width .35s ease;
}
.bar.thin { height: 5px; }
.bar.good i { background: var(--good); }
.bar.warn i { background: var(--warn); }
.bar.gold i { background: var(--gold); }

/* ── Кнопки ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border: 0; border-radius: 11px; font-size: 14.5px;
  font-weight: 600; font-family: inherit; background: var(--track);
  color: var(--text-1); cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.good    { background: var(--good);   color: #fff; }
.btn.danger  { background: var(--serious); color: #fff; }
.btn.ghost   { background: transparent; color: var(--text-1);
               box-shadow: inset 0 0 0 1px var(--grid); }
.btn.wide    { width: 100%; }
.btn.sm      { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* ── Поля ввода ─────────────────────────────────────────────────────────── */
.field {
  width: 100%; padding: 11px 13px; border-radius: 11px; font-size: 16px;
  font-family: inherit; border: 1px solid var(--grid);
  background: var(--surface); color: var(--text-1); outline: none;
}
.field:focus { border-color: var(--accent); }
textarea.field { resize: vertical; line-height: 1.4; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }
label.lbl { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }

/* ── Нижняя навигация ───────────────────────────────────────────────────── */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--grid);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; position: relative; border: 0; background: none; color: var(--text-2);
  font-size: 11px; font-family: inherit; padding: 7px 0 6px; line-height: 1.3;
  cursor: pointer;
}
nav.tabs button .ico { display: block; font-size: 20px; line-height: 1.15; }
nav.tabs button.on { color: var(--accent); font-weight: 600; }
nav.tabs .dot {
  position: absolute; top: 4px; left: 50%; margin-left: 8px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--serious); color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px;
}

/* ── Состояния: загрузка, ошибка, пусто ─────────────────────────────────── */
.state { text-align: center; color: var(--text-2); padding: 44px 16px; }
.state .state-ico { font-size: 30px; margin-bottom: 8px; }
.state .state-msg { margin-bottom: 12px; color: var(--text-1); font-size: 14px; }
.state.small-state { padding: 20px 12px; }
.spin {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--track); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 2.4s; }
  .bar i { transition: none; }
}

/* ── Баннеры (множитель, блокировка, подсказки) ─────────────────────────── */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border-radius: 13px; margin-bottom: 12px; font-size: 13.5px;
  background: var(--card); box-shadow: var(--shadow);
  border-left: 3px solid var(--accent);
}
.banner.warn { border-left-color: var(--warn); }
.banner.bad  { border-left-color: var(--serious); }
.banner.good { border-left-color: var(--good); }
.banner .banner-body { flex: 1; min-width: 0; }
.banner.boost {
  border-left-color: var(--gold);
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--gold) 18%, var(--card)), var(--card) 62%);
}
.boost-x {
  font-size: 22px; font-weight: 800; color: var(--gold);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.boost-timer {
  font-size: 13px; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ── QR-карта гостя ─────────────────────────────────────────────────────── */
.qr-wrap {
  display: flex; align-items: center; justify-content: center;
  background: #fff;            /* белое поле обязательно: см. шапку файла */
  border-radius: 14px; padding: 12px; margin: 12px 0 10px;
  min-height: 200px;
}
.qr-wrap canvas { display: block; image-rendering: pixelated; }
.qr-wrap .qr-fail { color: #6d6d72; font-size: 13px; text-align: center; }
.qr-id {
  text-align: center; font-size: 17px; font-weight: 700; letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums; margin-bottom: 4px;
}

/* ── Уровень ────────────────────────────────────────────────────────────── */
.lvl { display: flex; align-items: center; gap: 14px; }
.lvl-badge {
  flex: none; width: 58px; height: 58px; border-radius: 16px;
  background: var(--accent); color: var(--accent-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; line-height: 1;
}
.lvl-badge span { font-size: 9px; font-weight: 600; letter-spacing: 1px; opacity: .85; }
.lvl-body { flex: 1; min-width: 0; }
.lvl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
           font-size: 13.5px; }
.lvl-scale { display: flex; justify-content: space-between; font-size: 11.5px;
             color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── Мини-статы (стрик, статус) ─────────────────────────────────────────── */
.stat { text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
           line-height: 1.2; }
.stat .l { font-size: 11.5px; color: var(--text-2); }

/* ── Задания ────────────────────────────────────────────────────────────── */
.task { padding: 11px 0; border-top: 1px solid var(--grid); }
.task:first-child { border-top: 0; padding-top: 2px; }
.task-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.task-title { font-weight: 600; }
.task.done .task-title { color: var(--text-2); text-decoration: line-through;
                         text-decoration-color: var(--grid); }
.task-meta { display: flex; justify-content: space-between; gap: 8px;
             font-size: 12px; color: var(--text-2); margin-top: 3px; }
.task-note { font-size: 12px; color: var(--warn); margin-top: 4px; }
.sub-list { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--grid); }
.sub-list .sub-item { font-size: 12.5px; color: var(--text-2); padding: 2px 0;
                      display: flex; justify-content: space-between; gap: 8px; }

/* ── Строки «ключ — значение» ───────────────────────────────────────────── */
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0;
      border-bottom: 1px solid var(--grid); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Награды и промокоды ────────────────────────────────────────────────── */
.promo-code {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px dashed var(--grid); border-radius: 11px;
  padding: 10px 12px; margin: 8px 0 6px;
  font-size: 17px; font-weight: 700; letter-spacing: 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.promo-code.dead { opacity: .55; text-decoration: line-through; }
.promo-code .copy { font-size: 12px; font-weight: 600; color: var(--accent);
                    font-family: inherit; letter-spacing: 0; white-space: nowrap; }
.deadline { font-size: 12.5px; font-weight: 700; color: var(--warn);
            font-variant-numeric: tabular-nums; }

/* ── Ачивки ─────────────────────────────────────────────────────────────── */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach {
  text-align: center; padding: 10px 6px; border-radius: 12px;
  background: var(--surface);
}
.ach .ico { font-size: 24px; line-height: 1.2; }
.ach .t { font-size: 11.5px; font-weight: 600; margin-top: 3px; }
.ach.locked { opacity: .45; }
.ach .p { font-size: 10.5px; color: var(--text-2); margin-top: 2px;
          font-variant-numeric: tabular-nums; }

/* ── Тосты ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60; padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: var(--text-1); color: var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28); text-align: center;
}
.toast.good { background: var(--good); color: #fff; }
.toast.bad  { background: var(--serious); color: #fff; }
body.no-tabs .toast { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* ── Модалка ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 70; background: var(--overlay-bg);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.overlay-box {
  width: 100%; max-width: 400px; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; padding: 18px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35);
}

/* ── NPS-шкала опроса ───────────────────────────────────────────────────── */
.nps-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
.nps {
  padding: 9px 0; border: 0; border-radius: 9px; background: var(--surface);
  color: var(--text-1); font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
}
.nps.on { background: var(--accent); color: var(--accent-text); }

/* ═══ Панель кассира ════════════════════════════════════════════════════ */

/* Крупная цветная плашка результата: кассир смотрит на неё через весь
   прилавок и должен понимать исход, не читая мелкий текст. */
.plaque {
  text-align: center; font-size: 15.5px; font-weight: 700; padding: 14px 12px;
  border-radius: 13px; margin-bottom: 10px; transition: background .15s;
}
.plaque.idle { background: var(--card); color: var(--text-2); font-weight: 500;
               font-size: 14px; box-shadow: var(--shadow); }
.plaque.ok   { background: var(--good);    color: #fff; }
.plaque.warn { background: var(--warn);    color: #fff; }
.plaque.bad  { background: var(--serious); color: #fff; }
.plaque .sub { display: block; font-size: 12.5px; font-weight: 500; margin-top: 3px;
               opacity: .92; }

#reader { width: 100%; min-height: 240px; border-radius: 12px; overflow: hidden;
          background: #000; }
#reader video { border-radius: 12px; width: 100% !important; }
#reader img { display: none; }   /* служебная картинка html5-qrcode «нет камеры» */

.guest-head { display: flex; align-items: center; gap: 12px; }
.guest-head .nick { font-size: 18px; font-weight: 700; line-height: 1.2; }
.guest-head .sub { font-size: 12.5px; color: var(--text-2); }

.act-list .act-item { padding: 10px 0; border-top: 1px solid var(--grid); }
.act-list .act-item:first-child { border-top: 0; }
.act-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.act-line .t { font-weight: 600; font-size: 14px; }
.act-line .btn { flex: none; }

.acc { padding: 10px 0; border-top: 1px solid var(--grid); }
.acc:first-child { border-top: 0; }
.acc .acc-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acc .login { font-weight: 600; }
.acc .meta { font-size: 12px; color: var(--text-2); }

.log-item { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0;
            font-size: 12.5px; color: var(--text-2); border-bottom: 1px solid var(--grid); }
.log-item:last-child { border-bottom: 0; }
.log-item .when { white-space: nowrap; font-variant-numeric: tabular-nums; }
