/* Пульт AHU. Светлая «машинная» страница и один тёмный приборный блок — схема установки.
   Цвет воздуха: свежий (наружный и приток) — холодный, удаляемый (вытяжка и выброс) — тёплый. */
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(/fonts/golos-text-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(/fonts/golos-text-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url(/fonts/golos-text-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url(/fonts/golos-text-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }

:root {
  --bg: #ECEEEA;
  --rail: #E2E5E0;
  --sheet: #F7F8F5;
  --ink: #1A1E1C;
  --muted: #5F6964;
  --rule: #CFD5CF;
  --rule-soft: #DDE2DC;
  --fresh: #1F7F93;
  --stale: #B4602A;
  --ok: #2F7A4C;
  --warn: #9A6A00;
  --bad: #B23A2A;
  /* приборный блок одинаков в обеих темах */
  --deck: #1B211F;
  --deck-line: #2D3632;
  --deck-ink: #EEF2EF;
  --deck-muted: #93A09A;
  --deck-fresh: #62C6D8;
  --deck-stale: #EDA45E;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412; --rail: #151A18; --sheet: #171C1A; --ink: #E4E9E6; --muted: #8E9A94;
    --rule: #2A332F; --rule-soft: #212926; --fresh: #62C6D8; --stale: #EDA45E;
    --ok: #63C28A; --warn: #E2B04A; --bad: #EF7D6D; --deck: #1D2421; --deck-line: #34403B;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); font-feature-settings: "tnum"; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
.muted { color: var(--muted); }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.86em; }
:focus-visible { outline: 2px solid var(--fresh); outline-offset: 2px; }

/* ---------- элементы управления */
.btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 6px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--rule); background: transparent; color: var(--ink); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.quiet { border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .45; cursor: default; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input, select { width: 100%; font: inherit; color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; }
input:disabled, select:disabled { opacity: .6; }
.check { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.error { color: var(--bad); margin: 0 0 12px; }
.ok-text { color: var(--ok); }

/* ---------- вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-form { width: min(340px, 100%); }
.login-mark { width: 44px; height: 44px; }
.login h1 { font-size: 32px; margin: 22px 0 4px; }
.login p.muted { margin: 0 0 28px; }
svg path.f { stroke: var(--fresh); stroke-width: 9; stroke-linecap: round; }
svg path.s { stroke: var(--stale); stroke-width: 9; stroke-linecap: round; }

/* ---------- каркас: рейка слева и рабочее поле */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); border-right: 1px solid var(--rule); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; text-decoration: none; letter-spacing: .04em; padding: 0 6px; }
.wordmark svg { width: 22px; height: 22px; }
.rail-toggle { display: none; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.rail-nav > a { text-decoration: none; padding: 7px 8px; border-radius: 6px; font-weight: 600; font-size: 14px; }
.rail-nav > a[aria-current="page"] { background: var(--sheet); }
.rail-units { display: flex; flex-direction: column; margin: 2px 0 14px; }
.rail-unit { display: grid; grid-template-columns: 3px 1fr auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 6px; text-decoration: none; font-size: 14px; }
.rail-unit[aria-current="page"] { background: var(--sheet); }
.rail-unit .bar { width: 3px; height: 22px; border-radius: 2px; background: var(--rule); }
.rail-unit .t { color: var(--muted); font-size: 13px; }
.rail-unit span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
i.bar.ok { background: var(--ok); } i.bar.warn { background: var(--warn); } i.bar.bad { background: var(--bad); } i.bar.off { background: var(--muted); }
.rail-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--rule); padding-top: 12px; }
.link-state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.link-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); }
.link-state.on i { background: var(--ok); } .link-state.off i { background: var(--bad); }
.view { padding: 28px 36px 64px; max-width: 1180px; width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; height: auto; z-index: 10; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .wordmark { margin-right: auto; }
  .rail-toggle { display: grid; gap: 5px; place-content: center; width: 38px; height: 34px; border: 1px solid var(--rule); border-radius: 6px; background: transparent; cursor: pointer; }
  .rail-toggle span { display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 1px; }
  .rail-nav, .rail-foot { display: none; width: 100%; }
  .rail.open .rail-nav, .rail.open .rail-foot { display: flex; }
  .view { padding: 20px 16px 48px; }
}

/* ---------- заголовки страниц */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 22px; }
.page-head h1 { font-size: 30px; line-height: 1.1; margin-right: auto; }
.page-head .sub { width: 100%; margin-top: -8px; color: var(--muted); }
.state-word { font-weight: 600; }
.state-word.ok { color: var(--ok); } .state-word.warn { color: var(--warn); } .state-word.bad { color: var(--bad); }

/* ---------- список установок: ведомость, а не карточки */
.ledger { border-top: 1px solid var(--ink); }
.ledger-row { display: grid; grid-template-columns: 3px minmax(0, 2.2fr) minmax(0, 1.3fr) 90px 90px minmax(0, 1fr); gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--rule); text-decoration: none; }
.ledger-row:hover { background: var(--sheet); }
.ledger-row .bar { width: 3px; height: 34px; border-radius: 2px; background: var(--rule); }
.ledger-row .name { font-weight: 600; font-size: 16px; }
.ledger-row .id { color: var(--muted); font-size: 12.5px; }
.ledger-row .num { font-size: 20px; font-weight: 600; }
.ledger-row .num small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.ledger-head { font-size: 12.5px; color: var(--muted); padding-block: 8px; border-bottom: 1px solid var(--rule); }
.ledger-head:hover { background: none; }
@media (max-width: 860px) {
  .ledger-row { grid-template-columns: 3px 1fr auto; }
  .ledger-row > :nth-child(n+4) { display: none; }
  .ledger-head { display: none; }
}
.empty { padding: 48px 0; max-width: 460px; }
.empty p { margin: 0 0 18px; }

/* ---------- приборный блок: схема установки */
.deck { background: var(--deck); color: var(--deck-ink); border-radius: 14px; overflow: hidden; }
.deck svg { display: block; width: 100%; height: auto; }
.deck .lbl { fill: var(--deck-muted); font-size: 13px; }
.deck .val { fill: var(--deck-ink); font-size: 30px; font-weight: 600; }
.deck .val.f { fill: var(--deck-fresh); } .deck .val.s { fill: var(--deck-stale); }
.deck .duct-f { stroke: var(--deck-fresh); } .deck .duct-s { stroke: var(--deck-stale); }
.deck .core { fill: none; stroke: var(--deck-line); stroke-width: 1.5; }
.deck .flow { stroke-dasharray: 10 12; animation: flow 1.6s linear infinite; }
.deck .flow.slow { animation-duration: 3.2s; }
@keyframes flow { to { stroke-dashoffset: -22; } }
.deck .stopped { stroke-dasharray: 3 6; opacity: .55; }
.deck-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; padding: 16px 22px; border-top: 1px solid var(--deck-line); }
.deck-bar .readout { display: flex; gap: 22px; flex-wrap: wrap; margin-right: auto; font-size: 13px; color: var(--deck-muted); }
.deck-bar .readout b { display: block; color: var(--deck-ink); font-size: 17px; font-weight: 600; }
.power { display: flex; align-items: center; gap: 12px; }
.power .what { text-align: right; font-size: 13px; color: var(--deck-muted); }
.power .what b { display: block; color: var(--deck-ink); font-size: 15px; }
.switch { position: relative; width: 66px; height: 36px; border-radius: 18px; border: 0; padding: 0; cursor: pointer; background: var(--deck-line); flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: var(--deck-ink); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--deck-fresh); }
.switch[aria-checked="true"]::after { transform: translateX(30px); background: var(--deck); }
.switch.pending::after { animation: blink .8s steps(2) infinite; }
.switch:disabled { opacity: .45; cursor: default; }
@keyframes blink { 50% { opacity: .35; } }
.offline-note { padding: 10px 22px; background: color-mix(in srgb, var(--bad) 22%, var(--deck)); color: var(--deck-ink); font-size: 14px; }

/* ---------- разделы под схемой */
.tabs { display: flex; gap: 22px; margin: 30px 0 18px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs button { font: inherit; font-size: 15px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 0 10px; color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 44px; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.block { margin-bottom: 30px; }
.block > h3 { font-size: 15px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 4px; }
.block > p.muted { font-size: 14px; margin: 8px 0 12px; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.alarm { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.alarm .code { font-weight: 600; }
.alarm.critical .code { color: var(--bad); } .alarm.warning .code { color: var(--warn); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }

.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--rule-soft); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.range { display: flex; gap: 4px; }
.range button { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 5px; border: 1px solid var(--rule); background: transparent; color: var(--muted); cursor: pointer; }
.range button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 112px 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.log .t { color: var(--muted); }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 4px; border: 1px solid var(--rule); color: var(--muted); align-self: start; white-space: nowrap; }
.tag.done, .tag.applied { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--rule)); }
.tag.failed, .tag.rejected, .tag.timeout, .tag.rolled_back { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }
.tag.critical { color: var(--bad); } .tag.warning { color: var(--warn); }
@media (max-width: 600px) { .log li { grid-template-columns: 1fr auto; } .log .t { grid-column: 1 / -1; font-size: 12.5px; } }

.progress { height: 6px; border-radius: 3px; background: var(--rule-soft); overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--fresh); transition: width .3s; }
.result { margin-top: 12px; overflow-x: auto; }
.result table { border-collapse: collapse; font-size: 13.5px; width: 100%; }
.result th, .result td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--rule-soft); }
.result th { color: var(--muted); font-weight: 400; }
.notice { padding: 10px 12px; border-left: 3px solid var(--warn); background: var(--sheet); font-size: 14px; margin: 0 0 14px; }
.notice.bad { border-left-color: var(--bad); } .notice.ok { border-left-color: var(--ok); }

/* ---------- диалоги и всплывающее сообщение */
dialog { border: 1px solid var(--rule); border-radius: 12px; padding: 0; background: var(--bg); color: var(--ink); width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(12, 16, 14, .5); }
.dlg { padding: 24px; }
.dlg h2 { font-size: 20px; margin-bottom: 6px; }
.dlg > p.muted { margin: 0 0 18px; font-size: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.creds { display: grid; grid-template-columns: auto 1fr auto; gap: 10px 12px; align-items: center; margin: 0 0 12px; font-size: 14px; }
.creds dt { color: var(--muted); }
.creds dd { margin: 0; overflow-wrap: anywhere; }
.copy { font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 5px; border: 1px solid var(--rule); background: transparent; color: var(--muted); cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 6px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
