/* =====================================================================
   Мини-приложение клиники — дизайн-система (МП-12, 18.11.2026)
   Один файл на все экраны. Архитектор может взять его в каркас как есть:
   токены — в :root, компоненты — классами без зависимостей.
   Тема: светлая/тёмная берётся из Telegram (WebApp.colorScheme →
   <html data-theme="light|dark">). Палитра — своя, демократовская:
   цвета темы Telegram пользователя не подмешиваем, чтобы оранжевый
   не спорил с синими/зелёными темами. Шапку красим setHeaderColor(--paper).
   ===================================================================== */

:root {
  /* поверхность */
  --paper:   #F2F3F4;   /* фон приложения */
  --surface: #FFFFFF;   /* листы и группы */
  --raised:  #FFFFFF;   /* нижние листы */
  --fill:    #EAECED;   /* неактивные заливки, дорожки */
  --fill-2:  #DFE2E4;
  --rule:    #E4E7E9;   /* разделители */
  /* текст */
  --ink:     #1C2326;
  --ink-2:   #3A4346;
  --hint:    #6A7377;   /* 4.8:1 на белом */
  --hint-2:  #8B9498;   /* только для неважного: подписи осей */
  /* бренд */
  --accent:       #EF521B;
  --accent-press: #D2440F;
  --accent-ink:   #FFFFFF;
  --accent-soft:  #FDEDE6;
  /* статусы */
  --red:    #C2352B;  --red-soft:   #FBE8E6;
  --amber:  #946200;  --amber-soft: #FFF2CF;
  --green:  #1D7A4F;  --green-soft: #E2F3E9;
  --blue:   #3966C9;  --blue-soft:  #E7EEFB;   /* только «прошлый период» на графиках */
  /* тени — светлая тема: почти невидимая подложка, без серых «карточных» теней */
  --lift: 0 1px 0 rgba(28,35,38,.04), 0 10px 24px -16px rgba(28,35,38,.18);
  --sheet-shadow: 0 -12px 40px -12px rgba(28,35,38,.28);
  --edge: transparent;  /* обводка поверхностей (в тёмной — волосок) */
  /* типографика */
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* радиусы: лист 18, элемент внутри 12, плашка 8, пилюля 999 */
  --r-sheet: 18px; --r-el: 12px; --r-tile: 9px;
  /* движение */
  --spring: cubic-bezier(.32,.72,0,1);
  --quick:  cubic-bezier(.2,.8,.2,1);
}

:root[data-theme="dark"] {
  --paper:   #0E1214;
  --surface: #171D20;
  --raised:  #1C2327;
  --fill:    #222A2E;
  --fill-2:  #2B3438;
  --rule:    #262E32;
  --ink:     #ECEFF0;
  --ink-2:   #C6CDD0;
  --hint:    #8F999D;
  --hint-2:  #6F797D;
  --accent:       #FF6A33;
  --accent-press: #FF875A;
  --accent-ink:   #1B0D06;
  --accent-soft:  #3A2015;
  --red:    #FF7A6D;  --red-soft:   #3A1B18;
  --amber:  #EFC04E;  --amber-soft: #352C15;
  --green:  #55C892;  --green-soft: #142D1F;
  --blue:   #6F98EE;  --blue-soft:  #18243D;
  --lift: none;
  --sheet-shadow: 0 -12px 40px -8px rgba(0,0,0,.6);
  --edge: rgba(255,255,255,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:#0E1214; --surface:#171D20; --raised:#1C2327; --fill:#222A2E; --fill-2:#2B3438; --rule:#262E32;
    --ink:#ECEFF0; --ink-2:#C6CDD0; --hint:#8F999D; --hint-2:#6F797D;
    --accent:#FF6A33; --accent-press:#FF875A; --accent-ink:#1B0D06; --accent-soft:#3A2015;
    --red:#FF7A6D; --red-soft:#3A1B18; --amber:#EFC04E; --amber-soft:#352C15;
    --green:#55C892; --green-soft:#142D1F; --blue:#6F98EE; --blue-soft:#18243D;
    --lift:none; --sheet-shadow:0 -12px 40px -8px rgba(0,0,0,.6); --edge:rgba(255,255,255,.05);
  }
}

/* ---------- основа ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.45; font-weight: 400;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-feature-settings: "tnum" 0;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.i.s { width: 18px; height: 18px; }
svg.i.xs { width: 14px; height: 14px; stroke-width: 2; }
.num, .n { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- шкала текста ----------
   26/30 700 — фраза дня и главная цифра раздела
   20/26 700 — заголовок экрана
   17/22 700 — заголовок группы
   15/21 500 — строка списка (основной текст)
   13/18 500 — пояснение
   12/16 600 — подписи значений, оси  */
.t-display { font-size: 26px; line-height: 30px; font-weight: 700; letter-spacing: -.015em; }
.t-title   { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -.01em; }
.t-group   { font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -.005em; }
.t-body    { font-size: 15px; line-height: 21px; font-weight: 500; }
.t-note    { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--hint); }
.t-cap     { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--hint); }
.hint { color: var(--hint); }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }
b, strong { font-weight: 700; }

/* ---------- каркас экрана ---------- */
.screen { display: none; min-height: 100%; padding-bottom: 96px; }
.screen.on { display: block; animation: screen-in .38s var(--spring); }
.screen.has-main { padding-bottom: 96px; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pad { padding: 0 16px; }
.stack > * + * { margin-top: 12px; }
.gap-s { height: 8px; } .gap { height: 16px; } .gap-l { height: 28px; }

/* шапка приложения: клиника и свежесть данных */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 6px;
}
.clinic { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; border: 0; background: none; padding: 6px 0; cursor: pointer; }
.clinic svg { color: var(--hint); }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--hint); white-space: nowrap; }
.fresh i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.fresh.off i { background: var(--amber); }

/* заголовок экрана раздела */
.head { padding: 8px 16px 4px; }
.head h1 { margin: 0; }
.head p { margin: 4px 0 0; }

/* полоса «нет связи» */
.banner { margin: 8px 16px 0; padding: 10px 12px; border-radius: var(--r-el); background: var(--amber-soft); color: var(--ink); font-size: 13px; line-height: 18px; display: flex; gap: 10px; align-items: flex-start; }
.banner svg { color: var(--amber); margin-top: 1px; }
.banner.red { background: var(--red-soft); } .banner.red svg { color: var(--red); }

/* ---------- фраза дня + линейка плана (главный элемент «Сегодня») ---------- */
.day { padding: 10px 16px 6px; }
.day .greet { font-size: 13px; font-weight: 600; color: var(--hint); margin-bottom: 6px; }
.day .phrase { margin: 0; font-size: 25px; line-height: 31px; font-weight: 700; letter-spacing: -.02em; text-wrap: balance; }
.day .phrase .q { color: var(--hint); font-weight: 600; }
.ruler { position: relative; margin: 22px 0 4px; height: 46px; }
.ruler .track { position: absolute; left: 0; right: 0; top: 18px; height: 10px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.ruler .fact  { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; transform-origin: left; animation: fill-in 1.1s .15s var(--spring) both; }
.ruler .fcst  { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, var(--accent-soft) 0 4px, transparent 4px 7px); }
.ruler .ticks { position: absolute; left: 0; right: 0; top: 30px; height: 6px;
  background-image: linear-gradient(to right, var(--hint-2) 1px, transparent 1px);
  background-size: 10% 100%; opacity: .55; }
.ruler .ticks::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background-image: linear-gradient(to right, var(--hint-2) 1px, transparent 1px); background-size: 5% 100%; }
.ruler .needle { position: absolute; top: 12px; width: 2px; height: 22px; background: var(--ink); border-radius: 1px; transform: translateX(-1px); }
.ruler .needle span { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px; font-weight: 700; color: var(--ink); }
.ruler-legend { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--hint); }
.ruler-legend b { color: var(--ink); font-weight: 700; }
@keyframes fill-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- ведомость: 4 цифры в одном листе ---------- */
.ledger { margin: 14px 16px 0; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge);
  display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.ledger > a, .ledger > div { padding: 13px 14px 12px; position: relative; display: block; }
.ledger > :nth-child(2n) { border-left: 1px solid var(--rule); }
.ledger > :nth-child(n+3) { border-top: 1px solid var(--rule); }
.ledger .k { font-size: 12px; font-weight: 600; color: var(--hint); }
.ledger .v { font-size: 21px; line-height: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ledger .v small { font-size: 13px; font-weight: 600; color: var(--hint); letter-spacing: 0; }
.ledger .d { font-size: 12px; font-weight: 600; color: var(--hint); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- заголовок группы ---------- */
.sec { display: flex; align-items: baseline; justify-content: space-between; padding: 26px 16px 10px; }
.sec h2 { margin: 0; font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -.005em; }
.sec .more { font-size: 13px; font-weight: 600; color: var(--hint); background: none; border: 0; cursor: pointer; padding: 4px 0; }
.sec .count { font-size: 13px; font-weight: 700; color: var(--hint); margin-left: 6px; }

/* ---------- сгруппированный список ---------- */
.group { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); overflow: hidden; }
.group + .group { margin-top: 12px; }
.cell { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; position: relative; cursor: pointer; width: 100%; text-align: left; background: none; border: 0; transition: background .2s var(--quick); }
.cell:active { background: var(--fill); }
.cell + .cell::before { content: ""; position: absolute; top: 0; right: 0; left: 58px; height: 1px; background: var(--rule); }
.cell.plain + .cell.plain::before, .cell.noicon + .cell::before, .cell + .cell.noicon::before { left: 14px; }
.tile { width: 32px; height: 32px; border-radius: var(--r-tile); background: var(--fill); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.tile svg.i { width: 19px; height: 19px; }
.tile.red { background: var(--red-soft); color: var(--red); }
.tile.amber { background: var(--amber-soft); color: var(--amber); }
.tile.green { background: var(--green-soft); color: var(--green); }
.tile.accent { background: var(--accent-soft); color: var(--accent); }
.cell .main { flex: 1; min-width: 0; }
.cell .title { font-size: 15px; line-height: 20px; font-weight: 600; }
.cell .sub { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--hint); margin-top: 1px; }
.cell .val { text-align: right; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell .val small { display: block; font-size: 12px; font-weight: 600; color: var(--hint); }
.cell .chev { color: var(--hint-2); }
.cell .chev svg { width: 16px; height: 16px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* бейджи и метки */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--fill); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.badge.red { background: var(--red); color: #fff; }
:root[data-theme="dark"] .badge.red { color: #1B0D06; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--ink-2); white-space: nowrap; }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--hint-2); }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); }

/* ---------- сигнал ---------- */
.signal { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); padding: 14px 14px 12px; cursor: pointer; }
.signal + .signal { margin-top: 10px; }
.signal .from { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--hint); }
.signal .from svg { width: 16px; height: 16px; color: var(--ink-2); }
.signal .from .when { margin-left: auto; }
.signal .what { margin: 8px 0 0; font-size: 16px; line-height: 22px; font-weight: 700; letter-spacing: -.005em; }
.signal .why { margin: 4px 0 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.signal .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.signal.level-red .from .lvl { color: var(--red); }
.signal.level-amber .from .lvl { color: var(--amber); }
.signal.done { opacity: .62; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r-el); border: 0; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--fill); color: var(--ink); transition: transform .18s var(--quick), background .2s var(--quick); white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.line { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fill-2); }
.btn.ink { background: var(--ink); color: var(--surface); }
.btn.main { background: var(--accent); color: var(--accent-ink); }
.btn.main:active { background: var(--accent-press); }
.btn.ghost { background: none; color: var(--hint); padding: 0 8px; }
.btn.big { min-height: 50px; font-size: 15px; border-radius: 14px; }
.btn.wide { width: 100%; }
.btn svg { width: 17px; height: 17px; }

/* нижняя кнопка Telegram (BottomButton) — её рисует сам Telegram */
.tg-main { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; padding: 8px 12px 14px; background: var(--paper); display: none; }
.tg-main button { width: 100%; height: 50px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; cursor: pointer; }
.tg-main .tg-label { position: absolute; top: -18px; right: 14px; font-size: 10px; color: var(--hint-2); font-weight: 600; }

/* ---------- переключатели ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 13px; border-radius: 999px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); color: var(--surface); box-shadow: none; }
.chip .c { font-weight: 600; opacity: .6; }
.seg { display: flex; margin: 0 16px; padding: 3px; border-radius: 12px; background: var(--fill); }
.seg button { flex: 1; height: 32px; border: 0; border-radius: 9px; background: none; font-size: 13px; font-weight: 600; color: var(--hint); cursor: pointer; transition: background .25s var(--spring); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- нижнее меню ---------- */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; padding: 6px 6px 12px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--rule); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 2px; border: 0; background: none; color: var(--hint); font-size: 11px; font-weight: 600; cursor: pointer; position: relative; }
.tabbar button.on { color: var(--ink); }
.tabbar button.on svg { color: var(--accent); }
.tabbar button .badge { position: absolute; top: 0; left: calc(50% + 6px); height: 17px; min-width: 17px; font-size: 11px; padding: 0 5px; }

/* ---------- нижний лист ---------- */
.scrim { position: absolute; inset: 0; z-index: 20; background: rgba(10,14,16,.42); opacity: 0; pointer-events: none; transition: opacity .3s var(--quick); }
.sheet { visibility: hidden; position: absolute; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--raised); border-radius: 22px 22px 0 0; box-shadow: var(--sheet-shadow); padding: 8px 16px 24px; transform: translateY(105%); transition: transform .45s var(--spring); max-height: 88%; overflow-y: auto; }
.sheet .grip { width: 36px; height: 4px; border-radius: 2px; background: var(--fill-2); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; line-height: 24px; font-weight: 700; }
.open .scrim { opacity: 1; pointer-events: auto; }
.open .sheet.on { transform: none; visibility: visible; }
.sheet { transition: transform .45s var(--spring), visibility 0s .45s; }
.open .sheet.on { transition: transform .45s var(--spring), visibility 0s; }

/* поле ввода */
.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--hint); margin-bottom: 6px; }
.input { width: 100%; min-height: 46px; padding: 12px 14px; border-radius: var(--r-el); border: 0; background: var(--fill); color: var(--ink); font: inherit; font-size: 15px; font-weight: 500; resize: none; }
.input::placeholder { color: var(--hint); }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: var(--fill); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.opt.on { background: var(--ink); color: var(--surface); }

/* ---------- графики (чистый HTML/CSS, без библиотек) ---------- */
.chart { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); padding: 14px; }
.legend { display: flex; gap: 14px; font-size: 12px; font-weight: 600; color: var(--hint); margin-bottom: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: 3px; margin-right: 5px; }
/* горизонтальные полосы */
.hbar { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px 10px; align-items: center; font-size: 13px; font-weight: 600; }
.hbar .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .tr { height: 8px; border-radius: 3px; background: var(--fill); position: relative; overflow: hidden; }
.hbar .tr i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--ink-2); }
.hbar .tr i.acc { background: var(--accent); } .hbar .tr i.red { background: var(--red); } .hbar .tr i.green { background: var(--green); }
.hbar .vv { font-variant-numeric: tabular-nums; text-align: right; min-width: 56px; }
/* столбики */
.cols { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 8px; }
.cols > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.cols i { display: block; border-radius: 3px 3px 1px 1px; background: var(--fill-2); }
.cols i.acc { background: var(--accent); }
.cols i.prev { background: var(--blue); opacity: .35; }
.axis { display: flex; gap: 4px; margin-top: 6px; }
.axis span { flex: 1; text-align: center; font-size: 10px; font-weight: 600; color: var(--hint-2); }
/* теплокарта загрузки */
.heat { display: grid; grid-template-columns: 22px repeat(11, minmax(0, 1fr)); gap: 3px; font-size: 10px; font-weight: 600; color: var(--hint-2); }
.heat span { display: grid; place-items: center; }
.heat i { aspect-ratio: 1 / 1.05; border-radius: 4px; background: var(--fill); }
.heat i.h1 { background: color-mix(in srgb, var(--accent) 18%, var(--fill)); }
.heat i.h2 { background: color-mix(in srgb, var(--accent) 40%, var(--fill)); }
.heat i.h3 { background: color-mix(in srgb, var(--accent) 66%, var(--fill)); }
.heat i.h4 { background: var(--accent); }
.heat i.zero { background: transparent; box-shadow: inset 0 0 0 1.5px var(--red); }
/* воронка */
.funnel { display: grid; gap: 6px; }
.funnel .st { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--fill); font-size: 13px; font-weight: 600; position: relative; overflow: hidden; }
.funnel .st i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); }
.funnel .st > * { position: relative; }
.funnel .st b { font-variant-numeric: tabular-nums; }

/* таблица */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.tbl th { font-size: 11px; font-weight: 600; color: var(--hint); text-align: right; padding: 0 0 8px; }
.tbl td { padding: 10px 0; border-top: 1px solid var(--rule); text-align: right; font-weight: 600; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td:first-child { font-weight: 600; color: var(--ink-2); }

/* выноска «что сделать» */
.advice { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); padding: 4px 14px; }
.advice ol { margin: 0; padding: 0; list-style: none; counter-reset: a; }
.advice li { counter-increment: a; display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 12px 0; border-top: 1px solid var(--rule); font-size: 14px; line-height: 20px; font-weight: 500; }
.advice li:first-child { border-top: 0; }
.advice li::before { content: counter(a); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.advice li b { display: block; font-weight: 700; }
.advice li span { color: var(--hint); font-size: 13px; }
.src { margin: 8px 16px 0; font-size: 12px; font-weight: 500; color: var(--hint); }

/* «Спросить про это» внизу раздела */
.ask-row { margin: 0 16px; padding: 12px 14px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); }
.ask-row .lead { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.ask-row .lead svg { color: var(--accent); }
.ask-row .qs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ask-row .qs button { text-align: left; padding: 9px 12px; border-radius: 10px; border: 0; background: var(--fill); font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }

/* ---------- чат ---------- */
.chat { padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 21px; font-weight: 500; }
.msg.me { align-self: flex-end; background: var(--ink); color: var(--surface); border-bottom-right-radius: 6px; }
.msg.cl { align-self: flex-start; background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); border-bottom-left-radius: 6px; }
.msg.cl .tbl { margin: 8px 0 4px; }
.msg .meta { display: block; margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--hint); }
.msg.me .meta { color: color-mix(in srgb, var(--surface) 60%, transparent); }
.msg .src-chip { display: inline-flex; gap: 4px; align-items: center; margin: 8px 6px 0 0; height: 24px; padding: 0 8px; border-radius: 8px; background: var(--fill); font-size: 11px; font-weight: 600; color: var(--hint); }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--hint-2); animation: blink 1.2s infinite var(--quick); }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.composer { position: sticky; bottom: 70px; z-index: 6; padding: 8px 12px; background: var(--paper); }
.composer .box { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 22px; background: var(--surface); box-shadow: var(--lift), inset 0 0 0 1px var(--rule); }
.composer .box span { flex: 1; padding: 8px 0; color: var(--hint); font-size: 15px; font-weight: 500; }
.composer .send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.composer .ctx { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px 4px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.suggest { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
.suggest button { text-align: left; padding: 12px 14px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: var(--lift), inset 0 0 0 1px var(--edge); font-size: 14px; font-weight: 600; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.suggest button svg { color: var(--hint); }

/* ---------- скелет загрузки ---------- */
.skel { background: linear-gradient(90deg, var(--fill) 0, var(--fill-2) 40%, var(--fill) 80%); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* ---------- пустое состояние ---------- */
.empty { text-align: center; padding: 36px 28px; }
.empty .ic { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.empty .ic svg { width: 28px; height: 28px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.empty p { margin: 0; font-size: 14px; line-height: 20px; color: var(--hint); font-weight: 500; }

/* отзыв */
.review { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); padding: 14px; }
.review + .review { margin-top: 10px; }
.review .top { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--hint); }
.stars { color: var(--amber); letter-spacing: 1px; font-size: 13px; }
.review .txt { margin: 8px 0 0; font-size: 14px; line-height: 20px; font-weight: 500; }
.draft { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--fill); font-size: 14px; line-height: 20px; font-weight: 500; }
.draft .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }

/* прогресс-кольцо (тренажёр) */
.ring { --p: 70; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--fill) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* сравнение «мы — конкуренты» */
.vs { display: grid; grid-template-columns: 1fr auto auto; gap: 0 14px; font-size: 13px; font-weight: 600; }
.vs > * { padding: 10px 0; border-top: 1px solid var(--rule); }
.vs > .h { border-top: 0; padding-top: 0; font-size: 11px; color: var(--hint); }
.vs .us { color: var(--accent); }
.vs .r { text-align: right; font-variant-numeric: tabular-nums; }

/* мелочи */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap-p { padding: 14px; }
.hr { height: 1px; background: var(--rule); margin: 12px 0; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--rule); font-size: 14px; font-weight: 500; }
.kv:first-child { border-top: 0; }
.kv b { font-variant-numeric: tabular-nums; }
.only-owner, .only-manager, .only-admin, .no-owner, .no-admin { }

/* галочка задачи */
.tick { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 2px var(--fill-2); background: none; cursor: pointer; display: grid; place-items: center; transition: background .25s var(--spring), box-shadow .25s; }
.tick.done { background: var(--green); box-shadow: none; }
.tick.done::after { content: ""; width: 10px; height: 6px; border: 2.2px solid var(--surface); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.cell .tick ~ .main { min-width: 0; }
.cell:has(> .tick) + .cell::before, .cell + .cell:has(> .tick)::before { left: 50px; }
.cell.is-done .title { color: var(--hint); text-decoration: line-through; text-decoration-color: var(--hint-2); }
/* переключатель */
.switch { width: 44px; height: 26px; border-radius: 13px; background: var(--fill-2); position: relative; flex: none; transition: background .25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .3s var(--spring); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }
.bar .t-title { padding: 4px 0; }
/* вывод Claude: подпись и мягкая подложка (text by=claude) */
.by-claude { margin: 0 16px; padding: 14px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); }
.by-claude .who-wrote { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--hint); margin-bottom: 8px; }
.by-claude .who-wrote::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }
.by-claude p { margin: 0 0 8px; font-size: 14px; line-height: 21px; font-weight: 500; }
.by-claude p:last-child { margin-bottom: 0; }
/* вкладки раздела (подменю из экранов menu=True) */
.subtabs { display: flex; gap: 22px; padding: 2px 16px 0; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.subtabs button { flex: none; border: 0; background: none; padding: 10px 0 11px; font-size: 14px; font-weight: 600; color: var(--hint); cursor: pointer; position: relative; }
.subtabs button.on { color: var(--ink); }
.subtabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
/* kpis-ряд внутри раздела */
.kpis { margin: 12px 16px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); overflow: hidden; }
.kpis > div { padding: 12px 14px; }
.kpis > :nth-child(2n) { border-left: 1px solid var(--rule); }
.kpis > :nth-child(n+3) { border-top: 1px solid var(--rule); }
.kpis.three { grid-template-columns: 1fr 1fr 1fr; }
.kpis.three > :nth-child(n) { border-left: 1px solid var(--rule); border-top: 0; }
.kpis.three > :first-child { border-left: 0; }
.kpis .k { font-size: 12px; font-weight: 600; color: var(--hint); }
.kpis .v { font-size: 20px; line-height: 25px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpis .d { font-size: 12px; font-weight: 600; color: var(--hint); margin-top: 1px; }
/* предпросмотр сообщения пациенту (text style=preview) */
.preview { margin: 0 16px; padding: 14px; border-radius: var(--r-sheet); background: color-mix(in srgb, var(--blue) 9%, var(--paper)); }
.preview .bubble { max-width: 92%; background: var(--surface); border-radius: 16px 16px 16px 6px; padding: 10px 12px; font-size: 14px; line-height: 20px; font-weight: 500; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.preview .bubble .bt { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rule); text-align: center; color: var(--blue); font-weight: 700; font-size: 13px; }
.preview .cap { font-size: 12px; font-weight: 600; color: var(--hint); margin-bottom: 8px; }
.screen[data-composer].on { display: flex; flex-direction: column; padding-bottom: 0; }
.advice .who-wrote, .by-claude .who-wrote { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--hint); padding-top: 10px; }
.advice .who-wrote::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }
.by-claude .who-wrote { padding-top: 0; }
.tbl tr.total td { font-weight: 700; color: var(--ink); border-top: 1.5px solid var(--ink-2); }
.tbl tr.us td { color: var(--accent); }
.tbl tr.us td:first-child { color: var(--accent); }
.hbar { grid-template-columns: minmax(84px, 108px) 1fr auto; }
/* сообщение «пациента» в тренажёре */
.msg.pt { align-self: flex-start; background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); border-bottom-left-radius: 6px; }
.msg .role { display: block; font-size: 11px; font-weight: 700; color: var(--hint); margin-bottom: 2px; }
.crit { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 11px 0; border-top: 1px solid var(--rule); font-size: 14px; line-height: 19px; font-weight: 500; }
.crit:first-child { border-top: 0; }
.crit .mk { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.crit .mk.ok { background: var(--green-soft); color: var(--green); }
.crit .mk.no { background: var(--red-soft); color: var(--red); }
.crit .mk svg { width: 12px; height: 12px; stroke-width: 2.4; }
.crit small { display: block; color: var(--hint); font-size: 12px; margin-top: 2px; }
.crit b { font-variant-numeric: tabular-nums; }
.step { display: flex; align-items: center; gap: 10px; padding: 24px 16px 10px; }
.step .no { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.step h2 { margin: 0; font-size: 17px; font-weight: 700; }
.pick { display: grid; gap: 8px; padding: 0 16px; }
.pick button { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: var(--lift), inset 0 0 0 1px var(--edge); cursor: pointer; }
.pick button .main { flex: 1; } .pick button .title { font-size: 15px; font-weight: 600; } .pick button .sub { font-size: 12px; font-weight: 500; color: var(--hint); }
.pick button .radio { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--fill-2); flex: none; }
.pick button.on { box-shadow: inset 0 0 0 2px var(--ink); }
.pick button.on .radio { box-shadow: inset 0 0 0 7px var(--ink); }
.pick button .n { font-weight: 700; font-variant-numeric: tabular-nums; }

.ruler .needle.end span { left: auto; right: -2px; transform: none; }
.ruler .needle.start span { left: -2px; transform: none; }
/* рейтинг-полосы: подпись и значение строкой, полоса под ними — длинные подписи не режутся */
.hbar { grid-template-columns: 1fr auto; grid-auto-flow: row dense; gap: 0 12px; }
.hbar .lbl { grid-column: 1; white-space: normal; padding-top: 10px; font-weight: 600; }
.hbar .vv { grid-column: 2; padding-top: 10px; min-width: 0; }
.hbar .tr { grid-column: 1 / -1; margin-top: 6px; height: 6px; }
.hbar > :nth-child(1), .hbar > :nth-child(3) { padding-top: 0; }

/* ===== отрисовка блоков контракта (blocks.js) ===== */
.screen-body > .blk { margin-top: 12px; }
.screen-body > .blk.banner { margin-top: 12px; }
.screen-body > .subtabs + .blk, .screen-body > .chips + .blk { margin-top: 12px; }
.kpis.one { grid-template-columns: 1fr; }
.kpis > .kpi { padding: 12px 14px; text-align: left; background: none; border: 0; font: inherit; color: inherit; }
.kpis > .kpi.tap { cursor: pointer; }
.kpis > .kpi.tap:active { background: var(--fill); }
.kpis .delta { font-weight: 700; }
.kpis .delta.up { color: var(--ink-2); } .kpis .delta.down { color: var(--ink-2); }
.banner.ok { background: var(--green-soft); } .banner.ok svg { color: var(--green); }
.banner.info { background: var(--fill); } .banner.info svg { color: var(--ink-2); }
.banner p { margin: 0; } .banner p + p { margin-top: 4px; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.compact { min-height: 34px; padding: 0 12px; font-size: 13px; }
.acts-row { display: flex; gap: 8px; flex-wrap: wrap; }
.acts-row .btn { flex: 1; }
.form-block .field:first-child { margin-top: 4px; }
.with-unit { position: relative; } .with-unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--hint); font-weight: 600; }
.field-hint { display: block; margin-top: 6px; font-size: 12px; font-weight: 500; color: var(--hint); }
.composer-input { flex: 1; border: 0; background: none; font: inherit; font-size: 15px; font-weight: 500; color: var(--ink); padding: 8px 0; outline: none; }
.md-list { margin: 0; padding-left: 18px; } .md-list li { margin: 4px 0; }
.text-block { margin: 0 16px; font-size: 14px; line-height: 21px; font-weight: 500; color: var(--ink-2); }
.text-block p { margin: 0 0 8px; }
.by-claude .md-list { font-size: 14px; line-height: 21px; font-weight: 500; }
.heat i.off { background: transparent; }
.cols .target { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px dashed var(--ink); pointer-events: none; }
.empty .ic.bad { background: var(--red-soft); color: var(--red); }
.empty .ic.neutral { background: var(--fill); color: var(--ink-2); }
.tbl tr.mark-us td { color: var(--accent); }
.tbl tr.mark-bad td:first-child { color: var(--red); }
.tbl tr.mark-warn td:first-child { color: var(--amber); }
.tbl tr.mark-ok td:first-child { color: var(--green); }
.table-wrap { overflow-x: auto; }
.ruler .fact.st-ok { background: var(--green); } .ruler .fact.st-bad { background: var(--red); } .ruler .fact.st-warn { background: var(--amber); }
.block-progress { padding: 4px 16px 0; }
.block-progress > .k { font-size: 12px; font-weight: 600; color: var(--hint); margin-bottom: -6px; }
/* широкие таблицы: листаются вбок, первая колонка стоит */
.table-wrap.scrolls { padding: 14px 0; }
.table-wrap.scrolls .tbl { min-width: max-content; }
.table-wrap.scrolls .tbl th, .table-wrap.scrolls .tbl td { padding-left: 14px; white-space: nowrap; }
.table-wrap.scrolls .tbl th:last-child, .table-wrap.scrolls .tbl td:last-child { padding-right: 14px; }
.table-wrap.scrolls .tbl th:first-child, .table-wrap.scrolls .tbl td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; max-width: 140px; white-space: normal; box-shadow: 1px 0 0 var(--rule); }
.kpis:not(.three) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.kpis.three .v { font-size: 17px; line-height: 22px; }
.axis span { white-space: nowrap; min-width: 0; }
.line-wrap { position: relative; }
.line-chart { width: 100%; height: 130px; display: block; overflow: visible; }
.line-chart polyline { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.line-chart .cur { stroke: var(--accent); }
.line-chart .prev { stroke: var(--blue); opacity: .5; }
.line-chart .tgt { stroke: var(--ink); stroke-dasharray: 4 4; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.line-chart .zero { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.line-last { position: absolute; right: 0; top: -4px; font-size: 12px; font-weight: 700; background: var(--surface); padding: 1px 4px; border-radius: 6px; }
.heat i { aspect-ratio: auto; height: 22px; }
.heat { row-gap: 3px; align-items: center; }
/* QR: всегда чёрный на белом, и в тёмной теме — так его читает любая камера */
.qr-block { margin: 0 16px; padding: 18px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); text-align: center; }
.qr-block .qr { width: 196px; height: 196px; display: block; margin: 0 auto; border-radius: 10px; }
.qr-block p { margin: 12px 0 0; font-size: 14px; line-height: 20px; font-weight: 600; }
.qr-block .qr-link { margin-top: 6px; font-size: 12px; font-weight: 500; color: var(--hint); word-break: break-all; }
.block-progress.in-day { padding: 0; }
.screen-body > .blk-headline { margin-top: 0; }
.screen-body > .blk-signals .signal + .signal { margin-top: 10px; }
.screen-body > .blk-signals .sec { padding-top: 26px; }
/* разделители в листе цифр (после сброса рамок у кнопок-цифр) */
.kpis > .kpi:nth-child(2n) { border-left: 1px solid var(--rule); }
.kpis > .kpi:nth-child(n+3) { border-top: 1px solid var(--rule); }
.kpis.three > .kpi:nth-child(n) { border-top: 0; border-left: 1px solid var(--rule); }
.kpis.three > .kpi:first-child { border-left: 0; }
.kpis:not(.three) > .kpi:last-child:nth-child(odd) { border-left: 0; }
/* колонки таблицы не слипаются: «8» и «72,7 %» */
.tbl th + th, .tbl td + td { padding-left: 14px; }
.tbl tr.tap { cursor: pointer; }
.tbl tr.tap:active td { background: var(--fill); }
.tbl tr.tap td:first-child { text-decoration: underline; text-decoration-color: var(--fill-2); text-underline-offset: 3px; }
/* меню разделов: плитки 2 колонки по группам — 10 разделов в один экран */
.menu { padding: 0 16px; }
.mgroup h2 { margin: 18px 0 8px; font-size: 15px; line-height: 20px; font-weight: 700; color: var(--ink-2); }
.mgroup:first-child h2 { margin-top: 6px; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mtile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 92px; padding: 12px; border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--lift), inset 0 0 0 1px var(--edge); text-align: left; cursor: pointer; font: inherit; color: var(--ink); transition: transform .18s var(--quick); }
.mtile:active { transform: scale(.97); }
.mtile .mtop { display: flex; width: 100%; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.mtile .tile { width: 30px; height: 30px; }
.mtile .mt { font-size: 14px; line-height: 18px; font-weight: 700; }
.mtile .mh { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--hint); }
/* компактная плитка: [значок] Название [бейдж] / пояснение одной строкой */
.mtile { display: grid; grid-template-columns: 28px minmax(0, 1fr); grid-template-areas: "ic t" "h h"; position: relative; column-gap: 8px; row-gap: 6px; align-items: center; min-height: 0; padding: 11px 11px 10px; }
.mtile .mtop { display: contents; }
.mtile .tile { grid-area: ic; width: 28px; height: 28px; border-radius: 8px; }
.mtile .tile svg.i { width: 17px; height: 17px; }
/* бейдж — на углу значка, как у приложений: название раздела получает всю ширину */
.mtile .badge, .mtile .dot { position: absolute; top: 4px; left: 29px; box-shadow: 0 0 0 2px var(--surface); }
.mtile .badge { min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
.mtile .dot { top: 7px; left: 34px; }
.mtile .mt { grid-area: t; font-size: 13.5px; line-height: 17px; min-width: 0; }
.mtile .mh { grid-area: h; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mgroup h2 { margin: 14px 0 7px; font-size: 14px; }
.mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ===== Цвета темы Telegram (themeParams) =====
   telegram-web-app.js сам выставляет --tg-theme-* на <html>. Каркас ставит класс tg-native, когда приложение открыто
   в Telegram. Тогда фон, текст, подписи и разделители — как у Telegram человека (приложение сливается с его темой),
   а фирменный оранжевый и цвета статусов остаются нашими. Вне Telegram — наша палитра (фолбэки ниже). */
:root.tg-native:not([data-theme="dark"]) {
  --paper:   var(--tg-theme-secondary-bg-color, #F2F3F4);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #FFFFFF));
  --raised:  var(--tg-theme-bg-color, #FFFFFF);
  --ink:     var(--tg-theme-text-color, #1C2326);
  --hint:    var(--tg-theme-hint-color, #6A7377);
  --rule:    var(--tg-theme-section-separator-color, #E4E7E9);
}
:root.tg-native[data-theme="dark"] {
  --paper:   var(--tg-theme-secondary-bg-color, #0E1214);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #171D20));
  --raised:  var(--tg-theme-bg-color, #1C2327);
  --ink:     var(--tg-theme-text-color, #ECEFF0);
  --hint:    var(--tg-theme-hint-color, #8F999D);
  --rule:    var(--tg-theme-section-separator-color, #262E32);
}
/* абзацы внутри пузыря чата и плашек — без стандартных полей браузера */
.msg p { margin: 0; } .msg p + p, .msg ul + p, .msg p + ul { margin-top: 8px; }
.msg .md-list { margin: 6px 0 0; }
.day.tap { cursor: pointer; } .day.tap:active { opacity: .8; }

/* ===================================================================
   18.11 — решения Виталия: клиники, чаты как Claude Code, уведомления, бот пациентов
   =================================================================== */

/* --- клиника: монограмма в шапке, переключатель --- */
.mono { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: 11px; font-weight: 700; letter-spacing: .02em; display: inline-grid; place-items: center; flex: none; }
.mono.lg { width: 36px; height: 36px; border-radius: 11px; font-size: 13px; }
.mono.off { background: var(--fill); color: var(--ink-2); }
.clinic .many { font-size: 12px; font-weight: 600; color: var(--hint); }
.inner-clinic { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--hint); }
.inner-clinic .mono { width: 18px; height: 18px; border-radius: 5px; font-size: 8px; }
.mini-ruler { position: relative; height: 6px; border-radius: 3px; background: var(--fill); margin-top: 8px; }
.mini-ruler b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--ink); }
.mini-ruler i { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--hint); }
.clin-alerts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cell.top { align-items: flex-start; }
.cell.current { background: color-mix(in srgb, var(--ink) 4%, var(--surface)); }
.toast { margin: 8px 16px 0; padding: 10px 10px 10px 12px; border-radius: var(--r-el); background: var(--ink); color: var(--surface); font-size: 13px; line-height: 18px; font-weight: 600; display: flex; gap: 10px; align-items: center; animation: toast-in .5s var(--spring) both; }
.toast .btn { min-height: 30px; padding: 0 10px; background: color-mix(in srgb, var(--surface) 16%, transparent); color: var(--surface); font-size: 12px; margin-left: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* --- чаты --- */
.search { margin: 6px 16px 0; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: var(--r-el); background: var(--fill); color: var(--hint); font-size: 15px; font-weight: 500; }
.chatrow .title { display: flex; gap: 8px; align-items: baseline; }
.chatrow .title .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow .title time { flex: none; font-size: 12px; font-weight: 600; color: var(--hint); }
.chatrow .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow .sub .busy { color: var(--accent); font-weight: 600; }
.chatrow .sub svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 2px; }
.swipe { position: relative; overflow: hidden; }
.swipe .acts { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.swipe .acts button { width: 74px; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; cursor: pointer; color: #fff; background: var(--hint); }
.swipe .acts button.del { background: var(--red); }
.swipe .acts button svg { width: 20px; height: 20px; }
:root[data-theme="dark"] .swipe .acts button { color: #0E1214; }
.swipe .cell { background: var(--surface); transform: translateX(-148px); }
.msg.cl.wide { max-width: 94%; }
.msg p { margin: 0; } .msg p + p { margin-top: 8px; }
.tools { align-self: flex-start; max-width: 94%; display: grid; gap: 3px; padding: 8px 12px; border-radius: 14px; background: color-mix(in srgb, var(--ink) 5%, transparent); font-size: 12px; line-height: 17px; font-weight: 600; color: var(--hint); }
.tools .t { display: flex; gap: 8px; align-items: center; }
.tools .t svg { width: 14px; height: 14px; stroke-width: 2; }
.tools .t.done svg { color: var(--green); }
.tools .t.now { color: var(--ink); }
.tools .t.wait { opacity: .55; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--fill-2); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin, .typing i, .toast { animation: none; } }

/* вложения: файл (строка) и артефакт (с превью) */
.att { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 8px 8px 8px; border-radius: 14px; background: var(--fill); color: var(--ink); text-align: left; }
.att .tile { width: 36px; height: 36px; background: var(--surface); }
.att .nm { font-size: 14px; line-height: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .mt { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--hint); }
.att > div { flex: 1; min-width: 0; }
.att .ib { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.att .ib svg { width: 18px; height: 18px; }
.msg.me .att { background: color-mix(in srgb, var(--surface) 14%, transparent); color: var(--surface); }
.msg.me .att .tile { background: color-mix(in srgb, var(--surface) 18%, transparent); color: var(--surface); }
.msg.me .att .mt { color: color-mix(in srgb, var(--surface) 65%, transparent); }
.msg .photo { display: block; margin: -4px -7px 8px; height: 120px; border-radius: 14px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 26%, transparent), transparent 70%),
              repeating-linear-gradient(0deg, transparent 0 15px, color-mix(in srgb, var(--surface) 18%, transparent) 15px 16px),
              color-mix(in srgb, var(--surface) 8%, transparent); }
.msg .photo span { position: absolute; left: 10px; bottom: 8px; font-size: 11px; font-weight: 600; color: color-mix(in srgb, var(--surface) 80%, transparent); }
.art { margin-top: 10px; border-radius: 16px; overflow: hidden; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); }
.art .thumb { height: 118px; padding: 12px 14px 0; background: var(--paper); display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.art .thumb .h { font-size: 12px; line-height: 15px; font-weight: 700; }
.art .thumb .h small { display: block; font-weight: 500; color: var(--hint); }
.art .thumb .bars { flex: 1; display: flex; align-items: flex-end; gap: 5px; }
.art .thumb .bars i { flex: 1; border-radius: 3px 3px 0 0; background: var(--fill-2); }
.art .thumb .bars i.hi { background: var(--ink); }
.art .foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.art .foot .nm { font-size: 14px; font-weight: 700; line-height: 18px; }
.art .foot .mt { font-size: 12px; font-weight: 500; color: var(--hint); }
.art .acts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); }
.art .acts button { height: 40px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.art .acts.two { grid-template-columns: 1fr 1fr; }
.art .acts button + button { box-shadow: inset 1px 0 0 var(--rule); }
.art .acts svg { width: 16px; height: 16px; }
.composer .clip { width: 34px; height: 36px; border: 0; background: none; color: var(--hint); display: grid; place-items: center; cursor: pointer; margin-left: -8px; flex: none; }
.composer .pending { display: flex; gap: 8px; margin: 0 0 8px; }
.composer .pending .att { margin: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule); flex: 1; }
.composer .prog { height: 3px; border-radius: 2px; background: var(--fill); margin-top: 5px; overflow: hidden; }
.composer .prog b { display: block; height: 100%; width: 64%; background: var(--ink); border-radius: 2px; }
.daysep { align-self: center; font-size: 12px; font-weight: 600; color: var(--hint); padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.state-card { margin: 20px 16px 0; padding: 22px 18px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); text-align: center; }
.state-card .ic { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); }
.state-card .ic.red { background: var(--red-soft); color: var(--red); }
.state-card .ic svg { width: 26px; height: 26px; }
.state-card h3 { margin: 0; font-size: 17px; line-height: 22px; font-weight: 700; }
.state-card p { margin: 6px 0 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--hint); }
.state-card .big { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -.03em; margin-top: 12px; font-variant-numeric: tabular-nums; }
.state-card .btn { margin-top: 14px; }
.viewer { margin: 0 16px; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); padding: 16px; }
.viewer h2 { margin: 0; font-size: 19px; line-height: 25px; font-weight: 700; letter-spacing: -.01em; }
.viewer .t-note { margin: 4px 0 12px; }
.viewer .tbl { margin-top: 10px; }

/* --- уведомления --- */
.cell .switch { cursor: pointer; }
.cell .val.time { padding: 5px 10px; border-radius: 10px; background: var(--fill); font-size: 14px; }
.cell.dim .title, .cell.dim .tile { opacity: .45; }
.example { margin-top: 6px; padding: 7px 10px; border-radius: 10px; background: var(--fill); font-size: 12px; line-height: 17px; font-weight: 500; color: var(--ink-2); }
/* Telegram-чат бота — это не приложение, а то, что человек видит в чате с ботом */
.tgchat { min-height: 844px; padding: 0 0 24px; background: color-mix(in srgb, #8DB06A 26%, var(--paper)); }
:root[data-theme="dark"] .tgchat { background: #0E1621; }
.tgchat .tghead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); box-shadow: 0 1px 0 var(--rule); }
.tgchat .tghead .ava { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.tgchat .tghead b { display: block; font-size: 15px; line-height: 19px; } .tgchat .tghead small { font-size: 12px; color: var(--hint); font-weight: 500; }
.tgchat .tghead .back { color: var(--accent); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; }
.tgchat .feed { padding: 12px 10px 0; display: flex; flex-direction: column; gap: 6px; }
.tgb { align-self: flex-start; max-width: 88%; background: var(--surface); border-radius: 16px 16px 16px 5px; padding: 8px 11px; font-size: 14px; line-height: 20px; font-weight: 500; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.tgb .meta { float: right; margin: 6px 0 0 10px; font-size: 11px; color: var(--hint); }
.tgb .from { display: block; font-size: 12px; font-weight: 700; color: var(--hint); margin-bottom: 2px; }
:root[data-theme="dark"] .tgb { background: #182533; }
.tgb.out { align-self: flex-end; border-radius: 16px 16px 5px 16px; background: color-mix(in srgb, #9FD67A 45%, var(--surface)); }
:root[data-theme="dark"] .tgb.out { background: #2B5278; }
.tgkb { align-self: flex-start; width: 88%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: -2px; }
.tgkb button { min-height: 38px; padding: 4px 6px; border: 0; border-radius: 10px; background: color-mix(in srgb, #1C2326 32%, transparent); color: #fff; font-size: 13px; line-height: 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
:root[data-theme="dark"] .tgkb button { background: rgba(255,255,255,.1); }
.tgkb button.full { grid-column: 1 / -1; }
.tgkb button svg { width: 14px; height: 14px; stroke-width: 2; flex: none; }
.tgnote { align-self: center; font-size: 12px; font-weight: 600; color: #fff; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.25); margin: 6px 0; }
.callout { margin: 16px 10px 0; padding: 12px 14px; border-radius: 14px; background: var(--surface); font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.callout b { color: var(--ink); }
:root[data-theme="dark"] .callout { background: #182533; }

/* --- мастер бота пациентов --- */
.wiz { padding: 4px 16px 0; }
.wiz .bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.wiz .bars i { height: 4px; border-radius: 2px; background: var(--fill-2); }
.wiz .bars i.on { background: var(--ink); }
.wiz .lbl { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--hint); }
.howto { list-style: none; margin: 0 16px; padding: 2px 14px; counter-reset: h; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); }
.howto li { counter-increment: h; display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding: 12px 0; font-size: 14px; line-height: 20px; font-weight: 500; }
.howto li + li { border-top: 1px solid var(--rule); }
.howto li::before { content: counter(h); width: 24px; height: 24px; border-radius: 50%; background: var(--fill); color: var(--ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.howto b { font-weight: 700; }
.howto small { display: block; color: var(--hint); font-size: 13px; line-height: 18px; margin-top: 2px; }
.howto .btn { margin-top: 8px; min-height: 36px; }
.cmd { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--fill); white-space: nowrap; }
.secret { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 6px 0 14px; border-radius: var(--r-el); background: var(--fill); box-shadow: inset 0 0 0 2px var(--ink); }
.secret .dots { flex: 1; font-size: 18px; letter-spacing: 1px; color: var(--ink); overflow: hidden; white-space: nowrap; }
.secret .btn { min-height: 38px; background: var(--surface); font-size: 13px; }
.secret.saved { box-shadow: none; background: var(--green-soft); padding: 0 6px 0 12px; }
.secret.saved .dots { color: var(--green); font-size: 14px; font-weight: 700; letter-spacing: 0; display: flex; align-items: center; gap: 8px; }
.botcard { margin: 0 16px; padding: 18px 16px 16px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); text-align: center; }
.botcard .ava { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; background: #FFFFFF; box-shadow: inset 0 0 0 1px var(--rule); position: relative; }
.botcard .ava b { font-size: 21px; font-weight: 700; color: #EF521B; letter-spacing: -.03em; }
.botcard .ava .ed { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; border: 2px solid var(--surface); }
.botcard .ava .ed svg { width: 14px; height: 14px; }
.botcard h3 { margin: 10px 0 0; font-size: 18px; font-weight: 700; }
.botcard .un { font-size: 13px; font-weight: 600; color: var(--hint); }
.botcard .desc { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--fill); font-size: 13px; line-height: 18px; font-weight: 500; text-align: left; }
.botcard .desc small { display: block; font-size: 11px; font-weight: 700; color: var(--hint); margin-bottom: 2px; }
.counter { float: right; font-weight: 600; color: var(--hint-2); }
.conds { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.cond { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 11px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--fill-2); font-size: 13px; font-weight: 600; color: var(--ink); }
.cond small { color: var(--hint); font-weight: 600; font-size: 12px; }
.cond button { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--fill); color: var(--hint); display: grid; place-items: center; cursor: pointer; }
.cond button svg { width: 12px; height: 12px; stroke-width: 2.2; }
.cond.add { padding: 0 12px; color: var(--hint); background: none; cursor: pointer; border: 0; }
.understood { margin: 0 16px; padding: 12px 14px 14px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--lift); border: 1px solid var(--edge); }
.understood .by { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--hint); margin-bottom: 10px; }
.understood .by svg { width: 15px; height: 15px; }
.understood .conds { padding: 0; }
.tally { display: grid; grid-template-columns: 1fr 1fr; margin: 12px 16px 0; background: var(--surface); border-radius: var(--r-sheet); box-shadow: var(--lift); border: 1px solid var(--edge); }
.tally.three { grid-template-columns: 1fr 1fr 1fr; }
.tally > div { padding: 12px 14px; } .tally > div + div { border-left: 1px solid var(--rule); }
.tally .v { font-size: 26px; line-height: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tally .k { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--hint); margin-top: 2px; }

.md-link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
