/* В Telegram цвета приходят из его темы (--tg-theme-*), вне Telegram — из системной темы */
:root { --fb-bg: #0f1115; --fb-bg2: #171a21; --fb-text: #f2f4f8; --fb-hint: #8a93a6; }
@media (prefers-color-scheme: light) {
  :root { --fb-bg: #f4f5f8; --fb-bg2: #ffffff; --fb-text: #15181e; --fb-hint: #6b7280; }
}
:root {
  --bg: var(--tg-theme-bg-color, var(--fb-bg));
  --bg2: var(--tg-theme-secondary-bg-color, var(--fb-bg2));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --accent: var(--tg-theme-button-color, #3d8bfd);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --ok: #2fbf71;
  --warn: #f0a33a;
  --bad: #e5484d;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 520px; margin: 0 auto; padding: 12px 16px 96px; }
[hidden] { display: none !important; }
h2 { margin: 8px 0 6px; font-size: 22px; }
h3 { margin: 20px 0 8px; font-size: 17px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.op { opacity: .85; }
.title { font-weight: 600; font-size: 16px; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hello { display: flex; gap: 10px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; }
.name { font-weight: 600; }
.chip { background: var(--warn); color: #000; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }

.balance-card { border-radius: 20px; padding: 18px; color: #fff;
  background: linear-gradient(135deg, #3d8bfd 0%, #7b5cff 60%, #c548ff 100%);
  box-shadow: 0 10px 30px rgba(91, 92, 255, .25); }
.balance { font-size: 38px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0; }
.balance-row { display: flex; gap: 24px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.25); }
.balance-row > div > div:last-child { font-weight: 600; }

.card { background: var(--bg2); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.ad-card { display: flex; gap: 16px; align-items: center; }
.ad-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: rgba(127,127,127,.2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .5s ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text b { font-size: 24px; }

.streak-card { display: flex; flex-direction: column; gap: 12px; }
.streak-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.sday { border-radius: 10px; padding: 6px 0; text-align: center; background: rgba(127,127,127,.12); font-size: 11px; color: var(--hint); }
.sday b { display: block; font-size: 13px; color: var(--text); }
.sday.done { background: linear-gradient(135deg, #ff9a3d, #ff5a5f); color: #fff; }
.sday.done b { color: #fff; }
.sday.next { outline: 2px solid #ff9a3d; outline-offset: -2px; }

.ref-hero { text-align: center; color: #fff; background: linear-gradient(135deg, #2fbf71, #1a9e8f); }
.ref-big { font-size: 40px; font-weight: 800; }
.ref-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ref-stats .card { margin-top: 14px; padding: 12px; text-align: center; }
.pbar { height: 6px; border-radius: 99px; background: rgba(127,127,127,.2); overflow: hidden; margin-top: 6px; width: 100%; }
.pbar i { display: block; height: 100%; background: var(--ok); }
.row .left { flex: 1; }
.task-done { color: var(--ok); font-weight: 600; white-space: nowrap; }

.btn { border: 0; border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.big { padding: 14px; font-size: 16px; margin-top: 4px; }

.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--hint); }
input, select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid rgba(127,127,127,.25);
  background: var(--bg); color: var(--text); font: inherit; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

.wall { display: flex; align-items: center; gap: 12px; }
.wall .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; font-size: 22px; flex: none; }
.wall .grow { flex: 1; min-width: 0; }
.empty { text-align: center; padding: 28px 12px; }
.empty .big-emoji { font-size: 40px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--bg2); border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.row .left { min-width: 0; }
.row .left div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plus { color: var(--ok); font-weight: 700; white-space: nowrap; }
.minus { color: var(--bad); font-weight: 700; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.badge.pending { background: rgba(240,163,58,.2); color: var(--warn); }
.badge.paid { background: rgba(47,191,113,.2); color: var(--ok); }
.badge.rejected { background: rgba(229,72,77,.2); color: var(--bad); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--bg2); border-top: 1px solid rgba(127,127,127,.15); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 130px; background: none; border: 0; color: var(--hint); font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; cursor: pointer; }
.tabs button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs button.active { color: var(--accent); font-weight: 600; }
.tabs button.active span { filter: none; opacity: 1; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 50; padding: 16px; }
.ad-box { width: 100%; max-width: 420px; background: var(--bg2); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ad-label { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: 1px; }
.ad-visual { height: 220px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 16px; color: #fff;
  background: linear-gradient(120deg, #ff6a3d, #ff3d77, #7b5cff); background-size: 200% 200%; animation: shift 4s ease infinite; }
.ad-brand { font-size: 28px; font-weight: 800; }
@keyframes shift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.progress { height: 6px; background: rgba(127,127,127,.2); border-radius: 99px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: #222a; backdrop-filter: blur(8px); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60;
  font-size: 14px; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.ok { background: rgba(47,191,113,.95); }
.toast.bad { background: rgba(229,72,77,.95); }
.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
