:root {
  --bg: #f3f6f5; --surface: #fff; --ink: #14231f; --muted: #5b6b66; --line: #dce5e1;
  --primary: #0f5c55; --primary-ink: #fff; --primary-soft: #e3f1ee;
  --crit: #b3261e; --crit-soft: #fdecea;
  --warn-ink: #7a4b00; --warn-soft: #fff4d6; --warn-line: #d9a21b;
  --ok: #1f7a3d; --ok-soft: #e6f4ea;
  --orange: #b4500b; --orange-soft: #ffe8d4; --orange-line: #e0701c;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px; min-height: 44px; font-weight: 600; }
.btn:hover { background: var(--primary-soft); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: #0b4a45; }
.btn.danger { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid #1d7a72; outline-offset: 2px; }

/* бейджи: различимы не только цветом, но и значком и рамкой */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge.crit { background: var(--crit); color: #fff; border: 2px solid var(--crit); }
.badge.mand { background: var(--crit); color: #fff; border: 2px solid var(--crit); }
.badge.desir { background: var(--warn-soft); color: var(--warn-ink); border: 2px dashed var(--warn-line); }
.badge.none { background: var(--ok-soft); color: var(--ok); border: 2px solid transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); border: 2px solid var(--warn-line); }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; display: flex; gap: 10px; }
.banner.crit { background: var(--crit-soft); border: 2px solid var(--crit); }
.banner.warn { background: var(--warn-soft); border: 2px solid var(--warn-line); }
.banner.ok { background: var(--ok-soft); border: 2px solid var(--ok); }
.banner .ico { font-size: 20px; line-height: 1.2; }
.banner.crit .ico { color: var(--crit); }

/* вход */
.login { max-width: 460px; margin: 6vh auto; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--primary); }
.brand svg { width: 30px; height: 30px; }
.demo-grid { display: grid; gap: 8px; margin: 12px 0; }
.demo-grid .btn { text-align: left; }
input[type=text], input[type=password], textarea { width: 100%; padding: 10px 12px; border: 1px solid #b9c7c2; border-radius: 10px; background: #fff; }

/* каркас */
.topbar { background: var(--primary); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
.topbar .brand { color: #fff; font-size: 17px; }
.topbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); min-height: 36px; padding: 4px 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6ee7a8; display: inline-block; }
.dot.off { background: #f59e8b; }

/* врач */
.doc { display: grid; grid-template-columns: 330px 1fr; gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { .doc { grid-template-columns: 1fr; } }
.plist .item { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left-width: 6px; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.plist .item.sel { outline: 3px solid var(--primary); }
.plist .item.s-red { border-left-color: var(--crit); background: var(--crit-soft); }
.plist .item.s-orange { border-left-color: var(--orange-line); }
.plist .item.s-yellow { border-left-color: var(--warn-line); }
.plist .item.s-none { border-left-color: var(--ok); }
.scores { display: flex; gap: 14px; margin-top: 6px; }
.scores b { font-size: 18px; }
.sect-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 4px 12px; font-size: 14px; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } }
.list { margin: 6px 0; padding-left: 20px; }
.list li { margin: 3px 0; }
.chk-crit { color: var(--crit); font-weight: 600; }
.chk-warn { color: var(--warn-ink); }
.src { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart text { font-size: 10px; fill: #5b6b66; }
.chat { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.msg { padding: 8px 10px; border-radius: 12px; max-width: 85%; font-size: 14px; }
.msg.doctor { background: var(--primary-soft); align-self: flex-start; }
.msg.patient { background: #eef0f6; align-self: flex-end; }
.msg.system { background: var(--warn-soft); border: 1px dashed var(--warn-line); }
.msg time { display: block; font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 600; min-height: 36px; }
.tab.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* пациент */
.pat { max-width: 520px; margin: 0 auto; padding: 14px 14px 80px; }
.sos { width: 100%; background: var(--crit); color: #fff; border: 0; border-radius: 14px; padding: 16px; font-weight: 800; font-size: 17px; min-height: 56px; }
.task { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.opts { display: grid; gap: 10px; margin: 14px 0; }
.opt { text-align: left; padding: 14px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-weight: 600; min-height: 52px; }
.opt:hover, .opt.on { border-color: var(--primary); background: var(--primary-soft); }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 16px; }
.progress i { display: block; height: 100%; background: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font-size: 14px; min-height: 40px; }
.chip.on { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.chip.severe.on { border-color: var(--crit); background: var(--crit-soft); color: var(--crit); }
input[type=range] { width: 100%; accent-color: var(--primary); }
.big { font-size: 34px; font-weight: 800; }

#toasts { position: fixed; right: 14px; top: 64px; display: grid; gap: 10px; z-index: 50; max-width: 380px; }
.toast { background: var(--crit); color: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .25s ease-out; }
.toast.info { background: #26433f; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---- цвета алертов: красный / оранжевый / жёлтый, различимы значком и рамкой ---- */
.badge.orange { background: var(--orange-soft); color: var(--orange); border: 2px solid var(--orange-line); }
.banner.orange { background: var(--orange-soft); border: 2px solid var(--orange-line); }
.banner.orange .ico { color: var(--orange); }
.toast.orange { background: var(--orange); }
.toast.yellow { background: #7a4b00; }
.good { color: var(--ok); font-weight: 700; }
.nowrap { white-space: nowrap; }

.chain { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.chain .step { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); background: #fff; }
.chain .step.on { border: 1px solid var(--primary); color: var(--primary); font-weight: 600; background: var(--primary-soft); }

.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 6px 0; }
.meter .bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.meter .bar i { display: block; height: 100%; background: var(--ok); }
.meter .bar i.mid { background: var(--warn-line); }
.meter .bar i.hi { background: var(--orange-line); }
.meter .bar i.crit { background: var(--crit); }
.hyp, .stage { border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 0 10px 10px 0; padding: 10px 12px; margin: 10px 0; }
.stage .alt { background: #fff; border: 1px dashed var(--primary); border-radius: 8px; padding: 6px 8px; }
.raw { width: 100%; border-collapse: collapse; margin-top: 10px; }
.raw td, .jt td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.raw tr.rowcrit td { background: var(--crit-soft); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 14px; }
.chk { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 4px 0; }
.chk input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--primary); }
details.card summary { cursor: pointer; }
.proto { margin-top: 14px; padding-top: 10px; border-top: 2px solid var(--crit); }

.chip-st { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 2px solid; }
.chip-st.green { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.chip-st.yellow { color: var(--warn-ink); border-color: var(--warn-line); background: var(--warn-soft); }
.chip-st.red { color: #fff; border-color: var(--crit); background: var(--crit); }
.ddi { margin: 6px 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.ddi.yellow { background: var(--warn-soft); border-color: var(--warn-line); }
.ddi.red { background: var(--crit-soft); border-color: var(--crit); }
.chips-med { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip-med { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; }
.chip-med button { border: 0; background: var(--line); border-radius: 50%; width: 22px; height: 22px; line-height: 20px; padding: 0; }

/* полноэкранный красный алерт врача */
.overlay { position: fixed; inset: 0; z-index: 100; background: #8c1b14; color: #fff; display: grid; place-items: center; padding: 20px; overflow: auto; animation: flash 1.4s ease-out 1; }
.ov-box { max-width: 760px; text-align: center; }
.ov-box h1 { font-size: clamp(26px, 5vw, 42px); margin: 8px 0 12px; }
.ov-ico { font-size: 72px; line-height: 1; }
.ov-p { font-size: 18px; }
.ov-list { text-align: left; display: inline-block; font-size: 16px; }
@keyframes flash { 0% { background: #ff3b30; } 100% { background: #8c1b14; } }
@media (prefers-reduced-motion: reduce) { .overlay { animation: none; } }

.modal { position: fixed; inset: 0; z-index: 90; background: rgba(10, 25, 22, .55); display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal-box { background: #fff; border-radius: 16px; padding: 20px; max-width: 640px; width: 100%; }

/* экран безопасности пациента */
.safety { min-height: 100vh; background: #8c1b14; color: #fff; padding: 28px 18px; max-width: 560px; margin: 0 auto; }
.safety h1 { font-size: 28px; margin: 6px 0 12px; }
.sf-ico { font-size: 56px; }
.sf-p { font-size: 17px; }
.phones { display: grid; gap: 10px; margin: 12px 0; }
.phone { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; color: #8c1b14; text-decoration: none; padding: 14px; border-radius: 12px; font-weight: 600; border: 2px solid #8c1b14; }
.phone b { font-size: 20px; white-space: nowrap; }
.banner .phones .phone { background: #fff; }
.safety .btn { color: #8c1b14; background: #fff; border-color: #fff; }

/* ======= v2: спокойный светлый стиль (небо / крем / тёплый жёлтый акцент) ======= */
:root {
  --bg: #eef7fa; --surface: #fff; --ink: #17324d; --muted: #5f7488; --line: #e1edf2;
  --primary: #1b83a3; --primary-ink: #fff; --primary-soft: #e3f4f9; --navy: #1d578c; --sun: #ffc90a;
  --crit: #c4302b; --crit-soft: #fff0ee;
  --warn-ink: #7a5300; --warn-soft: #fff6d9; --warn-line: #f0c43a;
  --ok: #1f8a56; --ok-soft: #e6f6ee;
  --orange: #b45a12; --orange-soft: #ffeedd; --orange-line: #f0913d;
  --radius: 20px; --shadow: 0 8px 28px rgba(29, 87, 140, .08);
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body { background: radial-gradient(1100px 520px at 90% -10%, #d8f1f8 0%, transparent 60%), radial-gradient(900px 480px at -10% 0%, #fff6d6 0%, transparent 55%), var(--bg); background-attachment: fixed; font-size: 15px; line-height: 1.55; }
h1, h2, h3, .brand, .btn, .tab, .big, .badge { font-family: 'Montserrat', 'Open Sans', system-ui, sans-serif; }
h2 { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
h3 { font-size: 14px; font-weight: 700; color: var(--navy); margin: 16px 0 6px; }
.card { border: 0; box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.btn { border: 0; background: #fff; border-radius: 999px; padding: 10px 20px; font-weight: 700; box-shadow: 0 2px 10px rgba(29, 87, 140, .1); transition: transform .15s, box-shadow .15s, background .15s; }
.btn:hover { background: var(--primary-soft); transform: translateY(-1px); }
.btn.primary { background: var(--primary); box-shadow: 0 6px 16px rgba(27, 131, 163, .35); }
.btn.primary:hover { background: var(--navy); }
.btn.danger { background: var(--crit); box-shadow: 0 6px 16px rgba(196, 48, 43, .3); }
.btn.small { padding: 6px 14px; }
input[type=text], input[type=password], textarea { border: 2px solid var(--line); border-radius: 14px; padding: 11px 14px; background: #fbfdfe; }
input:focus, textarea:focus { border-color: var(--primary); outline: none; background: #fff; }

/* бейджи и баннеры: пастельные, без тяжёлых рамок */
.badge { border: 0 !important; padding: 3px 11px; font-weight: 700; font-size: 11.5px; }
.badge.crit, .badge.mand { background: var(--crit); color: #fff; }
.badge.desir { background: var(--warn-soft); color: var(--warn-ink); box-shadow: inset 0 0 0 1.5px var(--warn-line); }
.badge.none { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.banner { border: 0 !important; border-radius: 16px; padding: 14px 16px; box-shadow: inset 4px 0 0 var(--line); }
.banner.crit { background: var(--crit-soft); box-shadow: inset 5px 0 0 var(--crit); }
.banner.warn { background: var(--warn-soft); box-shadow: inset 5px 0 0 var(--warn-line); }
.banner.orange { background: var(--orange-soft); box-shadow: inset 5px 0 0 var(--orange-line); }
.banner.ok { background: var(--ok-soft); box-shadow: inset 5px 0 0 var(--ok); }
.chip-st { border: 0; padding: 2px 10px; }
.ddi { border: 0 !important; border-radius: 14px; }

/* верхняя панель: светлая, с логотипом */
.topbar { background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); color: var(--ink); box-shadow: 0 2px 18px rgba(29, 87, 140, .08); padding: 12px 24px; }
.topbar .brand { color: var(--navy); font-size: 17px; font-weight: 800; }
.topbar .btn { background: var(--primary-soft); color: var(--navy); box-shadow: none; }
.brand svg { width: 38px; height: 38px; filter: drop-shadow(0 4px 8px rgba(29, 87, 140, .25)); }
.login { max-width: 520px; margin-top: 7vh; }
.login .brand { font-size: 26px; margin-bottom: 8px; }
.login .brand svg { width: 56px; height: 56px; }

/* список пациентов: карточки с цветной точкой вместо толстой рамки */
.doc { gap: 28px; padding: 24px; grid-template-columns: 340px 1fr; }
.plist h2 { margin-left: 4px; }
.plist .item { border: 0; border-radius: 18px; padding: 16px 16px 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow); position: relative; transition: transform .15s; }
.plist .item:hover { transform: translateY(-2px); }
.plist .item::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 5px; border-radius: 0 5px 5px 0; background: var(--ok); }
.plist .item.s-red { background: var(--crit-soft); } .plist .item.s-red::before { background: var(--crit); }
.plist .item.s-orange::before { background: var(--orange-line); }
.plist .item.s-yellow::before { background: var(--sun); }
.plist .item.sel { outline: 0; box-shadow: 0 0 0 3px var(--primary), var(--shadow); }
.scores b { font-family: 'Montserrat', sans-serif; color: var(--navy); }
.tabs { gap: 8px; margin: 4px 0 20px; }
.tab { border: 0; background: #fff; box-shadow: 0 2px 10px rgba(29, 87, 140, .08); padding: 8px 18px; font-size: 13.5px; }
.tab.on { background: var(--navy); }

/* вторичное — свёрнуто */
details.more { margin: 14px 0 4px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.more > summary { cursor: pointer; color: var(--primary); font-weight: 700; font-size: 13.5px; list-style: none; }
details.more > summary::before { content: '＋ '; }
details.more[open] > summary::before { content: '－ '; }
details.more > summary::-webkit-details-marker { display: none; }
.kv { gap: 8px 16px; grid-template-columns: 230px 1fr; } .kv b { color: var(--muted); font-weight: 600; font-size: 13px; }
.chain .step { border: 0; background: #f2f7fa; } .chain .step.on { background: var(--primary-soft); color: var(--navy); }
.hyp, .stage { border: 0; border-radius: 16px; background: var(--primary-soft); padding: 14px 16px; }
.stage .alt { border: 0; background: #fff; border-radius: 12px; padding: 8px 10px; }
.raw td, .jt td { border-top: 1px solid var(--line); }
.proto { border-top: 0; margin-top: 18px; padding: 16px; background: var(--crit-soft); border-radius: 16px; }
.meter .bar { height: 12px; background: #e8f1f5; }
.msg.doctor { background: var(--primary-soft); } .msg.patient { background: #fff3cf; }
.msg { border-radius: 16px; padding: 10px 14px; }
.modal-box { border-radius: 24px; padding: 28px; }

/* пациент: крупно, воздушно, дружелюбно */
.pat { padding: 20px 18px 90px; }
.opt, .chip { border: 0; box-shadow: 0 2px 12px rgba(29, 87, 140, .1); border-radius: 18px; transition: transform .12s, background .12s; }
.opt:hover, .opt.on { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary); transform: scale(1.01); }
.chip.on { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary); }
.chip.severe.on { background: var(--crit-soft); box-shadow: 0 0 0 3px var(--crit); }
.progress { height: 10px; background: #d9ecf3; } .progress i { background: linear-gradient(90deg, #4bcced, var(--primary)); border-radius: 99px; }
.sos { border-radius: 999px; box-shadow: 0 10px 24px rgba(196, 48, 43, .35); }
.task { border-bottom: 1px dashed var(--line); }
.toast { border-radius: 18px; box-shadow: 0 14px 34px rgba(0, 0, 0, .22); }
.overlay { background: #9b221c; }
.phone { border: 0; border-radius: 18px; }

/* v3: мягкий экран пациента (без тревожного красного) */
.safety { background: linear-gradient(180deg, #dff3f8 0%, #f6fbfd 60%); color: #17324d; }
.safety h1 { color: #1d578c; font-size: 25px; line-height: 1.2; }
.sf-ico { font-size: 52px; color: #1b83a3; line-height: 1; }
.phone { color: #17324d; border: 1.5px solid #bfe0ea; background: #fff; }
.phone b { color: #1b83a3; }
.phone span small { display: block; font-weight: 500; color: #5f7488; font-size: 13px; margin-top: 2px; }
.phone.doc { border-color: #ffc90a; background: #fffbea; }
.phone.doc b { color: #17324d; }
.safety .btn { color: #17324d; background: #fff; border: 1.5px solid #bfe0ea; }
.banner.soft { background: #e8f6fa; border: 1px solid #bfe0ea; color: #17324d; }
.banner.soft .ico { color: #1b83a3; }

/* v3: Нейрончик и искры */
.mascot-card { display: flex; gap: 10px; align-items: center; background: linear-gradient(135deg, #fffbea, #e9f7fb); border: 1px solid #cfe8ef; border-radius: 20px; padding: 12px 14px; margin-bottom: 14px; }
.mc-body { flex: 1; min-width: 0; }
.bubble { position: relative; background: #fff; border-radius: 14px; padding: 9px 12px; font-size: 14.5px; line-height: 1.3; box-shadow: 0 2px 8px rgba(29, 87, 140, .08); }
.bubble:before { content: ''; position: absolute; left: -7px; top: 18px; border: 7px solid transparent; border-right-color: #fff; border-left: 0; }
.mc-stats { display: flex; gap: 6px; margin: 8px 0 6px; flex-wrap: wrap; }
.chipx { background: #fff; border: 1px solid #cfe8ef; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; color: #1d578c; }
.lvl-h { display: flex; justify-content: space-between; font-size: 13px; color: #1d578c; margin-bottom: 4px; }
.gain { font-weight: 800; color: #b57f00; font-size: 16px; animation: pop .6s cubic-bezier(.2, .9, .3, 1.4); }
.gain.big { font-size: 28px; margin: 6px 0 10px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* v4: спокойный интерфейс (ориентир: Flo): мало кнопок, один главный шаг, остальное свёрнуто */
.pat.calm { padding-top: 6px; }
.big-cta { width: 100%; padding: 15px 18px; font-size: 17px; border-radius: 999px; margin: 4px 0 14px; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; padding: 8px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--primary); }
.back { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 18px; color: var(--navy); cursor: pointer; margin-bottom: 6px; }
details.fold { background: #fff; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 10px; }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 700; color: var(--navy); display: flex; justify-content: space-between; align-items: center; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: '›'; font-size: 20px; color: var(--muted); transition: transform .2s; }
details.fold[open] > summary::after { transform: rotate(90deg); }
.fold-b { padding: 0 16px 14px; }
.qrow { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 0; text-align: left; cursor: pointer; font: inherit; color: var(--ink); }
.qrow:first-child { border-top: 0; }
.qrow small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.qrow i { font-style: normal; color: var(--muted); font-size: 20px; }
.sos-line { text-align: center; margin: 14px 0 4px; }
.sos-line small { display: block; color: var(--muted); font-size: 12px; }
.sos-line .linkbtn { color: #b3261e; font-weight: 600; }
.foot { text-align: center; margin: 6px 0 20px; }
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--navy); padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 38px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(29, 87, 140, .14); padding: 6px 10px; display: flex; flex-direction: column; z-index: 20; min-width: 130px; }
.plist .item .scores { margin-top: 4px; }

/* v5: карточка маскота */
.mascot-card { display:grid; grid-template-columns:minmax(120px,42%) minmax(0,1fr); gap:12px; }
@media(max-width:360px) {
  .mascot-card { grid-template-columns:minmax(0,1fr); }
  .bubble:before { display:none; }
}
@media(prefers-reduced-motion:reduce) {
  .gain,.gain.big { animation:none; }
}

/* КЛК: уровни маршрута и статусы взаимодействий (оранжевый и серый) */
.badge.mand2 { background: var(--orange); color: #fff; }
.chip-st.orange { color: #fff; background: var(--orange); }
.chip-st.grey { color: #3d4a46; background: #e3e8e6; box-shadow: inset 0 0 0 1.5px #98a5a0; }
.ddi.orange { background: var(--orange-soft); box-shadow: inset 0 0 0 1.5px var(--orange-line); }
.ddi.grey { background: #eef1f0; box-shadow: inset 0 0 0 1.5px #b3bdb9; }
.banner.orange { background: var(--orange-soft); }

/* клинический блок пациента */
.cq { border: 0; padding: 0; margin: 14px 0 0; }
.cq legend { font-size: 17px; font-weight: 600; padding: 0; margin-bottom: 6px; line-height: 1.35; }
.medrow { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr; gap: 6px; margin: 6px 0; }
.medrow input { min-width: 0; }
@media (max-width: 480px) { .medrow { grid-template-columns: 1fr; } }
.phones { max-width: 100%; }
.phone { flex-wrap: wrap; gap: 2px 10px; box-sizing: border-box; max-width: 100%; }
.phone span { min-width: 0; flex: 1 1 120px; }
/* toast не перекрывает шапку: ниже топбара, на узких экранах по ширине с отступами */
#toasts { top: 76px; }
@media (max-width: 600px) { #toasts { left: 12px; right: 12px; max-width: none; } }

/* ======= v6: палитра и форма под овечку (крем / голубой из ушек / тёмно-синий глаз / румянец) =======
   Контраст (WCAG AA): ink #1b2a4e на кремовом ≈ 13:1; muted #566083 на кремовом ≈ 5.8:1; белый на --primary #3d5c9c ≈ 6.6:1.
   Румянец (--blush) и голубой ушек (--ear) — только фоны и декор, текста на них нет без тёмно-синего. */
:root {
  --bg: #fbf5ea; --surface: #fffdf8; --ink: #1b2a4e; --muted: #566083; --line: #eadfca;
  --cream: #f6e9d2; --ear: #a9c1e6; --blush: #f6c3b8;
  --primary: #3d5c9c; --primary-soft: #e8eefa; --navy: #22345f;
  --ok: #1f7a4d; --ok-soft: #e7f4ec;
  --radius: 22px; --shadow: 0 6px 22px rgba(60, 70, 110, .09);
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
body { background: radial-gradient(900px 480px at 100% -10%, #e8eefa 0%, transparent 60%), radial-gradient(800px 460px at -10% 0%, #fdeedb 0%, transparent 55%), var(--bg); background-attachment: fixed; }
h1, h2, h3, .brand, .btn, .tab, .big, .badge, .scores b { font-family: 'Montserrat', 'Open Sans', system-ui, sans-serif; }
.card, .plist .item { box-shadow: var(--shadow); }
.btn { box-shadow: 0 2px 10px rgba(60, 70, 110, .1); }
.btn:hover { background: var(--primary-soft); }
.btn.primary { background: var(--primary); box-shadow: 0 6px 16px rgba(61, 92, 156, .3); }
.btn.primary:hover { background: var(--navy); }
.btn.danger { background: var(--crit); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
input[type=text], input[type=password], textarea { background: #fffefb; border-color: var(--line); }
input:focus, textarea:focus { border-color: var(--primary); }
.topbar { background: rgba(255, 253, 248, .9); box-shadow: 0 2px 16px rgba(60, 70, 110, .07); }
.topbar .btn, details.menu > summary { background: var(--primary-soft); color: var(--navy); }
.brand svg { filter: drop-shadow(0 3px 6px rgba(60, 70, 110, .2)); }
.tab.on { background: var(--navy); }
.plist .item.s-yellow::before { background: var(--warn-line); }
.chain .step { background: #f8f1e4; } .chain .step.on, .hyp, .stage { background: var(--primary-soft); }
.msg.doctor { background: var(--primary-soft); } .msg.patient { background: #fdebdd; }
.meter .bar { background: #efe6d4; }
.src { border-top-color: var(--line); }
.progress { background: #efe6d4; height: 10px; } .progress i { background: linear-gradient(90deg, var(--ear), var(--primary)); }
.opt, .chip { background: var(--surface); box-shadow: 0 2px 10px rgba(60, 70, 110, .09); }
.opt:hover, .opt.on, .chip.on { background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary); transform: none; }
.chip { min-height: 44px; }
.back { width: 44px; height: 44px; background: var(--surface); border-color: var(--line); }
.linkbtn { min-height: 44px; padding: 10px 6px; }
details.fold { background: var(--surface); border-color: var(--line); border-radius: 20px; }
details.fold > summary { min-height: 52px; }
.qrow { min-height: 44px; border-top-color: var(--line); }
.sos-line .linkbtn { color: #a82822; }
.chipx { background: var(--surface); border: 1px solid var(--line); color: var(--navy); }
.lvl-h { color: var(--navy); }
.gain { color: #8a5a00; }

/* овечка: спутник, а не декор */
.mascot-card { background: linear-gradient(135deg, #fff8ea 0%, #eaf0fb 100%); border: 0; border-radius: 28px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px 12px; align-items: center; padding: 14px 16px 16px 8px; }
#app .sheep img { filter: drop-shadow(0 8px 10px rgba(60, 70, 110, .16)); }
#app .mascot-card .sheep { width: 100%; max-width: 128px; margin: 0 auto; }
.bubble { background: var(--surface); color: var(--ink); border-radius: 18px; padding: 10px 14px; font-size: 15px; line-height: 1.35; box-shadow: 0 2px 10px rgba(60, 70, 110, .09); }
.bubble:before { left: -8px; top: 22px; border-width: 8px; border-right-color: var(--surface); }
.mc-body .progress { margin: 6px 0; }
@media (min-width: 700px) { .mascot-card { grid-template-columns: 150px minmax(0, 1fr); } #app .mascot-card .sheep { max-width: 160px; } }
@media (max-width: 359px) { .mascot-card { grid-template-columns: 88px minmax(0, 1fr); } .bubble:before { display: block; } }
/* итог: крупная овечка над заголовком, текст и кнопки не перекрываются */
#app .pat .card .sheep.lg { width: min(190px, 52%); margin: 0 auto 8px; }
.banner.soft { background: #eef2fb; border: 0; box-shadow: inset 5px 0 0 var(--ear); align-items: center; }
#app .banner.soft .sheep.sm, #app .sheep.sm { width: 64px; flex: none; margin: 0; }
#app .calm-c7 .sheep.sm { display: block; margin: 0 auto 4px; width: 96px; }

/* экран безопасности: спокойный, тёплый, без тревожных цветов */
.safety { background: linear-gradient(180deg, #e8eefa 0%, #fbf5ea 62%); color: var(--ink); }
.safety h1 { color: var(--navy); font-size: 25px; }
#app .safety .sheep.lg { width: 150px; margin: 0 0 4px; }
.phone { color: var(--ink); background: var(--surface); border: 1.5px solid #d7e1f3; box-shadow: var(--shadow); min-height: 56px; }
.phone b { color: var(--primary); }
.phone span small { color: var(--muted); }
.phone.doc { background: #fff6e4; border-color: #ecd3a4; }
.phone.doc b { color: var(--ink); }
.safety .btn { color: var(--navy); background: var(--surface); border: 1.5px solid #d7e1f3; }
.banner.soft .ico, .sf-ico { color: var(--primary); }

/* касательные цели ≥ 44 px на мобильном */
@media (max-width: 700px), (pointer: coarse) {
  .btn.small, .tab, .topbar .btn, details.menu > summary { min-height: 44px; }
  .menu-pop button, .menu-pop a { min-height: 44px; }
}
@media (max-width: 430px) { .pat { padding-left: 14px; padding-right: 14px; } .card { padding: 18px; } }

/* вход: овечка рядом с названием, не мешает кнопкам */
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.login-head .brand { margin: 0 !important; }
#app .login-head .sheep.sm { width: 88px; }
.demo-grid .btn { border-radius: 20px; }

/* красный алерт врача: не обрезается на узком экране */
.overlay { grid-template-columns: minmax(0, 1fr); place-items: start center; align-content: center; }
.ov-box { width: 100%; min-width: 0; }
.overlay .btn { white-space: normal; height: auto; }
.ov-list { max-width: 100%; }
@media (max-width: 900px) { .doc { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 16px; } .doc > * { min-width: 0; } .row.spread { min-width: 0; } .badge { white-space: normal; } }
@media (max-width: 700px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv > * { min-width: 0; overflow-wrap: anywhere; } .kv b { margin-top: 6px; } }

/* safety: фон на всю ширину, контакт врача не наследует сетку .doc */
body:has(.safety) { background: linear-gradient(180deg, #e8eefa 0%, #fbf5ea 62%) fixed; }
.safety { background: transparent; }

/* Краткая сводка и проверяемое основание решения врача. */
.doctor-summary { border: 1px solid #cbd9ee; background: #f7f9fd; }
.summary-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.summary-heading h2 { font-size:20px; margin:0; color:#1b2a4e; }
.summary-heading p { margin:4px 0 0; color:#34496d; font-size:13px; }
.summary-label { background:#e5edfa; color:#263d68; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:700; }
.summary-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-top:14px; }
.summary-panel { min-width:0; background:#fff; border:1px solid #e1e8f4; border-radius:14px; padding:14px; }
.summary-panel h3 { color:#1b2a4e; margin:0 0 8px; }
.summary-panel p, .summary-list, .summary-panel summary { color:#34496d; font-size:13px; line-height:1.5; margin:5px 0; overflow-wrap:anywhere; }
.summary-panel summary { cursor:pointer; min-height:44px; display:flex; align-items:center; font-weight:700; color:#344f89; }
.summary-list { padding-left:18px; }
.summary-list li { margin:6px 0; }
.summary-list time { white-space:nowrap; font-weight:600; }
.summary-footer { font-size:13px; color:#34496d; margin:12px 0 0; }
.decision-context { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; padding:14px; margin:10px 0; background:#f3f6fc; border-radius:14px; }
.decision-context > div { min-width:0; overflow-wrap:anywhere; }
.decision-context p { margin:5px 0; }
.submission-status { display:inline-flex; padding:6px 12px; border-radius:999px; background:#e8f1eb; color:#174f36; font-size:14px; font-weight:700; }
@media(max-width:900px) { .summary-grid,.decision-context { grid-template-columns:minmax(0,1fr); } }

/* Пациентские результаты: отдельная шкала для каждого опросника. */
.patient-metrics { color: #1b2a4e; }
.patient-metrics h2 { font-size: 20px; }
.metric-intro, .metric-caption, .metric-details p, .metric-foot { color: #34496d; font-size: 14px; line-height: 1.5; }
.metric-scale { border-top: 1px solid #d7e1f3; padding-top: 15px; margin-top: 15px; }
.metric-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.metric-head h3 { margin: 0; font-size: 17px; }
.metric-head span { font-size: 14px; font-weight: 600; }
.metric-caption { margin: 8px 0 12px; }
.metric-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.metric-row { display: grid; grid-template-columns: 82px minmax(30px,1fr) minmax(64px,auto); gap: 8px; align-items: center; font-size: 13px; }
.metric-date { color: #34496d; white-space: nowrap; }
.metric-row b { text-align: right; font-size: 13px; }
.metric-track { background: #e6edf9; border-radius: 999px; height: 12px; overflow: hidden; }
.metric-track i { display: block; height: 100%; width: var(--fill); border-radius: inherit; background: #3c5996; transform-origin: left; animation: metric-fill .45s ease-out both; }
@keyframes metric-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.metric-details { margin-top: 8px; }
.metric-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: #344f89; font-weight: 700; }
.metric-details summary::after { content: ' +'; margin-left: 6px; }
.metric-details[open] summary::after { content: ' −'; }
.metric-details p { margin: 0 0 8px; }
.metric-foot { border-radius: 12px; background: #eef2fa; padding: 12px; margin: 16px 0 0; }
@media (prefers-reduced-motion: reduce) { .metric-track i { animation: none; } }
@media (max-width: 430px) {
  .safety .phone { display: grid; grid-template-columns: 1fr; gap: 5px; }
  .mascot-card { grid-template-columns: 92px minmax(0, 1fr); }
  .bubble { padding-left: 10px; padding-right: 10px; white-space: nowrap; font-size: 14px; }
}
.phone.doc { display: flex; grid-template-columns: none; max-width: 100%; margin: 0; padding: 14px; gap: 2px 10px; }
.topbar .btn, details.menu > summary { white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.login details > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
/* шапка врача на узком экране: меню не выталкивает страницу за ширину экрана */
.topbar { min-width: 0; }
details.menu { min-width: 0; max-width: 46vw; }
details.menu > summary { max-width: 100%; }

/* Исправление: на узком экране шапка врача не должна сжимать меню пользователя до «Л.» */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 4px; padding: 10px 14px; }
  .topbar .brand span { font-size: 15px; }
  #live { order: 3; }
  #alert-sound { order: 4; font-size: 13px; padding: 4px 2px; min-height: 36px; }
  details.menu { max-width: 60vw; }
  details.menu > summary { max-width: 60vw; }
}
