/* Здоровье семьи — дополнения к общей дизайн-системе (app.css взят из «Домашних счётчиков»). */
:root { --s1: #c2410c; --s2: #2a78d6; --band: color-mix(in srgb, var(--good) 12%, transparent); }
.brand-mark { color: #e34948; }

/* семья */
.g-people { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.person { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none !important; transition: box-shadow .15s ease, transform .15s ease; }
.person:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.person .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person b { font-size: 16px; }
.person .chev { transform: rotate(180deg); color: var(--muted); }
.pav { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; background: var(--surface-3); color: var(--ink-2); }
.pav-m { background: color-mix(in srgb, var(--s2) 16%, var(--surface)); color: var(--s2); }
.pav-f { background: color-mix(in srgb, #e34948 14%, var(--surface)); color: #c43b3a; }

/* карта */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ptabs { margin: 0 0 18px; display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; }
.ptabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2); text-decoration: none !important; }
.ptabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.g-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .g-card { grid-template-columns: minmax(0, 1fr); } }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; }
.kv > span:last-child { text-align: right; }
.lastv { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.lv { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.lv b { font-size: 18px; font-variant-numeric: tabular-nums; }
.bad-v { color: var(--bad); }
.disclaimer { display: flex; gap: 6px; align-items: center; margin-top: 18px; }

/* документы */
.list { padding: 6px 20px; }
.drow { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); }
.drow:first-child { border-top: 0; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 0; flex: 1; min-width: 0; }
.doc .grow { display: flex; flex-direction: column; min-width: 0; }
.doc b { font-weight: 600; overflow-wrap: anywhere; }
.dico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex: none; }
.dq { max-width: 260px; }
.vrow { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
@media (max-width: 640px) { .vrow { grid-template-columns: 1fr 1fr 1fr; } .vrow input[data-k="lab"] { grid-column: 1 / -1; } }
label.f.wide, .form-grid .wide { grid-column: 1 / -1; }
#dlgBody textarea { resize: vertical; }

/* показатели */
.mchips { margin-bottom: 14px; }
.mchips .chip { cursor: pointer; font-size: 13px; padding: 5px 10px; }
.mchips .chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.mchips .chip.on .muted { color: inherit; opacity: .7; }
.chart .band { fill: var(--band); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .ln.s1 { stroke: var(--s1); } .chart .ln.s2 { stroke: var(--s2); }
.chart .pt { stroke: var(--surface); stroke-width: 1.5; }
.chart .pt.s1 { fill: var(--s1); } .chart .pt.s2 { fill: var(--s2); }
.chart .pt.bad-v { fill: var(--bad); r: 5; }
.legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.legend i.s1 { background: var(--s1); } .legend i.s2 { background: var(--s2); } .legend i.band { height: 10px; background: var(--band); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); }
#mchart { margin-bottom: 12px; }

/* доступ */
.ucard .card-h { flex-wrap: wrap; align-items: center; }
.acc { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.accr { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.accr select { width: auto; min-width: 150px; }

/* просмотр документа во всплывающем окне */
dialog.wide-dlg { width: min(1100px, 96vw); max-width: 96vw; height: 92vh; padding: 0; }
dialog.wide-dlg #dlgBody { height: 100%; padding: 0; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-h { padding: 10px 14px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: nowrap; }
.viewer-h b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-b { flex: 1; min-height: 0; background: var(--surface-3); display: flex; align-items: flex-start; justify-content: center; overflow: auto; }
.viewer-b iframe { border: 0; width: 100%; height: 100%; background: #fff; }
.viewer-b img { max-width: 100%; height: auto; display: block; }
a.dtitle { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
a.dtitle:hover { color: var(--link); }

/* лечение */
.medrow, .crow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.medrow:first-of-type, .crow:first-child { border-top: 0; }
.medrow .grow, .crow .grow { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.medrow.off { opacity: .65; }
.crow.done b { text-decoration: line-through; color: var(--muted); }
.slots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.slot { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 99px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot input { width: 16px; height: 16px; margin: 0; }
.slot.on { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 40%, transparent); color: var(--good); }
.ctext { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); margin-top: 6px; }
@media (max-width: 640px) { .medrow { flex-wrap: wrap; } .slots { width: 100%; justify-content: flex-start; } }

/* для ИИ */
.steps { margin: 4px 0 14px; padding-left: 20px; }
.xprev pre { max-height: 420px; overflow: auto; white-space: pre-wrap; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
#aiText { width: 100%; font-family: inherit; }

/* добавить документ */
.addbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 22px 12px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; text-align: center; min-height: 120px; }
.bigbtn svg.i { width: 30px; height: 30px; }
.bigbtn.pri { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.bigbtn.pri .muted { color: inherit; opacity: .7; }
.qcard .qname { font-size: 15px; overflow-wrap: anywhere; }
.qcard + .qcard { margin-top: 12px; }
.qcard .badge { margin-left: 6px; text-transform: none; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--ink); animation: spin 0.8s linear infinite; margin: 8px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.appbox { margin-top: 16px; }
.msitems { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); }
.tabbar:has(a:nth-child(5)) a span { font-size: 10px; }
@media (max-width: 420px) { .addbtns { grid-template-columns: 1fr; } }

/* заключения исследований */
.drow > .grow { min-width: 0; }
.dconcl { margin: -4px 0 10px 48px; padding: 8px 10px; border-left: 3px solid var(--line-2); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.vconcl { padding: 10px 14px; border-bottom: 1px solid var(--line); max-height: 40vh; overflow: auto; }
.vtext { white-space: pre-wrap; font-size: 12px; max-height: 30vh; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
@media (max-width: 640px) { .dconcl { margin-left: 0; } }

/* требует внимания */
.attcard { margin-bottom: 16px; border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.attcard h2 { display: flex; align-items: center; gap: 6px; }
.att { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.att:first-of-type { border-top: 0; }
.att .grow { display: flex; flex-direction: column; min-width: 0; }
.att-dir { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; background: var(--bad-bg); color: var(--bad); }
.att-dir.down { background: color-mix(in srgb, var(--s2) 15%, var(--surface)); color: var(--s2); }
.att-v { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.att-badge { margin-top: 4px; width: fit-content; }

/* сводный экран семьи */
.sbox { display: flex; gap: 8px; margin: 0 0 16px; }
.sbox input { flex: 1; min-width: 0; }
.inboxnote { text-decoration: none !important; color: var(--ink); }
.g-fam { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
.fcard { display: flex; flex-direction: column; gap: 10px; }
.fhead { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none !important; }
.fhead .grow { display: flex; flex-direction: column; min-width: 0; }
.fhead b { font-size: 16px; }
.fhead .chev { transform: rotate(180deg); color: var(--muted); }
.fsec { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.fsec:has(.badge) { flex-direction: row; flex-wrap: wrap; align-items: center; }
.fsec-h { width: 100%; }
.fatt { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none !important; font-size: 14px; }
.fatt .att-dir { width: 22px; height: 22px; font-size: 12px; }
.fatt b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fdoc { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; align-items: baseline; font-size: 14px; }
.fdoc a { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.good-t { color: var(--good); display: inline-flex; align-items: center; gap: 4px; }
.ckrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.ckrow:first-of-type { border-top: 0; }
.ckrow .grow { display: flex; flex-direction: column; min-width: 0; }
mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 1px; }

/* вкладки карты на телефоне — одной строкой с прокруткой */
@media (max-width: 760px) {
  .ptabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .ptabs::-webkit-scrollbar { display: none; }
  .ptabs a { white-space: nowrap; flex: none; }
  .page-h h1 { font-size: 24px; }
  .fdoc { grid-template-columns: 1fr auto; } .fdoc > .xs:first-child { grid-column: 1 / -1; margin-bottom: -6px; }
  .dq { max-width: none; flex: 1; }
}

/* лента */
.tl { position: relative; margin-bottom: 8px; }
.tle { display: grid; grid-template-columns: 44px 28px 1fr; gap: 8px; padding: 8px 0; position: relative; }
.tle::before { content: ""; position: absolute; left: 57px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tld { font-size: 12px; color: var(--muted); padding-top: 5px; font-variant-numeric: tabular-nums; }
.tldot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); position: relative; z-index: 1; }
.tle-imaging .tldot { background: color-mix(in srgb, var(--s2) 16%, var(--surface)); color: var(--s2); }
.tle-vaccine .tldot { background: var(--good-bg); color: var(--good); }
.tle-care .tldot, .tle-med .tldot { background: var(--warn-bg); color: var(--warn); }
.tle .grow { min-width: 0; }
.tlt { margin-top: 4px; white-space: pre-wrap; }

/* документы: виды исследований, пересказ */
.mchips.sub { margin-top: -6px; }
.plainbox { margin-bottom: 14px; }
.plainbox .row { flex-wrap: wrap; gap: 8px; }
.dplain { margin: -4px 0 8px 48px; padding: 8px 10px; border-left: 3px solid var(--good); background: var(--good-bg); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
details.dconcl summary { cursor: pointer; }
@media (max-width: 640px) { .dplain { margin-left: 0; } }

/* показатели: группы, карта отклонений, сравнение */
.mgroups { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.mgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; }
.mgroup summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.mgroup[open] summary { margin-bottom: 8px; }
.mgroup .mchips { margin-bottom: 2px; }
.dot-bad { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); display: inline-block; }
.heat { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.heat th { font-weight: 500; color: var(--muted); text-align: center; font-size: 12px; }
.heat td.hn { padding-right: 10px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.heat tr[data-k] { cursor: pointer; }
.heat tr[data-k]:hover td.hn { color: var(--link); }
.hc { width: 26px; min-width: 26px; height: 20px; border-radius: 4px; background: var(--surface-3); text-align: center; font-size: 11px; color: var(--bad); font-weight: 700; }
.hc-ok { background: color-mix(in srgb, var(--good) 35%, var(--surface)); }
.hc-bad { background: color-mix(in srgb, var(--bad) 55%, var(--surface)); color: #fff; }
.hk { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); vertical-align: -1px; margin-left: 8px; }
.hk.hc-ok { background: color-mix(in srgb, var(--good) 35%, var(--surface)); } .hk.hc-bad { background: color-mix(in srgb, var(--bad) 55%, var(--surface)); }
tr.hg td { padding-top: 10px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.cmp td, .cmp th { padding: 6px 8px; }
.cmp td:first-child { min-width: 160px; }

/* порядок в данных */
.tidyl details, #tidy details { border-top: 1px solid var(--line); padding: 8px 0; }
.trow { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0 6px 6px; font-size: 14px; border-top: 1px dashed var(--line); }
.trow input, summary input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.trow span { min-width: 0; overflow-wrap: anywhere; }
#tidy summary { cursor: pointer; }
#tidy .card { margin-bottom: 12px; }
#tidy .card-h { flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { #mmode { width: 100%; } #mmode button { flex: 1; padding: 6px 4px; font-size: 12.5px; } }
.hlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.hlegend .hk { margin-left: 0; margin-right: 4px; }
table.heat { width: auto; }
@media (max-width: 640px) { .heat td.hn { max-width: 150px; font-size: 12.5px; } .hc { width: 20px; min-width: 20px; } }
.heat td, .heat th { padding: 0; height: 22px; }
.heat td.hn { padding-right: 10px; } tr.hg td { padding-top: 10px; }

/* доступ: QR со ссылкой на приложение */
.qrcard { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.qrcard img { width: 150px; height: 150px; border-radius: 10px; background: #fff; padding: 6px; flex: none; }
.qrcard h2 { margin: 0 0 6px; }
.qrcard p { margin: 0 0 10px; }
@media (max-width: 560px) { .qrcard { flex-direction: column; align-items: center; text-align: center; } .qrcard .row { justify-content: center; } }
/* длинные названия показателей не вылезают за край */
.mchips .chip { max-width: 100%; white-space: normal; text-align: left; overflow-wrap: anywhere; }

/* строка документа: название растягивается, выбор «чей?» и кнопки — справа по своей ширине; на телефоне выбор переходит на строку ниже */
.drow > .grow { flex: 1 1 auto; min-width: 0; }
.drow > select { width: auto; flex: 0 0 auto; max-width: 260px; }
.drow > button, .drow > .btn { flex: none; }
@media (max-width: 640px) {
  .drow:has(> select) { flex-wrap: wrap; padding-bottom: 10px; }
  .drow > select { flex: 1 1 100%; max-width: none; }
}
