:root {
  --bg: var(--tg-theme-bg-color, #0b1f22);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #12292c);
  --text: var(--tg-theme-text-color, #eef6f4);
  --hint: var(--tg-theme-hint-color, #8fa8a6);
  --link: var(--tg-theme-link-color, #2ec49e);
  --button: var(--tg-theme-button-color, #2ec49e);
  --button-text: var(--tg-theme-button-text-color, #073b4c);
  --separator: rgba(255, 255, 255, 0.08);
  --card: var(--bg-secondary);
  --gold: #ffc43d;
  --radius: 16px;
  --safe-top: max(env(safe-area-inset-top), 8px);
  --safe-bottom: max(env(safe-area-inset-bottom), 8px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--tg-theme-bg-color, #f3f8f7);
    --bg-secondary: var(--tg-theme-secondary-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #0b1f22);
    --hint: var(--tg-theme-hint-color, #5c7472);
    --separator: rgba(0, 0, 0, 0.08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

.hidden { display: none !important; }

.full-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}
.full-message-icon { font-size: 48px; margin-bottom: 12px; }
.full-message-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.full-message-text { color: var(--hint); font-size: 14px; max-width: 320px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 16px 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2ec49e, #073b4c);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.hello { font-weight: 700; font-size: 15px; }
.sub { font-size: 12px; color: var(--hint); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--card); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:active { opacity: 0.7; }

.content {
  padding: 0 16px calc(var(--safe-bottom) + 88px);
  max-width: 480px;
  margin: 0 auto;
}

.hero-card {
  background: linear-gradient(135deg, #0b3a4c, #0e6e5e);
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 14px;
}
.hero-label { font-size: 13px; opacity: 0.85; }
.hero-value { font-size: 32px; font-weight: 800; margin: 4px 0 12px; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}
.chip b { font-weight: 700; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-label { font-size: 12px; color: var(--hint); margin-bottom: 6px; }
.stat-value { font-size: 20px; font-weight: 700; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-weight: 700; margin-bottom: 12px; font-size: 15px; }

.ref-box { display: flex; gap: 8px; margin-bottom: 10px; }
.ref-box input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}
.btn-small {
  border: none;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-full {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn-small:active, .btn-full:active { opacity: 0.8; }

.bank-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 13px;
}
.bank-row:last-of-type { border-bottom: none; }
.bank-row span { color: var(--hint); }
.bank-hint { font-size: 11px; color: var(--hint); margin-top: 8px; }

.ticker {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-bottom) + 10px);
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
.toast {
  background: rgba(7, 59, 76, 0.95);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 12.5px;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
