/* ===================================================================
   Design tokens — pulled directly from the existing app's screens
   (dark navy background, green accent, capitalized card-head labels
   with a status dot). Intentionally not reinventing the visual
   language — this page has to sit next to the existing ones.
=================================================================== */
:root {
  --bg: #0a0e16;
  --surface-1: #121a25;
  --surface-2: #19222f;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #eef2f7;
  --text-secondary: #8d99ab;
  --text-muted: #5c6779;

  --green: #32d583;
  --green-strong: #22c55e;
  --green-dim: rgba(50, 213, 131, 0.14);
  --amber: #f5b942;
  --red: #f2685f;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button { cursor: pointer; min-height: 44px; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
nav { display: flex; gap: 18px; margin-top: 18px; }
nav a { color: var(--green); text-decoration: none; padding-block: 8px; }
.brand-note { font-size: 13px; color: var(--text-secondary); }
.notice { font-size: 13px; color: var(--text-secondary); line-height: 1.9; }
.notice.error { color: var(--red); }
.product { border-top: 1px solid var(--border); padding-block: 12px; }
.product h3 { font-size: 15px; }
.product p { color: var(--text-secondary); font-size: 13px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; } }

html, body {
  margin: 0;
  background: #000000;
  color: var(--text-primary);
  font-family: 'Vazirmatn', 'Tahoma', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* Keeps the page phone-width even when previewed in a wide desktop
   browser — inside the real Telegram Mini App WebView this is a no-op
   since the viewport is already narrow. */
.app-frame {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 32px;
  position: relative; /* scopes the deposit sheet to the frame, not the full window */
}

.topbar {
  padding: 20px 20px 4px;
}
.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 24px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}
.card-head h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0;
}
.card-head .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* Balance card — this is the page's one deliberate hero moment */
.balance-card {
  text-align: center;
  padding: 28px 18px 22px;
  background: radial-gradient(120% 140% at 50% -10%, rgba(50, 213, 131, 0.10), transparent 60%), var(--surface-1);
}
.eyebrow {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
.balance-amount {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.balance-amount .unit {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
}
.sub-balances {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Top-up method buttons */
.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.method-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 6px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}
.method-btn:active {
  border-color: var(--border-strong);
  transform: scale(0.98);
}
.method-icon { font-size: 20px; }

.muted-line {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

/* Referral */
.referral-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.referral-row code {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
  direction: ltr;
  text-align: right;
}
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
}
.referral-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Transaction history */
.tx-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.tx-item:first-child { border-top: none; }
.tx-method { font-size: 13.5px; }
.tx-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.tx-amount { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tx-status {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-inline-start: 8px;
}
.tx-status.CONFIRMED { background: var(--green-dim); color: var(--green); }
.tx-status.PENDING { background: rgba(245, 185, 66, 0.14); color: var(--amber); }
.tx-status.REJECTED { background: rgba(242, 104, 95, 0.14); color: var(--red); }
.tx-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 18px 0;
}

.demo-notice {
  background: rgba(245, 185, 66, 0.12);
  color: var(--amber);
  font-size: 11.5px;
  text-align: center;
  padding: 8px 12px;
  margin: 0 0 4px;
}

/* Deposit sheet — the page's only other motion: answers a user tap */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 50;
  animation: fadeIn 0.18s ease-out;
}
.sheet-overlay[hidden] {
  display: none;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 80vh;
  overflow-y: auto;
}
.sheet-close {
  position: absolute;
  top: 12px;
  left: 14px;
  background: var(--surface-2);
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }

/* Shared sheet content elements (built dynamically in wallet.js) */
.sheet h3 { font-size: 16px; margin: 4px 0 14px; }
.sheet .field-label { font-size: 12.5px; color: var(--text-secondary); margin: 14px 0 6px; }
.sheet input[type="number"],
.sheet input[type="text"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}
.sheet .primary-btn {
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(180deg, var(--green-strong), #178a44);
  border: none;
  color: #06170d;
  font-weight: 600;
  font-size: 14.5px;
  padding: 13px;
  border-radius: var(--radius-md);
  font-family: inherit;
}
.sheet .primary-btn:disabled { opacity: 0.5; }
.sheet .address-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12px;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  color: var(--text-secondary);
}
.sheet .status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}
.dropzone img {
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}
