:root {
  --bg-top: #0b111a;
  --bg-bottom: #06090e;
  --text: #ffffff;
  --text-muted: #6c7a8c;
  --text-soft: #8fa0b5;
  --text-silver: rgba(255, 255, 255, 0.82);
  --glass: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.08);
  --danger: #ff6b7a;
  --success: #3dd68c;
  --pending: #f0c674;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  overflow-x: hidden;
}

/* Premium Cosmic Dark atmospheric glows */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
}

body::before {
  top: -12%;
  right: -18%;
  width: min(72vw, 420px);
  height: min(72vw, 420px);
  background: rgba(255, 171, 0, 0.04);
}

body::after {
  bottom: -8%;
  left: -22%;
  width: min(78vw, 460px);
  height: min(78vw, 460px);
  background: rgba(36, 129, 204, 0.04);
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(18px + env(safe-area-inset-top, 0px))
    20px
    calc(18px + env(safe-area-inset-bottom, 0px));
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.view {
  display: none;
  width: 100%;
  animation: fadeRise 0.28s ease;
}

.view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

@keyframes fadeRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ——— Home ——— */
.home-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 12px 0 8px;
}

.balance-card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  padding: 22px 20px 18px;
  box-shadow:
    inset 0 -10px 20px rgba(255, 160, 0, 0.03),
    0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.balance-card::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 171, 0, 0.35) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.balance-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.balance-value {
  font-size: clamp(2rem, 9vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #ffffff;
}

.balance-currency {
  font-size: 1.15rem;
  font-weight: 600;
  color: #ffffff;
  opacity: 0.95;
}

.balance-star {
  margin-left: 2px;
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255, 196, 0, 0.55));
  transform: translateY(1px);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 16px;
  border-radius: 20px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: grid;
  gap: 12px;
}

.btn {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  border: 0;
  border-radius: 20px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(90deg, #1d54a1 0%, #173f7a 100%);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(23, 63, 122, 0.35);
}

.btn-arrow {
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 500;
  opacity: 0.95;
}

.btn-secondary {
  background: transparent;
  color: var(--text-silver);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.btn-secondary:active {
  border-color: rgba(255, 255, 255, 0.28);
}

/* ——— Shared subviews ——— */
.link-back {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 0;
  margin: 0 0 14px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.title {
  margin: 0 0 18px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow:
    inset 0 -10px 20px rgba(255, 160, 0, 0.02),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

.form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(29, 84, 161, 0.75);
}

.field select option {
  background: #0b111a;
  color: #fff;
}

.hint {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.success-panel {
  margin-top: 8px;
  text-align: center;
  padding: 28px 18px;
}

.success-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(61, 214, 140, 0.16);
  color: var(--success);
  font-size: 1.4rem;
  font-weight: 700;
}

.success-title {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 650;
}

.history-list {
  display: grid;
  gap: 10px;
}

.tx {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.tx-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.tx-title {
  font-weight: 650;
}

.tx-amount.credit {
  color: var(--success);
}

.tx-amount.debit {
  color: var(--danger);
}

.tx-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.status-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.status-pill.success {
  color: var(--success);
}

.status-pill.pending {
  color: var(--pending);
}

.status-pill.failed {
  color: var(--danger);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  margin-top: 28px;
}

.app-footer {
  margin-top: auto;
  padding-top: 22px;
  text-align: center;
  font-size: 12px;
  color: #ffffff;
  opacity: 0.3;
  letter-spacing: 0.01em;
  user-select: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(14, 20, 30, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 14px;
  max-width: min(92vw, 420px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 30;
  font-size: 0.92rem;
}

.loader {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(6, 9, 14, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 40;
  color: var(--text-soft);
  font-weight: 600;
}

.loader.is-visible {
  display: grid;
}

@media (min-height: 720px) {
  .home-stage {
    gap: 22px;
  }

  .balance-card {
    padding: 26px 22px 20px;
  }
}
