:root {
  --bg: #f2f4f5;
  --surface: #ffffff;
  --surface-2: #e9eef0;
  --text: #0f1a1c;
  --muted: #5e6b70;
  --line: #e1e7e9;
  --brand: #0e7c66;
  --brand-ink: #ffffff;
  --brand-soft: #dff2ec;
  --pos: #0e7c66;
  --neg: #c2410c;
  --neg-soft: #fdebe1;
  --danger: #b42318;
  --telegram: #0e78b7;
  --card-from: #13977c;
  --card-to: #0a4f47;
  --gold: #f5b83d;
  --shadow: 0 1px 2px rgba(15, 26, 28, 0.06), 0 8px 24px rgba(15, 26, 28, 0.06);
  --radius: 20px;
  --tabbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1213;
    --surface: #141d1f;
    --surface-2: #1d282b;
    --text: #e8eef0;
    --muted: #93a3a8;
    --line: #243134;
    --brand: #2bb594;
    --brand-ink: #04211b;
    --brand-soft: #173a33;
    --pos: #3ccb9f;
    --neg: #fb923c;
    --neg-soft: #3a2518;
    --danger: #f97066;
    --telegram: #2b9fe0;
    --card-from: #127a65;
    --card-to: #0a3a35;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  overscroll-behavior-y: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--brand);
}

.num {
  font-variant-numeric: tabular-nums;
}

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

.small {
  font-size: 14px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- shell ---------- */

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}

.brand svg {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
  flex: none;
}

.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 22px;
}

h1.h1 {
  margin: 4px 0 2px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0 0 16px;
  color: var(--muted);
}

.offline {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 520px;
  height: var(--tabbar-h);
  margin: 0 auto;
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.tab svg {
  width: 24px;
  height: 24px;
}

.tab[aria-current="page"] {
  color: var(--brand);
}

.tab .dot {
  position: absolute;
  top: 9px;
  left: calc(50% + 8px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--neg);
  border: 2px solid var(--surface);
}

/* ---------- cards ---------- */

.card {
  margin: 0 0 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid transparent;
}

@media (prefers-color-scheme: dark) {
  .card {
    border-color: var(--line);
  }
}

.balance-card {
  position: relative;
  overflow: hidden;
  margin: 0 0 12px;
  padding: 20px 20px 18px;
  border-radius: 24px;
  color: #fff;
  background: radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(135deg, var(--card-from), var(--card-to));
}

.balance-card::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 28px solid rgba(255, 255, 255, 0.07);
}

.bc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  opacity: 0.92;
}

.bc-amount {
  margin-top: 6px;
  font-size: 52px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.bc-unit {
  margin-top: 4px;
  font-size: 15px;
  opacity: 0.85;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-gold {
  background: var(--gold);
  color: #3a2600;
}

/* the card code is always dark on white: scanners need the contrast */
.code-card {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 20px 16px 16px;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  color: #0f1a1c;
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
}

.code-img {
  width: 188px;
  height: 188px;
  margin: 0 auto;
}

.code-img img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.code-phone {
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.code-hint {
  margin: 6px auto 0;
  max-width: 300px;
  font-size: 14px;
  color: #5e6b70;
}

.code-expand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: #0e7c66;
  font-size: 14px;
  font-weight: 600;
}

.code-expand svg {
  width: 16px;
  height: 16px;
}

.level-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
}

.bar {
  height: 8px;
  margin: 10px 0 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.tip-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.tip-icon svg {
  width: 22px;
  height: 22px;
}

.tip-body {
  flex: 1;
  min-width: 0;
}

.tip-title {
  font-weight: 600;
}

.tip-text {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tip-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tip-close {
  flex: none;
  width: 32px;
  height: 32px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ios-share {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  color: var(--telegram);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.btn svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.btn-sm {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 15px;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-telegram {
  background: var(--telegram);
  color: #fff;
}

.btn-link {
  min-height: 44px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}

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

/* ---------- login ---------- */

.login {
  display: flex;
  flex-direction: column;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 40px) 24px calc(env(safe-area-inset-bottom) + 24px);
}

.login-hero {
  text-align: center;
}

.login-hero .logo svg {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(14, 124, 102, 0.28);
}

.login-hero h1 {
  margin: 20px 0 4px;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.login-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.features {
  margin: 32px 0;
  padding: 0;
  list-style: none;
}

.features li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.features .tip-icon {
  width: 44px;
  height: 44px;
}

.login-actions {
  margin-top: auto;
}

.login.is-waiting .features {
  display: none;
}

.login.is-waiting .login-actions {
  margin-top: 32px;
}

.login-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.steps {
  margin: 0 0 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  counter-reset: step;
  list-style: none;
}

.steps li {
  position: relative;
  padding: 6px 0 6px 40px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
}

.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--muted);
}

.stack > * + * {
  margin-top: 8px;
}

/* ---------- lists: history, profile ---------- */

.month {
  margin: 20px 4px 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
}

.list {
  margin: 0 0 12px;
  padding: 4px 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (prefers-color-scheme: dark) {
  .list {
    border: 1px solid var(--line);
  }
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  color: inherit;
  text-decoration: none;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  cursor: default;
}

button.row,
a.row {
  cursor: pointer;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--pos);
}

.row-icon.neg {
  background: var(--neg-soft);
  color: var(--neg);
}

.row-icon svg {
  width: 20px;
  height: 20px;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-weight: 500;
  line-height: 1.3;
}

.row-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
}

.row-amount {
  flex: none;
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.row-amount.pos {
  color: var(--pos);
}

.row-amount.neg {
  color: var(--neg);
}

.row-value {
  color: var(--muted);
  text-align: right;
}

.row-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: none;
}

.row.danger {
  color: var(--danger);
  font-weight: 500;
}

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  color: var(--brand);
  opacity: 0.8;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 20px;
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.switch[aria-checked="true"] {
  background: var(--brand);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

.foot {
  margin: 24px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- support chat ---------- */

.chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 76px;
}

.day {
  align-self: center;
  margin: 12px 0 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.msg {
  max-width: 82%;
  padding: 8px 12px 6px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.msg.me {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink);
}

.msg.me a {
  color: inherit;
}

.msg.support {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.msg-time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.7;
  text-align: right;
}

.msg-photo {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 2px 0 4px;
  border-radius: 12px;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 15;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 12px;
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  resize: none;
  outline: none;
  line-height: 1.3;
}

.composer textarea:focus {
  border-color: var(--brand);
}

.send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}

.send[disabled] {
  opacity: 0.5;
}

.send svg {
  width: 22px;
  height: 22px;
}

/* ---------- confirmation sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 10, 12, 0.5);
  animation: fade 0.2s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  text-align: center;
  animation: up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

.sheet-grip {
  width: 40px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 99px;
  background: var(--line);
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--muted);
}

.sheet-amount {
  margin: 6px 0 2px;
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.sheet-unit {
  color: var(--muted);
}

.sheet-shop {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 15px;
  text-align: left;
}

.sheet-note {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: left;
}

.countdown {
  margin: 18px 0 14px;
}

.countdown .bar {
  margin: 0 0 6px;
  height: 6px;
}

.countdown .bar > i {
  transition: width 1s linear;
}

.countdown-text {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sheet-result {
  padding: 24px 0 12px;
}

.sheet-result svg {
  width: 64px;
  height: 64px;
}

.sheet-result .ok {
  color: var(--pos);
}

.sheet-result .no {
  color: var(--muted);
}

.sheet-result-title {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
}

@keyframes up {
  from {
    transform: translateY(100%);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- fullscreen code ---------- */

.fullcode {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #fff;
  color: #0f1a1c;
  animation: fade 0.15s ease;
}

.fullcode .code-img {
  width: min(78vw, 58vh, 420px);
  height: min(78vw, 58vh, 420px);
}

.fullcode .code-phone {
  margin-top: 24px;
  font-size: 30px;
}

.fullcode .code-hint {
  margin-top: 10px;
}

.fc-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #eef2f3;
  color: #0f1a1c;
  cursor: pointer;
}

.fc-close svg {
  width: 22px;
  height: 22px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: #1f2a2d;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
  animation: fade 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
