:root {
  --bg: #f3efe7; --card: #fff; --ink: #1e2622; --muted: #6a716c; --line: #e2dccf; --soft: #f8f5ef;
  --brand: #1f6f5c; --brand-dark: #17574a; --brand-soft: #e3f0ec;
  --home: #5b8c3e; --home-soft: #eaf3e3; --planned: #b8900f; --planned-soft: #faf2d6;
  --urgent: #d2691e; --urgent-soft: #fbe9da; --emergency: #c2432d; --emergency-soft: #fae2dd;
  --radius: 14px; --shadow: 0 1px 2px rgba(30, 38, 34, .06), 0 4px 16px rgba(30, 38, 34, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--brand); }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; background: #1e2622; color: #fff; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand span { color: #9fd3c4; font-weight: 500; }
.roles { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.roles button { background: transparent; border: 1px solid rgba(255, 255, 255, .22); color: #dfe6e2; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.roles button.on { background: #fff; color: #1e2622; border-color: #fff; font-weight: 600; }
.demo-bar { background: #2b3530; color: #cdd6d1; font-size: 13px; }
.demo-bar-in { max-width: 1180px; margin: 0 auto; padding: 6px 16px; display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; }
.demo-bar select, .demo-bar button { font: inherit; font-size: 13px; background: #3a4640; color: #fff; border: 1px solid #55625b; border-radius: 8px; padding: 3px 8px; cursor: pointer; }
.demo-bar .sp { margin-left: auto; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 110px; }
main.wide { max-width: 1180px; }

/* карточки */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 0 0 14px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.tight { padding: 14px; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row.center { align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 10px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 15px; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-dark); }
.btn.sec { background: #fff; color: var(--brand); }
.btn.sec:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: var(--emergency); border-color: var(--emergency); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

/* формы */
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfc8b9; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.check + .check { margin-top: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 14px; padding: 7px 13px; border-radius: 999px; border: 1px solid #cfc8b9; background: #fff; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* метки */
.tag { display: inline-block; font-size: 12px; line-height: 1.3; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.draft { background: #fff7e0; color: #8a6a00; border-color: #ecd98f; }
.tag.ok { background: var(--home-soft); color: #3d6a26; border-color: #c5ddb3; }
.tag.stop { background: var(--emergency-soft); color: #9c2f1d; border-color: #efb9ae; }
.tag.review { background: var(--urgent-soft); color: #9a4a10; border-color: #f0c9a6; }
.tag.brand { background: var(--brand-soft); color: var(--brand-dark); border-color: #bcdcd3; }
.lvl { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.lvl.home { background: var(--home-soft); color: #3d6a26; } .lvl.planned { background: var(--planned-soft); color: #7c6000; }
.lvl.urgent { background: var(--urgent-soft); color: #9a4a10; } .lvl.emergency { background: var(--emergency-soft); color: #9c2f1d; }
.note { border-left: 3px solid var(--brand); background: var(--brand-soft); padding: 10px 12px; border-radius: 0 10px 10px 0; font-size: 14px; }
.note.warn { border-color: var(--planned); background: var(--planned-soft); }
.note.alert { border-color: var(--emergency); background: var(--emergency-soft); }
.note.grey { border-color: #b9b3a5; background: var(--soft); }

/* главная */
.entry { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; cursor: pointer; }
.entry:hover { border-color: var(--brand); }
.entry .ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--brand-soft); flex: none; }
.entry b { font-size: 17px; }
.formula { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.formula span { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; color: var(--ink); }

/* маршрут */
.group-h { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 8px; }
.group-h h2 { margin: 0; } .group-h .n { color: var(--muted); font-size: 14px; }
.act { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; border-left: 4px solid var(--line); }
.act.g-now { border-left-color: var(--urgent); } .act.g-soon { border-left-color: var(--planned); } .act.g-planned { border-left-color: var(--brand); }
.act.g-awaiting { border-left-color: #7a8cc4; } .act.g-later { border-left-color: #b9b3a5; } .act.g-done { border-left-color: var(--home); opacity: .92; }
.act h3 { margin: 0 0 2px; font-size: 16px; }
.act .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.origins { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.origins li { padding: 4px 0 4px 16px; position: relative; }
.origins li:before { content: ""; position: absolute; left: 2px; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.why { background: var(--soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }
.why h4 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.why ul { margin: 0; padding-left: 18px; }

/* слоты */
.slot-day { margin-top: 10px; } .slot-day b { font-size: 14px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.slot { font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid #cfc8b9; background: #fff; cursor: pointer; }
.slot:hover { border-color: var(--brand); background: var(--brand-soft); }

/* симптомайзер */
.q-card h2 { font-size: 21px; }
.q-items { margin: 8px 0 0; padding-left: 20px; }
.q-items li { margin: 2px 0; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.answers .btn { padding: 14px; font-size: 16px; }
.answers .wide { grid-column: 1 / -1; }
.progress { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 10px; }
.path { font-size: 13px; }
.path div { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.emergency-box { background: var(--emergency); color: #fff; border-radius: var(--radius); padding: 22px; }
.emergency-box h1 { color: #fff; } .emergency-box .phone { font-size: 44px; font-weight: 800; line-height: 1.1; margin: 8px 0; }
.result-head { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.result-head.home { background: var(--home-soft); } .result-head.planned { background: var(--planned-soft); } .result-head.urgent { background: var(--urgent-soft); }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); font-weight: 600; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }

/* вкладки внутри кабинетов */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs button { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.subtabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.subtabs .cnt { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--urgent); color: #fff; font-size: 12px; text-align: center; }

/* воронка */
.funnel-row { display: grid; grid-template-columns: 230px 1fr 90px; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.funnel-bar { height: 22px; background: var(--soft); border-radius: 6px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; }
.funnel-row .v { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .funnel-row { grid-template-columns: 1fr 70px; } .funnel-bar { grid-column: 1 / -1; order: 3; } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .lbl { font-size: 13px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* нижняя навигация пациента */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line); }
.tabs-in { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs button { font: inherit; font-size: 12px; background: none; border: 0; padding: 8px 4px 10px; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabs button .i { font-size: 20px; line-height: 1; }
.tabs button.on { color: var(--brand); font-weight: 600; }
.tabs .badge { position: absolute; top: 4px; left: 50%; margin-left: 8px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--emergency); color: #fff; font-size: 11px; line-height: 17px; }
.help-fab { position: fixed; right: 16px; bottom: 76px; z-index: 14; }

/* модальное окно и тосты */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(30, 38, 34, .5); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { background: #fff; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px; }
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 20px; } .modal { border-radius: 18px; } }
.modal.wide { max-width: 860px; }
.modal-x { float: right; font-size: 22px; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 6px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 520px; }
.toast { background: #1e2622; color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.diff-add { color: #3d6a26; } .diff-rem { color: #9c2f1d; }
details > summary { cursor: pointer; color: var(--brand); font-size: 14px; }
details[open] > summary { margin-bottom: 8px; }
.tree { font-size: 13px; }
.tree .n { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: #fff; }
.tree .n.o { background: var(--soft); }
.tree code { font-size: 12px; color: var(--muted); }

@media (max-width: 700px) { .top { position: static; } .demo-bar-in { font-size: 12px; gap: 6px 10px; } .roles button { padding: 4px 9px; font-size: 12px; } }
.doc-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; }
@media (max-width: 900px) { .doc-grid { grid-template-columns: 1fr; } }
