:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --card: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #708499);
  --accent: var(--tg-theme-button-color, #5288c1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e74c3c;
  --success: #2ecc71;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
}

/* ====== TOPBAR ====== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px;
}
.brand-logo { font-size: 20px; }

.counters {
  font-size: 13px; color: var(--hint);
  display: flex; align-items: baseline; gap: 4px;
}
.counters span#mau {
  color: var(--accent); font-weight: 700; font-size: 15px;
}
.counter-label { color: var(--hint); }

/* ====== TABS ====== */
.tabs {
  display: flex; gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  position: sticky; top: 57px; z-index: 9;
}

.tab {
  flex: 1;
  padding: 10px 8px;
  background: var(--card);
  color: var(--hint);
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

/* ====== MAIN ====== */
main { padding: 12px 16px 80px; }

.loader { text-align: center; padding: 40px; color: var(--hint); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--hint);
}
.empty .icon { font-size: 48px; display: block; margin-bottom: 12px; }

/* ====== CARD ====== */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.product {
  display: flex; flex-direction: column; gap: 12px;
}

.product-head {
  display: flex; align-items: flex-start; gap: 12px;
}

.product-emoji {
  font-size: 28px; line-height: 1;
  flex-shrink: 0;
}

.product-info { flex: 1; min-width: 0; }

.product-info h3 {
  font-size: 15px; font-weight: 600;
  margin-bottom: 4px;
}

.product-desc {
  font-size: 13px; color: var(--hint);
  line-height: 1.4;
}

.product-bottom {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}

.product-price {
  font-size: 18px; font-weight: 700;
  color: var(--accent);
}

.product-stock {
  font-size: 12px; color: var(--hint);
  margin-top: 2px;
}

.btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:active { opacity: .75; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

/* ====== PROFILE ====== */
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .label { color: var(--hint); font-size: 14px; }
.profile-row .value { font-weight: 600; }

/* ====== PURCHASE ====== */
.purchase {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.purchase-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.purchase-title { font-weight: 600; font-size: 14px; }
.purchase-price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.purchase-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--hint);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-waiting { background: rgba(241,196,15,.15); color: #f1c40f; }
.badge-paid { background: rgba(52,152,219,.15); color: #3498db; }
.badge-completed { background: rgba(46,204,113,.15); color: var(--success); }
.badge-cancelled { background: rgba(231,76,60,.15); color: var(--danger); }

/* ====== TOAST ====== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(0,0,0,.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
