/* Фирменное оформление NIS — цвета и метрики из SNNP/Views/Theme.swift. */
:root {
  --blue: #0070ba;
  --cyan: #009cde;
  --deep: #005b95;
  --ink: #0b2233;
  --muted: #6e8598;
  --line: #e2ebf2;
  --field: #f5f9fc;
  /* Терракота — с кнопки QR в оригинальном приложении NIS. */
  --clay: #c0561f;
  --danger: #c62828;
}

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

body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
}

button { font: inherit; cursor: pointer; }

/* ─────────────────────────── каркас ─────────────────────────── */

.screen {
  display: flex;
  flex-direction: column;
  /* В полноэкранном режиме 100vh считается по-другому: берём высоту вьюпорта,
     которую сообщает Telegram, и падаем на 100vh вне его. */
  min-height: var(--tg-viewport-stable-height, 100vh);
}

.panel {
  position: relative;
  overflow: hidden;
  /* Сверху обходим и вырез устройства, и плавающие кнопки клиента: в
     полноэкранном режиме шапки Telegram нет, а «Закрыть» и меню остаются
     висеть поверх содержимого. Отступы складываются — вырез считается от края
     экрана, кнопки от края области содержимого. */
  padding: calc(
      var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) +
      var(--tg-content-safe-area-inset-top, 0px) + 14px
    ) 28px 44px;
  color: #fff;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--deep));
}

.fullscreen .panel { padding-top: max(72px, var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 14px); }

.mosaic { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.panel-body { position: relative; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Пара «поставить иконку» и «выйти» в одной строке, через тонкую черту.
   Черты нет, когда предложения нет: иконка уже стоит или клиент не умеет. */
.twin { display: flex; align-items: center; gap: 12px; }
.rule { display: none; width: 1px; height: 13px; background: rgba(255, 255, 255, 0.34); }
.add-home-inline:not([hidden]) + .rule { display: block; }

.sheet {
  flex: 1;
  margin-top: -28px;
  padding: 32px 28px calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 24px);
  background: #fff;
  border-radius: 28px 28px 0 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.sheet-footer { margin-top: auto; padding-top: 24px; }

/* ─────────────────────────── типографика ────────────────────── */

.wordmark-title {
  display: block;
  font-size: 30px;
  font-weight: 700;
  font-stretch: condensed;
}

.wordmark-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.34em;
  color: rgba(255, 255, 255, 0.72);
}

.panel-note { margin: 16px 0 0; max-width: 280px; color: rgba(255, 255, 255, 0.82); }

.panel-title, .greeting {
  font-size: 24px;
  font-weight: 600;
  font-stretch: condensed;
  margin: 0;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  font-stretch: condensed;
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 26px; }
.section-head.first { margin-top: 0; }
.section-head h1 { font-size: 19px; }

.empty { color: var(--muted); }

/* ─────────────────────────── формы ──────────────────────────── */

.fields { margin-top: 24px; }

.field { display: block; margin-bottom: 20px; }

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field input {
  width: 100%;
  height: 56px;
  padding: 0 18px;
  font-size: 17px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.field input:focus { outline: none; border-color: var(--blue); }

.button {
  position: relative;
  width: 100%;
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 28px;
  box-shadow: 0 8px 14px rgba(0, 112, 186, 0.26);
}

.button:disabled { opacity: 0.5; box-shadow: none; }
.button.busy span { visibility: hidden; }

.button.busy::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.link {
  align-self: flex-start;
  display: inline-block;
  margin-top: 18px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--blue);
  background: none;
  border: 0;
}

.panel-head .link { margin: 0; color: rgba(255, 255, 255, 0.78); }
.section-head .link { margin: 0; }

.add-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: none;
  font-weight: 600;
}

.add-home svg { width: 15px; height: 15px; flex: none; }

/* Шапка: ссылка вровень с «Sign out». */
.add-home-inline {
  padding: 0;
  font-size: 15px;
  color: #fff;
}

.add-home-inline svg { width: 14px; height: 14px; }

/* Экран входа: тихая строка того же веса, что ссылка про номер карты. */
.add-home-text {
  width: 100%;
  margin-bottom: 16px;
  padding: 4px;
  font-size: 15px;
  color: var(--blue);
}

.status { min-height: 20px; margin: 16px 0 0; font-size: 14px; color: var(--blue); }
.status.error { color: var(--danger); }
/* Пустая строка статуса не должна раздвигать вёрстку. */
.status:empty { min-height: 0; margin: 0; }

.spinner {
  width: 24px;
  height: 24px;
  margin: 24px auto;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────── код из SMS ─────────────────────── */

.code { position: relative; margin-top: 24px; }

.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.01;
  border: 0;
  font-size: 24px;
}

.code-boxes { display: flex; gap: 10px; pointer-events: none; }

.code-box {
  flex: 1;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.code-box.filled { border-color: var(--blue); }

/* ─────────────────────────── главная ────────────────────────── */

.summary { margin-top: 24px; }

/* Шапка главной: баллы слева, кнопка QR справа, напротив числа.
   Отступ сверху тот же, что между остальными блоками плашки. */
.panel-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.panel-split .summary { margin-top: 0; }

/* Круглая кнопка QR — по мотивам оригинального приложения. Белое кольцо
   обязательно: без него терракота вязнет в синей плашке. */
.qr-button {
  flex: none;
  width: 68px;
  height: 68px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--clay);
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 8px 16px rgba(11, 34, 51, 0.26);
}

.qr-button:active { transform: scale(0.96); }
.qr-button canvas { display: block; }

.summary-label { font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.72); }

.summary-value { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }

.points { font-size: 52px; font-weight: 800; line-height: 1; }
.level { font-size: 15px; font-weight: 600; color: rgba(255, 255, 255, 0.9); }

.tier { margin-top: 20px; }
.tier-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.26); overflow: hidden; }
.tier-fill { height: 100%; border-radius: 4px; background: #fff; }
.tier-note { display: block; margin-top: 10px; font-size: 13px; color: rgba(255, 255, 255, 0.82); }

.recent { flex: 1; }

/* ─────────────────────────── начисления ─────────────────────── */

.row { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }

.row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row-side { display: flex; flex-direction: column; gap: 4px; margin-left: auto; text-align: right; }

.row-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-detail { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-points { font-size: 13px; font-weight: 700; color: var(--blue); }

/* ─────────────────────────── карта ──────────────────────────── */

.card-screen { background: var(--field); }

.card-header { padding-bottom: 18px; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 24px calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 24px);
}

.loyalty-card {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 55%, var(--deep));
  box-shadow: 0 14px 22px rgba(0, 91, 149, 0.3);
}

.loyalty-card-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 26px;
  color: #fff;
}

.loyalty-card .wordmark { align-self: flex-start; }

.plate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 236px;
  height: 236px;
  background: #fff;
  border-radius: 20px;
  transition: opacity 0.15s ease-in-out;
}

.plate.dim { opacity: 0.45; }
.plate canvas { image-rendering: pixelated; }

.card-number { font-size: 19px; font-weight: 600; letter-spacing: 3px; }

.countdown { margin: 18px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); text-align: center; }
