/* МаркНави Mini App. Telegram theme-переменные + фолбэки для браузера. */
:root {
  --bg: var(--tg-theme-bg-color, #0e1621);
  --sec-bg: var(--tg-theme-secondary-bg-color, #17212b);
  --card: var(--tg-theme-secondary-bg-color, #1c2733);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #7d8b99);
  --link: var(--tg-theme-link-color, #64b5ef);
  --btn: var(--tg-theme-button-color, #2ea6ff);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #2ea6ff;
  --red: #e5484d;
  --yellow: #f5a623;
  --green: #30a46c;
  --radius: 16px;
  --tabbar-h: 62px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }

/* Шапка */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand { font-weight: 700; font-size: 17px; }
.icon-btn { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; padding: 4px 6px; }
.icon-btn:active { opacity: 0.6; }

#screen { padding: 16px; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.lead { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.sub { color: var(--hint); }
.section-title { font-size: 15px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: 0.4px; margin: 22px 0 10px; }

/* Кнопки */
.btn { display: block; width: 100%; border: none; border-radius: var(--radius); padding: 15px; font-size: 16px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--btn); color: var(--btn-text); }
.btn-primary:active { opacity: 0.9; }
.btn-ghost { background: var(--sec-bg); color: var(--text); }
.btn-ghost:active { background: rgba(255,255,255,0.05); }
.btn[disabled] { opacity: 0.5; }
.btn + .btn { margin-top: 10px; }

/* Карточки */
.card { background: var(--card); border: 1px solid rgba(255,255,255,0.05); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-row { display: flex; align-items: center; gap: 12px; }

/* Онбординг: мультивыбор */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid rgba(255,255,255,0.14); background: var(--sec-bg); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  background: var(--sec-bg); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; cursor: pointer;
}
.opt.on { border-color: var(--accent); }
.opt .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--hint); flex: 0 0 auto; }
.opt.on .radio { border-color: var(--accent); background: radial-gradient(circle at center, var(--accent) 0 5px, transparent 6px); }
.sticky-cta { position: sticky; bottom: 12px; margin-top: 18px; }

/* Дашборд: hero-отсчёт */
.hero { background: linear-gradient(160deg, rgba(46,166,255,0.16), rgba(46,166,255,0.04)); border: 1px solid rgba(46,166,255,0.25); border-radius: 20px; padding: 22px; text-align: center; margin-bottom: 16px; }
.hero.red { background: linear-gradient(160deg, rgba(229,72,77,0.18), rgba(229,72,77,0.04)); border-color: rgba(229,72,77,0.35); }
.hero .cap { color: var(--hint); font-size: 13px; }
.hero .days { font-size: 52px; font-weight: 800; line-height: 1.05; margin: 4px 0; }
.hero .days.overdue { color: var(--red); }
.hero .what { font-weight: 600; }
.hero .cat { color: var(--hint); font-size: 14px; margin-top: 4px; }
.hero .date { margin-top: 8px; font-weight: 600; }

/* Мини-статы */
.stats { display: flex; gap: 10px; margin-bottom: 16px; }
.stat { flex: 1; background: var(--card); border-radius: 14px; padding: 12px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; }
.stat .l { color: var(--hint); font-size: 12px; margin-top: 2px; }

/* Кольцо прогресса */
.progress-card { display: flex; align-items: center; gap: 16px; }
.ring { --p: 0; position: relative; width: 60px; height: 60px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), rgba(255,255,255,0.1) 0);
  display: flex; align-items: center; justify-content: center; }
.ring::before { content: ""; width: 44px; height: 44px; border-radius: 50%; background: var(--card); position: absolute; }
.ring span { position: relative; font-size: 13px; font-weight: 700; }
.progress-card .txt { flex: 1; }

/* Категории со светофором */
.cat-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.cat-item:last-child { border-bottom: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); } .dot.green { background: var(--green); }
.cat-item .nm { flex: 1; font-size: 15px; }
.cat-item .dl { color: var(--hint); font-size: 13px; white-space: nowrap; }

/* Трекер: шаги */
.step { background: var(--card); border: 1px solid rgba(255,255,255,0.06); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
.step-head { display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hint); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.step.done .check { background: var(--green); border-color: var(--green); color: #fff; }
.step-head .st-title { flex: 1; font-weight: 600; font-size: 15px; }
.step.done .st-title { color: var(--hint); text-decoration: line-through; }
.step-head .caret { color: var(--hint); transition: transform 0.2s; }
.step.open .caret { transform: rotate(90deg); }
.step-body { padding: 0 14px 14px 50px; display: none; font-size: 14px; }
.step.open .step-body { display: block; }
.step-body .row { margin: 6px 0; }
.step-body .k { color: var(--hint); }
.step.locked .step-head { opacity: 0.65; }
.step .lock-badge { color: var(--hint); font-size: 12px; }

.cat-switch { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.cat-switch .chip { white-space: nowrap; }

/* Таймлайн/календарь */
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.tl-when { text-align: center; min-width: 58px; }
.tl-when .d { font-size: 20px; font-weight: 800; }
.tl-when .m { color: var(--hint); font-size: 12px; text-transform: uppercase; }
.tl-main { flex: 1; }
.tl-main .lbl { font-weight: 600; }
.tl-main .ct { color: var(--hint); font-size: 13px; }
.tl-left { color: var(--hint); font-size: 12px; white-space: nowrap; align-self: center; }
.tl-left.soon { color: var(--red); }

/* Аккордеоны знаний */
.acc { background: var(--card); border-radius: 14px; margin-bottom: 8px; overflow: hidden; }
.acc-head { padding: 14px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.acc-body { padding: 0 14px 14px; display: none; color: var(--text); font-size: 14px; }
.acc.open .acc-body { display: block; }
.acc-head .caret { color: var(--hint); }
.acc.open .caret { transform: rotate(90deg); }

/* Баннер-крючок */
.promo { background: linear-gradient(135deg, rgba(48,163,108,0.16), rgba(48,163,108,0.04)); border: 1px solid rgba(48,163,108,0.3); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.promo h3 { font-size: 16px; margin-bottom: 4px; }
.promo p { color: var(--hint); font-size: 13px; margin-bottom: 12px; }

/* Таб-бар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: var(--bg); border-top: 1px solid rgba(255,255,255,0.08);
}
.tabbar button {
  flex: 1; background: none; border: none; color: var(--hint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 8px 0;
}
.tabbar button .ic { font-size: 20px; }
.tabbar button.on { color: var(--accent); }

/* Модалка */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom,0px)); max-height: 88vh; overflow-y: auto; animation: up 0.22s ease; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--hint); opacity: 0.4; margin: 0 auto 14px; }
.sheet h2 { font-size: 20px; margin-bottom: 4px; }

/* Тарифы */
.plan { display: flex; align-items: center; gap: 12px; border: 2px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 14px; margin-bottom: 10px; cursor: pointer; }
.plan.on { border-color: var(--accent); }
.plan .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--hint); flex: 0 0 auto; }
.plan.on .radio { border-color: var(--accent); background: radial-gradient(circle at center, var(--accent) 0 6px, transparent 7px); }
.plan .pinfo { flex: 1; }
.plan .pt { font-weight: 700; }
.plan .pn { color: var(--hint); font-size: 13px; }
.plan .badge { background: var(--green); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }

/* Формы */
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--hint); font-size: 13px; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--sec-bg); color: var(--text); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; font-family: inherit;
}
.field textarea { min-height: 80px; resize: vertical; }

.disclaimer { color: var(--hint); font-size: 12px; margin-top: 16px; }
.error { color: var(--red); text-align: center; padding: 24px; }
.skeleton { height: 60px; border-radius: 14px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--sec-bg) 25%, rgba(255,255,255,0.05) 50%, var(--sec-bg) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.center { text-align: center; }
.pad { padding: 32px 16px; }
.badge-locked { font-size: 11px; color: var(--btn-text); background: var(--accent); padding: 3px 8px; border-radius: 999px; }
