:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-soft: #121a31;
  --text: #f4f7ff;
  --muted: #9aa6c3;
  --accent: #6ea8ff;
  --card-a: #1f3b8f;
  --card-b: #5b2d91;
  --card-c: #1a8cff;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --transition: 300ms ease-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: radial-gradient(circle at top, #152044 0%, var(--bg) 55%);
  color: var(--text);
}

.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.toast {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: rgba(20, 28, 52, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 80;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.screens {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translateX(100%);
  transition: transform var(--transition);
  will-change: transform;
  pointer-events: none;
  visibility: hidden;
}

.screen.is-active {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
  z-index: 2;
}

.screen.is-left {
  transform: translateX(-100%);
  visibility: hidden;
  z-index: 1;
}

.screen.is-right {
  transform: translateX(100%);
  visibility: hidden;
  z-index: 1;
}

.screen.is-animating {
  visibility: visible;
  pointer-events: none;
}

.screen-scroll {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 20px
    calc(var(--nav-h) + var(--safe-bottom) + 20px);
  touch-action: pan-y;
}

.ptr-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  margin: 0 0 28px;
  padding-top: 2px;
}

.ptr-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  opacity: 0.78;
}

.ptr-hint-arrow {
  display: inline-block;
  font-size: 17px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.ptr-area[data-state="idle"] .ptr-hint-arrow {
  animation: ptrArrowIdle 2.2s ease-in-out infinite;
}

.ptr-area[data-state="pulling"] .ptr-hint-arrow,
.ptr-area[data-state="ready"] .ptr-hint-arrow,
.ptr-area[data-state="refreshing"] .ptr-hint-arrow,
.ptr-area[data-state="finishing"] .ptr-hint-arrow {
  animation: none;
}

@keyframes ptrArrowIdle {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.75;
  }
  50% {
    transform: translateY(4px);
    opacity: 1;
  }
}

.ptr-hint-text {
  font-size: 12px;
  font-weight: 500;
}

.ptr-area[data-state="pulling"] .ptr-hint,
.ptr-area[data-state="ready"] .ptr-hint {
  opacity: 1;
}

.ptr-area[data-state="ready"] .ptr-hint-arrow {
  transform: rotate(180deg);
}

.ptr-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.ptr-area[data-state="refreshing"] .ptr-loader,
.ptr-area[data-state="finishing"] .ptr-loader {
  display: flex;
}

.ptr-area[data-state="refreshing"] .ptr-hint,
.ptr-area[data-state="finishing"] .ptr-hint {
  display: none;
}

.ptr-spinner {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
}

.ptr-area[data-state="refreshing"] .ptr-spinner {
  animation: spin 0.75s linear infinite;
}

.ptr-loader-text {
  font-size: 13px;
  font-weight: 600;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.home-header {
  text-align: center;
  margin: 14px 0 20px;
}

.balance-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.balance {
  font-size: clamp(34px, 10vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.card-wrap {
  margin-bottom: 0;
  perspective: 900px;
}

.card-stage {
  transform-style: preserve-3d;
  will-change: transform;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 1.586 / 1;
  border-radius: 22px;
  padding: 18px 18px 16px;
  background: linear-gradient(
    135deg,
    var(--card-a) 0%,
    var(--card-b) 48%,
    var(--card-c) 100%
  );
  box-shadow: 0 18px 36px rgba(10, 18, 48, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform-style: preserve-3d;
  will-change: transform;
  transition: box-shadow 0.25s ease;
  animation: cardFloat 4.8s ease-in-out infinite;
  touch-action: manipulation;
}

.card.is-tilting {
  animation: none;
  transition: transform 0.08s ease-out, box-shadow 0.15s ease;
}

.card.is-returning {
  animation: none;
  transition: transform 0.45s cubic-bezier(0.22, 1.2, 0.36, 1),
    box-shadow 0.35s ease;
}

@keyframes cardFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.card-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0) 70%
  );
  pointer-events: none;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.card-bank {
  font-size: clamp(17px, 4.6vw, 20px);
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.98;
  padding-top: 2px;
}

.card-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.mc-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mc-circles {
  position: relative;
  width: 34px;
  height: 22px;
  display: block;
}

.mc-circle {
  position: absolute;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  opacity: 0.95;
}

.mc-circle-left {
  left: 0;
  background: #eb001b;
}

.mc-circle-right {
  right: 0;
  background: #f79e1b;
  opacity: 0.95;
}

.badge-mastercard {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  text-transform: none;
}

.card-number-row {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -24px;
  z-index: 2;
  width: 100%;
  height: 48px;
  pointer-events: none;
}

.card-number {
  width: 100%;
  margin: 0;
  font-size: clamp(17px, 5vw, 24px);
  letter-spacing: 0.09em;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  word-break: keep-all;
  padding: 0 12px;
  line-height: 48px;
  pointer-events: none;
}

.card-bottom {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.45fr 0.7fr 0.55fr;
  gap: 8px;
  align-items: end;
}

.card-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 5px;
}

.card-value {
  display: block;
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 650;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cvv-block {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  padding: 4px 2px;
  margin: -4px -2px;
}

.cvv-block:active {
  background: rgba(255, 255, 255, 0.08);
}

.transactions-title,
.screen-title {
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 14px;
  color: var(--text);
}

.screen-header {
  margin-bottom: 8px;
}

.transactions-list,
.transactions-grouped {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tx-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.tx-date {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 2px 2px;
}

.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tx-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tx-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tx-dot {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  position: relative;
}

.tx-dot::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.tx-dot.deposit {
  background: rgba(93, 222, 165, 0.16);
}

.tx-dot.deposit::after {
  background: #5ddea5;
}

.tx-dot.withdrawal {
  background: rgba(255, 123, 138, 0.16);
}

.tx-dot.withdrawal::after {
  background: #ff7b8a;
}

.tx-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-sub {
  font-size: 12px;
  color: var(--muted);
}

.tx-amount {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tx-amount.deposit {
  color: #5ddea5;
}

.tx-amount.withdrawal {
  color: #ff7b8a;
}

.transactions-empty {
  display: none;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 16px 0 8px;
}

.transactions-empty.is-visible {
  display: block;
}

.show-more {
  display: none;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.show-more.is-visible {
  display: block;
}

.show-more:active {
  background: rgba(255, 255, 255, 0.1);
}

.transfer-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 8px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}

.field-static,
.field-input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 16px;
}

.field-static {
  display: flex;
  align-items: center;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.field-input {
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.field-input:focus {
  border-color: rgba(110, 168, 255, 0.55);
}

.amount-wrap {
  position: relative;
}

.amount-prefix {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}

.amount-input {
  padding-left: 30px;
}

.transfer-btn {
  width: 100%;
  min-height: 54px;
  margin-top: 8px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #3b6fe0, #6b3fd6);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  opacity: 0.45;
  cursor: not-allowed;
}

.transfer-note {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 6px 10px calc(6px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(11, 16, 32, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 50;
}

.nav-btn {
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
}

.nav-btn.is-active {
  color: var(--accent);
}

.nav-icon {
  width: 22px;
  height: 22px;
}

@media (max-width: 360px) {
  .card {
    padding: 16px 14px 14px;
  }

  .card-number {
    letter-spacing: 0.05em;
    font-size: clamp(15px, 4.6vw, 18px);
  }

  .card-bottom {
    gap: 6px;
  }
}
