:root {
  --bg: var(--tg-theme-bg-color, #f6f8f7);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #18201c);
  --muted: var(--tg-theme-hint-color, #718078);
  --accent: var(--tg-theme-button-color, #2f6b55);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(45, 67, 56, .12);
  --soft: rgba(47, 107, 85, .08);
  --success: #2f6b55;
  --warning: #8a6500;
  --danger: #a43f3f;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(22, 35, 29, .06);
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--text); }
body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  padding:env(safe-area-inset-top) env(safe-area-inset-right)
          calc(84px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
button,input,select,textarea { font:inherit; }
.hidden { display:none !important; }
.topbar {
  position:sticky; top:0; z-index:20; min-height:68px; display:flex; align-items:center; gap:10px;
  padding:10px 14px; background:color-mix(in srgb,var(--bg) 92%,transparent);
  backdrop-filter:blur(18px); border-bottom:1px solid var(--line);
}
.brand { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.brand-mark {
  width:38px; height:38px; border-radius:12px; display:grid; place-items:center;
  background:var(--accent); color:var(--accent-text); font-weight:800;
}
.brand-title { font-size:16px; font-weight:750; line-height:1.1; }
.brand-subtitle { margin-top:3px; color:var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.icon-btn { width:38px; height:38px; border:0; border-radius:12px; background:transparent; color:var(--text); font-size:24px; cursor:pointer; }
.screen { max-width:720px; margin:0 auto; padding:18px 14px 30px; }
.hero,.card {
  background:var(--card); border:1px solid var(--line); box-shadow:var(--shadow); border-radius:var(--radius);
}
.hero { padding:18px; border-radius:24px; background:linear-gradient(145deg,var(--card),var(--soft)); }
.card { padding:16px; }
.eyebrow { color:var(--accent); font-weight:700; font-size:13px; margin-bottom:8px; }
h1 { margin:0 0 8px; font-size:27px; line-height:1.15; letter-spacing:-.5px; }
h2 { margin:0 0 10px; font-size:21px; line-height:1.2; }
h3 { margin:0; font-size:16px; }
p { line-height:1.5; }
.muted { color:var(--muted); }
.notice {
  margin:14px 0; padding:12px 14px; background:var(--soft); border:1px solid var(--line);
  border-radius:14px; font-size:13px; color:var(--muted); line-height:1.45;
}
.notice.warning { background:rgba(255,193,7,.10); color:var(--warning); }
.notice.success { background:rgba(47,107,85,.10); color:var(--success); }
.grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.action-card { text-align:left; cursor:pointer; min-height:124px; display:flex; flex-direction:column; justify-content:space-between; }
.card-icon { font-size:28px; }
.card-status { margin-top:8px; font-size:12px; color:var(--muted); }
.card-status.ok { color:var(--accent); font-weight:700; }
.btn {
  width:100%; border:0; border-radius:14px; padding:14px 16px; cursor:pointer; font-weight:700;
  background:var(--accent); color:var(--accent-text);
}
.btn.secondary { background:var(--soft); color:var(--accent); border:1px solid var(--line); }
.btn.ghost { background:transparent; color:var(--text); border:1px solid var(--line); }
.btn:disabled { opacity:.55; cursor:not-allowed; }
.btn-row { display:flex; gap:10px; margin-top:14px; }
.btn-row .btn { flex:1; }
.bottom-nav {
  position:fixed; z-index:30; left:0; right:0; bottom:0; display:grid; grid-template-columns:repeat(4,1fr);
  padding:7px 8px calc(7px + env(safe-area-inset-bottom));
  background:color-mix(in srgb,var(--card) 94%,transparent); backdrop-filter:blur(18px); border-top:1px solid var(--line);
}
.nav-item { border:0; background:transparent; color:var(--muted); display:flex; flex-direction:column; align-items:center; gap:3px; font-size:11px; padding:5px; }
.nav-item.active { color:var(--accent); font-weight:700; }
.nav-icon { font-size:21px; }
.progress-wrap { margin:4px 0 18px; }
.progress-meta { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; margin-bottom:7px; }
.progress { height:8px; background:var(--soft); border-radius:99px; overflow:hidden; }
.progress > div { height:100%; background:var(--accent); border-radius:99px; transition:width .2s ease; }
.question-card { padding:18px; }
.question-number { color:var(--accent); font-weight:750; font-size:13px; margin-bottom:8px; }
.question-title { font-size:21px; line-height:1.25; margin-bottom:8px; font-weight:760; }
.question-help { color:var(--muted); font-size:13px; margin-bottom:16px; line-height:1.45; }
.field { margin:14px 0; }
label { display:block; font-weight:650; margin-bottom:7px; font-size:14px; }
input,select,textarea {
  width:100%; border:1px solid var(--line); background:var(--card); color:var(--text);
  border-radius:13px; padding:13px 14px; outline:none;
}
textarea { min-height:110px; resize:vertical; }
.scale { display:grid; grid-template-columns:repeat(6,1fr); gap:8px; }
.scale button,.choice button {
  border:1px solid var(--line); background:var(--card); color:var(--text);
  border-radius:12px; padding:12px 6px; font-weight:700; cursor:pointer;
}
.scale button.selected,.choice button.selected { background:var(--accent); color:var(--accent-text); border-color:var(--accent); }
.choice { display:grid; gap:8px; }
.section-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:22px 2px 10px; }
.list { display:grid; gap:10px; }
.med-meta { color:var(--muted); font-size:13px; margin-top:6px; }
.med-actions { display:flex; gap:8px; margin-top:12px; }
.med-actions .btn { padding:10px 12px; font-size:13px; }
.kpis { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.kpi { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px; }
.kpi-label { color:var(--muted); font-size:12px; }
.kpi-value { margin-top:5px; font-size:23px; font-weight:800; }
.empty { text-align:center; padding:26px 18px; color:var(--muted); background:var(--card); border:1px dashed var(--line); border-radius:16px; }
.toast {
  position:fixed; left:50%; bottom:92px; transform:translateX(-50%); z-index:100;
  padding:11px 15px; border-radius:12px; background:#202923; color:#fff; box-shadow:var(--shadow);
  font-size:13px; max-width:calc(100% - 32px); text-align:center;
}
.modal-backdrop { position:fixed; inset:0; z-index:80; background:rgba(12,20,16,.45); display:flex; align-items:flex-end; justify-content:center; }
.modal { width:min(720px,100%); max-height:88vh; overflow:auto; background:var(--bg); border-radius:24px 24px 0 0; padding:18px 16px calc(22px + env(safe-area-inset-bottom)); }
.modal-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.modal-close { border:0; background:var(--soft); color:var(--text); width:36px; height:36px; border-radius:12px; font-size:20px; }
.onboarding { min-height:70vh; display:flex; flex-direction:column; justify-content:center; }
.onboarding .hero { padding:24px; }
.steps { display:grid; gap:9px; margin:18px 0; }
.step { display:flex; gap:10px; align-items:flex-start; font-size:14px; color:var(--muted); }
.step-num { flex:0 0 26px; width:26px; height:26px; border-radius:50%; display:grid; place-items:center; background:var(--soft); color:var(--accent); font-weight:800; }
.google-box { margin-top:12px; }
.google-state { font-weight:750; margin-bottom:5px; }
.link-btn { display:inline-block; margin-top:10px; color:var(--accent); font-weight:700; text-decoration:none; }
@media (max-width:420px) {
  .screen { padding-left:12px; padding-right:12px; }
  .grid { gap:9px; }
  .card { padding:14px; }
  h1 { font-size:24px; }
}
