:root {
  /* только светлая тема — не берём цвета из темы Telegram */
  color-scheme: light;
  --bg: #ffffff;
  --bg2: #f2f3f5;
  --text: #15171a;
  --muted: #6b7079;
  --link: #2a6fdb;
  --btn: #2a6fdb;
  --btn-text: #ffffff;
  --line: #e3e5e8;
  --warn-bg: #fff3e0;
  --warn-line: #f0a33a;
  --alert: #c62828;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }

.top { background: var(--bg); padding: 14px 16px 8px; }
.who { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0;
  font-size: 22px; font-weight: 700; cursor: pointer; }
.chev { font-size: 14px; color: var(--muted); }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; background: var(--bg);
  padding: 0 12px 10px; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: var(--bg2); border-radius: 999px; padding: 8px 2px; min-width: 0;
  font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs button.on { background: var(--text); color: var(--bg); font-weight: 600; }

main { padding: 12px 12px 96px; }
.card { background: var(--bg); border-radius: var(--r); padding: 14px 14px; margin-bottom: 10px; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: none; }
.empty { color: var(--muted); font-size: 15px; }

.warn { background: var(--warn-bg); border-left: 4px solid var(--warn-line); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; font-size: 15px; color: #3d2a00; }
.warn:last-child { margin-bottom: 0; }

.med { padding: 10px 0; border-top: 1px solid var(--line); }
.med:first-of-type { border-top: 0; padding-top: 0; }
.med-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.med-name { font-weight: 600; font-size: 16px; }
.med-time { font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.med-how { font-size: 15px; margin-top: 2px; }
.med-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.adh { font-size: 13px; color: var(--muted); }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 84px 12px 1fr; gap: 8px; padding: 8px 0; align-items: start; }
.tl .d { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-top: 6px; }
.tl .start .dot { background: var(--btn); }
.tl .stop .dot { background: #888; outline: 2px solid var(--bg2); }
.tl .t { font-size: 15px; }
.tl .m { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.tl .start .t { font-weight: 600; }
.tl .diagnosis .dot { background: #c62828; }
.tl .diagnosis .t, .tl .hospital .t { font-weight: 600; }
.tl .hospital .dot { background: #6a3fc1; }
.tl .test .dot { background: #2e7d32; }
.tl .event .dot { background: #8d6e63; }
.an-group { margin-bottom: 12px; }
.an-group:last-child { margin-bottom: 0; }
.an-title { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.an-row { display: grid; grid-template-columns: 78px 1fr; gap: 8px; padding: 4px 0; font-size: 15px; }
.an-d { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.an-det { display: block; color: var(--muted); font-size: 14px; }
.tl .bp .t { font-variant-numeric: tabular-nums; color: var(--muted); }

.bp-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.bp-sum div { background: var(--bg2); border-radius: 10px; padding: 8px 10px; }
.bp-sum b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.bp-sum span { font-size: 12px; color: var(--muted); }
svg.chart { width: 100%; height: 190px; display: block; }
.bp-row { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums; font-size: 15px; }
.bp-row.high b { color: var(--alert); }

label.f { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label.f input, label.f textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit;
  color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
label.f textarea { min-height: 64px; resize: vertical; }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); }
.btn { flex: 1; border: 0; border-radius: 10px; padding: 12px 14px; background: var(--btn); color: var(--btn-text);
  font-weight: 600; cursor: pointer; }
.btn.ghost { flex: 0 0 auto; background: var(--bg2); color: var(--text); }
.btn:disabled { opacity: .6; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 5; }
.sheet[hidden] { display: none; }
.sheet-in { background: var(--bg); width: 100%; border-radius: 16px 16px 0 0; padding: 12px 0 calc(16px + env(safe-area-inset-bottom)); }
.sheet-in button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 14px 20px; font-size: 17px; cursor: pointer; }
.sheet-in button.on { font-weight: 700; }
.sheet-in .hint { padding: 4px 20px 8px; color: var(--muted); font-size: 14px; }
