/* medik — стиль по брендбуку ред. 2 (согласован 15.09.2026) */
:root {
  --vein: #0B7399; --vein-deep: #075A78; --sky: #3DB3DA; --mist: #DDF1F6; --artery: #D6333F;
  --plasma: #F5F8F9; --surface: #FFFFFF; --tint: #E8F5F9;
  --ink: #1C2A31; --ink-2: #53646C; --line: #D4E4E9;
  --ok: #1E7A50; --ok-bg: #E3F3EA; --warn: #8F5A0B; --warn-bg: #FBEFD9; --crit: #C22634; --crit-bg: #FCE6E8;
  --on-vein: #FFFFFF; --outer: #E4EEF1;
  --shadow: 0 2px 6px rgba(11,115,153,.06), 0 14px 34px -12px rgba(28,42,49,.16);
  --display: "Montserrat", "Onest", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --vein: #5CC6EA; --vein-deep: #8AD7F1; --mist: #12303A; --artery: #F2646E;
    --plasma: #0A161B; --surface: #11222A; --tint: #16303A;
    --ink: #E6F1F4; --ink-2: #9FB6BE; --line: #22404A;
    --ok: #5BCB93; --ok-bg: #12301F; --warn: #F0B75A; --warn-bg: #33260F; --crit: #FF7A83; --crit-bg: #3A1519;
    --on-vein: #0A161B; --outer: #061015;
    --shadow: 0 2px 6px rgba(0,0,0,.3), 0 14px 34px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--outer); color: var(--ink); font: 16px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--vein); }
:focus-visible { outline: 3px solid var(--vein); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.app { max-width: 480px; min-height: 100dvh; margin: 0 auto; background: var(--plasma); display: flex; flex-direction: column; position: relative; }
@media (min-width: 520px) { .app { box-shadow: 0 0 60px rgba(28,42,49,.12); } }
.boot { flex: 1; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.top h1 { margin: 0; font: 600 1rem/1.15 var(--display); letter-spacing: .12em; text-transform: uppercase; }
.top .sub { display: block; margin-top: 4px; font-size: .78rem; color: var(--ink-2); }
.top .back { font: 600 .7rem var(--display); letter-spacing: .12em; text-transform: uppercase; text-decoration: none; color: var(--vein); display: inline-flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.acts { display: flex; gap: 6px; flex: none; }
.ic { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--mist); color: var(--vein); display: grid; place-items: center; cursor: pointer; text-decoration: none; position: relative; }
.ic svg { width: 19px; height: 19px; }
.ic.avatar { font: 700 .95rem var(--display); background: var(--vein); color: var(--on-vein); }
.ic.on { box-shadow: inset 0 0 0 2px var(--vein); }

main { flex: 1; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }

/* нижнее меню */
.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px 11px; font: 600 .62rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); text-decoration: none; border-top: 3px solid transparent; margin-top: -1px; position: relative; }
.tabs a svg { width: 23px; height: 23px; }
.tabs a[aria-current="page"] { color: var(--vein); border-top-color: var(--sky); }
.tabs a.off { opacity: .35; pointer-events: none; }

/* блоки */
.banner { position: relative; border-radius: 14px; overflow: hidden; height: 170px; box-shadow: var(--shadow); background: var(--mist); }
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner .cap { position: absolute; left: 10px; bottom: 10px; right: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent); border-radius: 10px; padding: 8px 12px; font-size: .86rem; box-shadow: var(--shadow); }
.banner .cap b { display: block; font: 600 .68rem var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--vein); margin-bottom: 2px; }

.sec { margin: 8px 2px -2px; font: 600 .64rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sec a, .sec button { font: 600 .64rem var(--display); letter-spacing: .12em; color: var(--vein); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; text-transform: uppercase; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; }
a.card, button.card { text-align: left; text-decoration: none; color: inherit; cursor: pointer; width: 100%; font: inherit; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card .lbl { font: 500 .7rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.card .big { font: 600 1.7rem/1 var(--body); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.card .big small { font: 500 .72rem var(--mono); color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.card .muted, .muted { color: var(--ink-2); font-size: .86rem; }
.card.alert { box-shadow: inset 0 0 0 2px var(--crit); }
.card.alert h3 { margin: 0; font: 600 .95rem var(--body); color: var(--crit); }
.card.empty { border-style: dashed; color: var(--ink-2); font-size: .9rem; }
.card h3 { margin: 0; font: 600 1rem var(--body); }
.list { display: grid; }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; }
.item .t { display: grid; gap: 1px; min-width: 0; }
.item .t b { font-weight: 600; overflow-wrap: anywhere; }
.item .t span { font-size: .82rem; color: var(--ink-2); }

.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 .74rem var(--body); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.crit, .pill.urgent { color: var(--crit); background: var(--crit-bg); }
.pill.crit::before, .pill.urgent::before { content: "!"; width: auto; height: auto; background: none; font-weight: 800; }
.pill.neutral { color: var(--vein); background: var(--mist); }
.pill.neutral::before { display: none; }

.btn { font: 600 .92rem var(--body); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 11px 18px; cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; }
.btn.primary { background: var(--vein); border-color: var(--vein); color: var(--on-vein); }
.btn.secondary { background: var(--mist); border-color: var(--mist); color: var(--vein); }
.btn.ghost { color: var(--vein); border-color: var(--vein); background: transparent; }
.btn.danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.btn.small { min-height: 34px; padding: 6px 14px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1 1 auto; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: 600 .8rem var(--body); cursor: pointer; color: var(--ink-2); display: grid; justify-items: center; line-height: 1.15; min-width: 52px; }
.chip small { font-weight: 500; font-size: .7rem; }
.chip[aria-pressed="true"] { background: var(--vein); border-color: var(--vein); color: var(--on-vein); }

.hatch { height: 10px; border-radius: 6px; background: repeating-linear-gradient(-45deg, var(--sky) 0 1.5px, transparent 1.5px 6px); }
.progress { height: 12px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--vein); }
.note { background: var(--mist); border-radius: 12px; padding: 12px 14px; font-size: .88rem; color: var(--ink); }

/* формы */
form.stack, .stack { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field > span, .field legend { font: 600 .68rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); padding: 0; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 1rem; }
.field textarea { min-height: 70px; resize: vertical; }
.field small { color: var(--ink-2); font-size: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--vein); flex: none; }
.check.done span { text-decoration: line-through; color: var(--ink-2); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg label { flex: 1; text-align: center; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 6px; font: 600 .84rem var(--body); color: var(--ink-2); }
.seg input:checked + span { background: var(--vein); color: var(--on-vein); }
.seg input:focus-visible + span { outline: 3px solid var(--vein); outline-offset: -3px; }
.error { color: var(--crit); font-size: .88rem; min-height: 1.2em; }
details.consent { font-size: .84rem; color: var(--ink-2); }
details.consent summary { cursor: pointer; color: var(--vein); }

/* вход */
.auth { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: calc(28px + env(safe-area-inset-top)) 20px 32px; isolation: isolate; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--vein); }
.brand b { font: 700 1.35rem/1 var(--display); letter-spacing: .06em; }
.brand small { display: block; font: 500 .6rem var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); margin-top: 5px; }
.welcome { position: relative; background: var(--surface); border-radius: 14px; padding: 22px 20px; box-shadow: var(--shadow); display: grid; gap: 14px; margin-right: 10px; }
.welcome::before { content: ""; position: absolute; inset: 10px -10px -10px 10px; z-index: -1; border-radius: 14px; background: repeating-linear-gradient(-45deg, var(--sky) 0 1.5px, transparent 1.5px 6px); }
.welcome h2 { margin: 0; font: 600 1.2rem/1.3 var(--display); letter-spacing: .07em; text-transform: uppercase; }
.welcome h2 em { font-style: normal; color: var(--vein); }

/* график */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-2); font: 10px var(--body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .limit { stroke: var(--crit); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.chart .s1 { stroke: var(--artery); fill: none; stroke-width: 2; }
.chart .s2 { stroke: var(--vein); fill: none; stroke-width: 2; }
.chart .d1 { fill: var(--artery); } .chart .d2 { fill: var(--vein); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* всплывающая панель */
dialog#sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px; max-height: 92dvh; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
dialog#sheet::backdrop { background: rgba(10,22,27,.45); }
.sheet { padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.sheet header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet h2 { margin: 0; font: 600 .95rem var(--display); letter-spacing: .12em; text-transform: uppercase; }
.sheet .close { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--mist); color: var(--vein); font-size: 1.3rem; cursor: pointer; }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--plasma); padding: 10px 16px; border-radius: 999px; font-size: .9rem; max-width: calc(100% - 32px); z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.err { background: var(--crit); color: #fff; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

.code { font: 700 1.6rem var(--mono); letter-spacing: .18em; text-align: center; padding: 14px; border-radius: 12px; background: var(--mist); color: var(--vein); user-select: all; }

/* помощник */
.chatlog { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--vein); color: var(--on-vein); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--ink-2); font-style: italic; }
.action { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--mist); display: grid; gap: 8px; font-size: .9rem; }
.action.done { background: var(--ok-bg); color: var(--ok); }
.action.failed { background: var(--crit-bg); color: var(--crit); }
.action.cancelled { background: var(--tint); color: var(--ink-2); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest .chip { min-width: 0; text-align: left; font-weight: 500; display: block; white-space: normal; }
.chatbar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; background: var(--plasma); padding: 8px 0; }
.chatbar textarea { flex: 1; min-height: 46px; max-height: 140px; border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px; background: var(--surface); resize: none; }
.chatbar .btn { width: 46px; height: 46px; min-height: 46px; padding: 0; font-size: 1.25rem; flex: none; }
.muted.small { font-size: .8rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--vein); text-decoration: underline; cursor: pointer; font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* администрирование */
.item.link { color: inherit; text-decoration: none; }
.item.link:hover b { color: var(--vein); }
.item .kv { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
details.adm { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
details.adm summary { cursor: pointer; font-weight: 600; }
details.adm .list { margin-top: 8px; }
