:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111);
  --muted: var(--tg-theme-hint-color, #8a8f98);
  --accent: var(--tg-theme-button-color, #2ea36b);
  --accentText: var(--tg-theme-button-text-color, #fff);
  --ok: #2ea36b; --warn: #e0a100; --bad: #e0533d;
  --p: #4f8cff; --f: #f0a53a; --c: #9b6bff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font: 15px/1.4 -apple-system, system-ui, Roboto, sans-serif; background: var(--bg2); color: var(--text); padding-bottom: 76px; }
.screen { padding: 16px; max-width: 560px; margin: 0 auto; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; } h3 { margin-top: 20px; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.card { background: var(--bg); border-radius: 16px; padding: 16px; margin-top: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; }
.streak { background: var(--bg); border-radius: 20px; padding: 6px 12px; font-weight: 600; }

label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
input, select { width: 100%; margin-top: 4px; padding: 12px; font-size: 16px; border: 0; border-radius: 12px; background: var(--bg); color: var(--text); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-top: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; color: var(--text); font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accentText); }
button { font: inherit; cursor: pointer; }
.primary { width: 100%; margin-top: 20px; padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accentText); font-weight: 600; font-size: 16px; }
.ghost { width: 100%; margin-top: 10px; padding: 12px; border: 0; border-radius: 12px; background: var(--bg); color: var(--accent); }

.ringCard { display: grid; grid-template-columns: 130px 1fr; gap: 16px; align-items: center; position: relative; }
.ring { width: 130px; height: 130px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--bg2); }
.ring .bar { stroke: var(--ok); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .5s, stroke .3s; }
.ringText { position: absolute; left: 16px; width: 130px; text-align: center; }
.big { font-size: 26px; font-weight: 700; }
.macro { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; align-items: center; font-size: 13px; margin: 6px 0; }
.macro b { font-weight: 500; font-size: 12px; white-space: nowrap; }
.pb { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.pb i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .5s; }
#pbP { background: var(--p); } #pbF { background: var(--f); } #pbC { background: var(--c); }

.actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.act { border: 0; background: var(--bg); border-radius: 14px; padding: 12px 6px; font-size: 22px; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.act span { font-size: 12px; }
.act.accent { background: var(--accent); color: var(--accentText); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { background: var(--bg); border-radius: 12px; padding: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list .t { font-weight: 500; } .list .s { font-size: 12px; color: var(--muted); }
.del { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px 8px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bg2); }
.tabs button { flex: 1; border: 0; background: none; font-size: 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; }
.tabs span { font-size: 11px; } .tabs .on { color: var(--accent); }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
.sheetBody { background: var(--bg2); width: 100%; max-height: 85vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 12px 16px 24px; }
.grab { width: 40px; height: 4px; background: var(--muted); opacity: .4; border-radius: 2px; margin: 0 auto 12px; }
textarea { width: 100%; min-height: 90px; padding: 12px; font: inherit; font-size: 16px; border: 0; border-radius: 12px; background: var(--bg); color: var(--text); resize: vertical; }
.item { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item input { width: 80px; padding: 6px 8px; margin: 0; text-align: right; background: var(--bg2); }
.spinner { text-align: center; padding: 30px; color: var(--muted); }
.idea { background: var(--bg); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.idea button { margin-top: 8px; border: 0; background: var(--bg2); color: var(--accent); padding: 8px 12px; border-radius: 10px; }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .col i { width: 100%; border-radius: 4px 4px 0 0; background: var(--muted); opacity: .5; }
.chart .col i.ok { background: var(--ok); opacity: 1; }
.chart .col span { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* ---- v2: премиум, бейджи, аналитика ---- */
.seg.mini { margin: 0; padding: 3px; } .seg.mini button { padding: 6px 10px; font-size: 12px; }
.prem { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.prem b { font-size: 16px; }
.payBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.payBtns button { border: 0; border-radius: 12px; padding: 12px; font-weight: 600; background: var(--accent); color: var(--accentText); }
.payBtns button.ton { background: #0098ea; color: #fff; }
.perks { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.perks li { margin: 3px 0; }
.switch { display: flex; justify-content: space-between; align-items: center; color: var(--text); font-size: 15px; }
.switch input { width: auto; transform: scale(1.4); margin: 0; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; font-size: 12px; }
.badge img { width: 100%; aspect-ratio: 1; border-radius: 50%; }
.badge.locked img { filter: grayscale(1); opacity: .35; }
.badge button, .badge a { display: block; margin-top: 6px; border: 0; border-radius: 8px; padding: 6px; background: var(--accent); color: var(--accentText); font-size: 12px; text-decoration: none; }
.badge a { background: var(--bg2); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.lock { text-align: center; }
.lock button { margin-top: 10px; }
.wline { width: 100%; height: 120px; }
.wline path { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.wline circle { fill: var(--accent); }
.row2 { display: flex; gap: 8px; margin-top: 10px; }
.row2 input { margin: 0; }
.row2 button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--accent); color: var(--accentText); }
.aiLeft { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
.celebrate { text-align: center; }
.celebrate img { width: 60%; border-radius: 50%; margin: 10px auto; display: block; }
.seg.mini button { white-space: nowrap; }
