:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg2: var(--tg-theme-secondary-bg-color, #161a21);
  --text: var(--tg-theme-text-color, #eef2f7);
  --hint: var(--tg-theme-hint-color, #8b95a5);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(255, 255, 255, 0.08);
  --good: #2fd08a;
  --warn: #ffb020;
  --bad: #ff5c5c;
  --radius: 16px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

#app { max-width: 560px; margin: 0 auto; padding-bottom: 86px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, #2ea6ff, #7c5cff);
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 18px;
}
.brand-name { font-weight: 650; letter-spacing: 0.2px; }
.brand-sub { font-size: 12px; color: var(--hint); }

.ghost {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 17px;
}
.ghost:active { transform: scale(0.94); }

.banner {
  margin: 0 16px 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 176, 32, 0.12); border: 1px solid rgba(255, 176, 32, 0.35);
  color: #ffcf70; font-size: 12.5px;
}

main { padding: 0 16px; }

.card {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }

.balance-label { font-size: 12.5px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.6px; }
.balance-value { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; margin: 2px 0 6px; }
.balance-value small { font-size: 16px; color: var(--hint); font-weight: 500; }

.stat-row { display: flex; gap: 8px; margin-top: 10px; }
.stat {
  flex: 1; background: rgba(255,255,255,0.03); border-radius: 12px;
  padding: 9px 10px; border: 1px solid var(--line);
}
.stat .k { font-size: 11px; color: var(--hint); }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 1px; }

.section-title {
  font-size: 12.5px; color: var(--hint); text-transform: uppercase;
  letter-spacing: 0.7px; margin: 18px 2px 8px;
}

.offer {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; margin-bottom: 9px;
}
.offer .ic {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  background: rgba(46, 166, 255, 0.14); color: var(--accent);
  display: grid; place-items: center; font-size: 19px;
}
.offer .meta { flex: 1; min-width: 0; }
.offer .t { font-weight: 600; font-size: 14.5px; }
.offer .s { font-size: 12px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer .pay { font-weight: 700; color: var(--good); font-size: 14px; margin-right: 6px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 12px; padding: 11px 16px;
  font-size: 14.5px; font-weight: 600; width: 100%;
  transition: transform 0.06s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(255, 92, 92, 0.15); color: var(--bad); border: 1px solid rgba(255,92,92,0.35); }
.btn.small { width: auto; padding: 8px 13px; font-size: 13px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--hint); margin-bottom: 6px; }
input, select {
  width: 100%; background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; font-size: 15px; font-family: inherit;
  appearance: none; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .l { min-width: 0; }
.list-item .lt { font-weight: 550; }
.list-item .ls { font-size: 11.5px; color: var(--hint); }
.amt.pos { color: var(--good); font-weight: 650; }
.amt.neg { color: var(--bad); font-weight: 650; }

.pill {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--hint); white-space: nowrap;
}
.pill.pending { color: var(--warn); border-color: rgba(255,176,32,0.4); background: rgba(255,176,32,0.1); }
.pill.paid { color: var(--good); border-color: rgba(47,208,138,0.4); background: rgba(47,208,138,0.1); }
.pill.rejected { color: var(--bad); border-color: rgba(255,92,92,0.4); background: rgba(255,92,92,0.1); }

.muted { color: var(--hint); font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; max-width: 560px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; background: none; border: 0; color: var(--hint);
  font-size: 11px; font-family: inherit; font-weight: 550;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
}
.tab span { font-size: 17px; line-height: 1; }
.tab.active { color: var(--accent); }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.55); display: flex; align-items: flex-end;
  animation: fade 0.15s ease;
}
.sheet {
  width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
  max-height: 88vh; overflow-y: auto;
}
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: var(--line); margin: 6px auto 14px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(28, 32, 40, 0.97); color: #fff; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; font-size: 13.5px; z-index: 60;
  max-width: 90vw; text-align: center;
}

.skeleton {
  height: 84px; border-radius: 14px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--bg2) 25%, rgba(255,255,255,0.05) 50%, var(--bg2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
.skeleton.short { height: 40px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.countdown { font-size: 46px; font-weight: 700; text-align: center; padding: 26px 0 10px; letter-spacing: -1px; }
.progress { height: 6px; background: rgba(255,255,255,0.07); border-radius: 99px; overflow: hidden; margin: 6px 0 18px; }
.progress > div { height: 100%; background: var(--accent); width: 0%; transition: width 0.95s linear; }
