:root {
  --bg: #07070c;
  --bg-elev: #11121a;
  --bg-elev-2: #181a26;
  --line: #232636;
  --text: #ffffff;
  --text-2: #9aa0b8;
  --text-3: #6b7090;
  --accent: #7a5cff;
  --accent-2: #4ad5ff;
  --green: #2bd576;
  --red: #ff5d6c;
  --warn: #ffb547;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(circle at 0% 0%, rgba(122,92,255,0.18) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(74,213,255,0.12) 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
}

button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; padding: 0; }
input { font-family: inherit; outline: none; border: 0; background: transparent; color: inherit; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

#app { max-width: 480px; margin: 0 auto; padding: 0 16px 40px; }

/* ====== SCREENS ====== */
.screen { display: none; animation: fadeIn .25s ease; }
.screen.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== TOPBAR ====== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px;
}
.topbar--inner { padding: 14px 0 18px; }
.topbar h2 {
  font-size: 17px; font-weight: 600; margin: 0;
}
.topbar h2 span { color: var(--accent-2); }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__hello { font-size: 12px; color: var(--text-3); }
.topbar__name { font-size: 16px; font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,0.06);
  display: grid; place-items: center;
  color: #d6d8e7; transition: background .15s;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }
.icon-btn svg { width: 20px; height: 20px; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(122,92,255,0.4);
}
.avatar--lg { width: 80px; height: 80px; font-size: 32px; }

/* ====== CARD ====== */
.card-wrap { padding: 8px 0 12px; perspective: 1000px; }
.card-wrap--small .card { transform: scale(.92); }

.card {
  position: relative;
  aspect-ratio: 1.586 / 1;
  border-radius: 22px;
  overflow: hidden;
  padding: 22px 22px 20px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
  box-shadow:
    0 30px 60px -20px rgba(122,92,255,0.5),
    0 16px 32px -16px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.12);
  transform-style: preserve-3d;
  transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.card:active { transform: rotateY(2deg) rotateX(-2deg); }

.card__bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(74,213,255,0.45) 0%, transparent 45%),
    radial-gradient(circle at 10% 110%, rgba(122,92,255,0.7) 0%, transparent 55%),
    linear-gradient(135deg, #1a1133 0%, #0c0a1f 60%, #1a0d2e 100%);
}
.card__bg::before {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 6px);
  mix-blend-mode: screen;
  opacity: .6;
}
.card__bg::after {
  content: "";
  position: absolute; right: -40%; top: -40%;
  width: 120%; height: 120%;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 35%);
  filter: blur(20px);
}

.card > *:not(.card__bg) { position: relative; z-index: 1; }

.card__top { display: flex; align-items: center; justify-content: space-between; }
.card__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.card__brand-mark {
  font-size: 22px;
  background: linear-gradient(135deg, #fff, #c9d6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card__brand-name { font-size: 15px; letter-spacing: .5px; }
.card__type {
  font-size: 10px;
  letter-spacing: 2px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
}

.card__chip { display: flex; align-items: center; justify-content: space-between; }
.chip {
  width: 42px; height: 32px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, #ffd068 0%, #b88930 50%, #6e5320 100%);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
}
.chip::before, .chip::after {
  content: ""; position: absolute; left: 4px; right: 4px;
  height: 1px; background: rgba(0,0,0,0.3);
}
.chip::before { top: 9px; }
.chip::after { bottom: 9px; }
.contactless { color: rgba(255,255,255,0.7); width: 24px; height: 24px; }

.card__number {
  font-family: "SF Mono", "Roboto Mono", monospace;
  font-size: 18px;
  letter-spacing: 2.5px;
  font-weight: 500;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.card__bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.card__label { font-size: 9px; color: rgba(255,255,255,0.55); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.card__holder, .card__expiry { font-size: 13px; font-weight: 500; letter-spacing: .8px; }
.card__network {
  font-family: "Times New Roman", serif;
  font-style: italic;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -1px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ====== BALANCE ====== */
.balance { padding: 18px 4px 12px; }
.balance__label { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.balance__value {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 38px; font-weight: 700; letter-spacing: -1px;
}
.balance__currency { font-size: 22px; color: var(--text-2); font-weight: 500; }
.balance__crypto { font-size: 13px; color: var(--text-3); margin-top: 4px; font-family: "SF Mono", monospace; }

/* ====== ACTIONS ====== */
.actions {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 6px 0 22px;
}
.action {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px;
  background: var(--bg-elev);
  border-radius: 16px;
  transition: transform .12s, background .15s;
  border: 1px solid var(--line);
}
.action:active { transform: scale(.96); background: var(--bg-elev-2); }
.action__icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(122,92,255,0.3);
}
.action__icon svg { width: 20px; height: 20px; }
.action__label { font-size: 12px; color: #d6d8e7; }

/* ====== SECTION HEAD ====== */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 10px;
}
.section-head h3 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text-2); text-transform: uppercase; letter-spacing: 1px; }
.section-head__more { font-size: 13px; color: var(--accent-2); font-weight: 500; }

/* ====== TX LIST ====== */
.tx-list { display: flex; flex-direction: column; gap: 4px; background: var(--bg-elev); border-radius: 16px; border: 1px solid var(--line); overflow: hidden; }
.tx {
  display: grid; grid-template-columns: 38px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.tx:last-child { border-bottom: 0; }
.tx__ico {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
}
.tx--in .tx__ico { background: rgba(43,213,118,0.14); color: var(--green); }
.tx--out .tx__ico { background: rgba(255,93,108,0.14); color: var(--red); }
.tx--card .tx__ico { background: rgba(74,213,255,0.14); color: var(--accent-2); }
.tx__title { font-size: 14px; font-weight: 500; }
.tx__sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tx__amount { font-size: 14px; font-weight: 600; text-align: right; }
.tx__amount--in { color: var(--green); }
.tx__amount--out { color: #f0f1f7; }
.tx__time { font-size: 11px; color: var(--text-3); margin-top: 2px; text-align: right; }

/* ====== PROMO ====== */
.promo {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(74,213,255,0.18), transparent 50%),
    linear-gradient(135deg, #1a1438, #0c0820);
  border: 1px solid rgba(122,92,255,0.25);
}
.promo__title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.promo__text { font-size: 13px; color: var(--text-2); }

/* ====== TOPUP ====== */
.topup-amount {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 8px;
}
.topup-amount__label { font-size: 12px; color: var(--text-3); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.topup-amount__row {
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.topup-amount__currency { font-size: 28px; color: var(--text-2); font-weight: 500; }
.topup-amount__row input {
  font-size: 38px; font-weight: 700; letter-spacing: -1px;
  flex: 1; min-width: 0; padding: 0;
}
.topup-amount__hint { font-size: 12px; color: var(--text-3); margin-top: 10px; }
.quick-amounts {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px;
}
.quick-amounts button {
  flex: 1 1 auto;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(122,92,255,0.1);
  color: #c2bafe;
  font-size: 13px; font-weight: 500;
  border: 1px solid rgba(122,92,255,0.18);
}
.quick-amounts button:active { background: rgba(122,92,255,0.2); }

.crypto-list { display: flex; flex-direction: column; gap: 8px; }
.crypto {
  display: grid; grid-template-columns: 44px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.crypto:active { background: var(--bg-elev-2); border-color: var(--accent); }
.crypto__ico {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  color: #fff;
}
.crypto__ico--btc { background: linear-gradient(135deg, #f7931a, #b86f0a); }
.crypto__ico--eth { background: linear-gradient(135deg, #627eea, #3957c8); }
.crypto__ico--usdt { background: linear-gradient(135deg, #26a17b, #1a7d5d); }
.crypto__ico--usdc { background: linear-gradient(135deg, #2775ca, #1c5ba8); }
.crypto__ico--ton { background: linear-gradient(135deg, #0098ea, #0072c4); }
.crypto__name { font-size: 15px; font-weight: 500; }
.crypto__net { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.crypto__rate { font-size: 14px; font-weight: 600; color: var(--text-2); font-family: "SF Mono", monospace; }

/* ====== DEPOSIT ====== */
.deposit { padding: 4px 0; }
.deposit__amount {
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.deposit__amount-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.deposit__amount-value { font-size: 22px; font-weight: 700; margin-top: 6px; font-family: "SF Mono", monospace; }
.deposit__amount-fiat { font-size: 13px; color: var(--text-3); margin-top: 4px; }

.qr {
  display: flex; flex-direction: column; align-items: center;
  background: #fff; border-radius: 18px;
  padding: 18px; margin-bottom: 14px;
}
.qr__inner { width: 220px; height: 220px; display: grid; place-items: center; }
.qr__inner img, .qr__inner canvas { width: 100%; height: 100%; }
.qr__net { color: #555; font-size: 12px; margin-top: 12px; font-weight: 500; }

.addr { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.addr__label { font-size: 12px; color: var(--text-3); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.addr__row { display: flex; align-items: center; gap: 10px; }
.addr__row code { flex: 1; font-family: "SF Mono", monospace; font-size: 13px; word-break: break-all; line-height: 1.5; }

.copy-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(122,92,255,0.15);
  display: grid; place-items: center; color: #c2bafe;
  flex-shrink: 0;
}
.copy-btn:active { background: rgba(122,92,255,0.25); }
.copy-btn svg { width: 16px; height: 16px; }

.warn {
  background: rgba(255,181,71,0.08);
  border: 1px solid rgba(255,181,71,0.2);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}
.warn__title { font-size: 13px; color: var(--warn); font-weight: 600; margin-bottom: 6px; }
.warn ul { margin: 0; padding-left: 18px; font-size: 12px; color: #c8c8d8; }
.warn li { margin: 3px 0; }
.warn span { color: var(--warn); font-weight: 500; }

/* ====== BUTTONS ====== */
.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  font-size: 15px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), #5e3eff);
  color: #fff;
  box-shadow: 0 8px 20px rgba(122,92,255,0.4);
  transition: transform .12s;
}
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  font-size: 14px; font-weight: 500;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-secondary:active { background: var(--bg-elev-2); }
.btn-secondary svg { width: 18px; height: 18px; }

/* ====== DETAILS ====== */
.details-list { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.details-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.details-row:last-child { border-bottom: 0; }
.details-row__label { font-size: 13px; color: var(--text-3); }
.details-row__value { display: flex; align-items: center; gap: 10px; font-family: "SF Mono", monospace; font-size: 14px; }
.details-row__value .copy-btn { width: 30px; height: 30px; }
.details-row__value .copy-btn svg { width: 14px; height: 14px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
}
.toggle-row__title { font-size: 14px; font-weight: 500; }
.toggle-row__hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.switch { position: relative; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #2a2d40; border-radius: 28px;
  transition: .2s;
}
.slider::before {
  content: ""; position: absolute;
  height: 22px; width: 22px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: .2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ====== SEND ====== */
.send-form { display: flex; flex-direction: column; gap: 10px; }
.field {
  display: block;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.field__label { font-size: 12px; color: var(--text-3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; }
.field input { width: 100%; font-size: 16px; padding: 4px 0; }
.hint { font-size: 12px; color: var(--text-3); padding: 8px 4px; }

/* ====== HISTORY ====== */
.filters { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.filter {
  padding: 8px 14px; border-radius: 10px;
  background: var(--bg-elev); color: var(--text-2);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--line);
}
.filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ====== PROFILE ====== */
.profile { text-align: center; padding: 12px 0 24px; }
.profile .avatar { margin: 0 auto 14px; }
.profile__name { font-size: 22px; font-weight: 700; }
.profile__id { font-size: 13px; color: var(--text-3); margin-top: 4px; font-family: "SF Mono", monospace; }

.menu { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.menu__item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.menu__item:last-child { border-bottom: 0; }
.menu__item:active { background: var(--bg-elev-2); }
.menu__icon { font-size: 18px; width: 22px; text-align: center; }
.menu__item span:nth-child(2) { flex: 1; }
.menu__badge { font-size: 11px; color: var(--warn); background: rgba(255,181,71,0.12); padding: 4px 8px; border-radius: 8px; }

.brand-foot { text-align: center; padding: 30px 0 10px; color: var(--text-3); }
.brand-foot__mark { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text-2); }
.brand-foot__text { font-size: 11px; }

/* ====== TOAST ====== */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-elev-2);
  color: #fff;
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  transition: all .25s cubic-bezier(.2,.8,.2,1);
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Telegram theme adjustments */
body.tg-light {
  --bg: #ffffff;
  --bg-elev: #f5f6fb;
  --bg-elev-2: #ebedf5;
  --line: #e1e3ed;
  --text: #0a0a0f;
  --text-2: #5a607a;
  --text-3: #8b91a9;
}

@media (max-width: 360px) {
  .actions { gap: 6px; }
  .action__label { font-size: 11px; }
  .balance__value { font-size: 32px; }
}
