@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format('woff2'); font-weight: 400; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format('woff2'); font-weight: 500; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format('woff2'); font-weight: 600; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: PlexMono; src: url(fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format('woff2'); font-weight: 400; unicode-range: U+0400-045F; font-display: swap; }
@font-face { font-family: PlexMono; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: PlexMono; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --paper: #f6f4ef;
  --panel: #fffefb;
  --ink: #1d232a;
  --ink-2: #4a5560;
  --ink-3: #7c8791;
  --rule: #e2ded4;
  --rule-2: #cfc9bc;
  --head: #c2410c;      /* напор / давление — тёплый */
  --head-soft: #fbe7dc;
  --ground: #8a7a5c;    /* грунт */
  --ground-fill: rgba(138, 122, 92, .16);
  --vel: #1e5f8c;       /* скорость */
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --warn-soft: #fdf3dc;
  --r: 6px;
  --mono: PlexMono, ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: Plex, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.num, .clock, input[type=number], .nodes td, .formula { font-variant-numeric: tabular-nums; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding: 10px 20px; background: var(--ink); color: #eef1f3;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 22px; height: 22px; border-radius: 4px; background:
  linear-gradient(135deg, transparent 46%, var(--head) 46%, var(--head) 58%, transparent 58%), #2c353e; }
.brand h1 { font-size: 15px; letter-spacing: .01em; }
.brand .sub { margin: 0; font-size: 12px; color: #9aa6b0; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.top .btn { background: #2c353e; border-color: #3a4651; color: #eef1f3; }
.top .btn:hover { background: #36414b; }
.top .btn.primary { background: var(--head); border-color: var(--head); color: #fff; }
.top .btn.primary:hover { background: #a6380b; }
.top .btn.ghost { background: transparent; border-color: #59646e; }
.speed { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #9aa6b0; }
.speed select { background: #2c353e; border: 1px solid #3a4651; border-radius: var(--r); padding: 5px 6px; color: #eef1f3; }
.clock { font-family: var(--mono); font-size: 18px; min-width: 110px; text-align: right; }
.clock small { font-size: 12px; color: #9aa6b0; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: transparent; }
#progressBar { height: 100%; width: 0; background: var(--head); transition: width .1s linear; }

.btn {
  border: 1px solid var(--rule-2); background: var(--panel); border-radius: var(--r);
  padding: 7px 12px; cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 13px;
}
.btn:hover { border-color: var(--ink-3); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .seg button:focus-visible, .tabs button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--head); outline-offset: 1px; }
.icon { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-3); padding: 2px 6px; border-radius: 4px; }
.icon:hover { color: var(--bad); background: var(--bad-soft); }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--rule); background: var(--panel); position: sticky; top: var(--top-h, 58px); z-index: 15; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--head); }
.mobile-only { display: none; }

/* ---------- раскладка ---------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; align-items: start; }
.side { padding: 16px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: calc(var(--top-h, 58px) + 41px); max-height: calc(100vh - var(--top-h, 58px) - 41px); overflow-y: auto; }
.main { padding: 16px 20px 40px; min-width: 0; }
.pane { display: none; }
body[data-tab=charts] .pane[data-pane=charts],
body[data-tab=table] .pane[data-pane=table],
body[data-tab=about] .pane[data-pane=about] { display: block; }

.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field span { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field span i { font-style: normal; color: var(--ink-3); }
input, select { border: 1px solid var(--rule-2); border-radius: 4px; background: #fff; padding: 5px 7px; min-width: 0; }
input[type=number] { font-family: var(--mono); font-size: 13px; width: 100%; }
.field input.bad { border-color: var(--bad); background: var(--bad-soft); }
.lbl { display: block; font-size: 12px; color: var(--ink-2); margin: 8px 0 4px; }
.lbl:first-of-type { margin-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r); overflow: hidden; width: 100%; }
.seg button { flex: 1; border: 0; background: #fff; padding: 6px 8px; cursor: pointer; font-size: 12px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--rule-2); }
.seg button.on { background: var(--ink); color: #fff; }
.hint { font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }
.hint.inline { margin: 0; }
.derived { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin: 8px 0 0; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row select { flex: 1; }
details.more { margin-top: 10px; }
details.more summary { cursor: pointer; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }

table.edit { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.edit th { font-size: 11px; font-weight: 500; color: var(--ink-3); text-align: left; padding: 2px 4px; }
table.edit td { padding: 2px 2px; }
table.edit input { width: 100%; font-family: var(--mono); font-size: 12px; padding: 3px 5px; }
.profile-scroll { max-height: 260px; overflow-y: auto; }

/* ---------- станции ---------- */
.station { border-top: 1px solid var(--rule); padding: 10px 0; }
.station:first-child { border-top: 0; padding-top: 0; }
.st-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.st-name { font-weight: 600; width: 90px; }
.st-x { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); }
.st-x input { width: 70px; }
.st-del { margin-left: auto; }
.pump { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 4px; margin-bottom: 5px; background: #fff; }
.pump.off { background: #f3f1ec; }
.pump .pname { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pump .pparams { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pump .pparams label { display: flex; flex-direction: column; font-size: 10px; color: var(--ink-3); }
.pump .pparams input { font-size: 11px; padding: 2px 4px; }
.st-add { margin-top: 4px; }
.add-station { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule-2); }
.add-station input { width: 80px; }
.add-station input#newStName { width: 90px; }

.toggle { position: relative; width: 34px; height: 20px; border-radius: 10px; border: 0; cursor: pointer; background: var(--rule-2); flex: none; transition: background .15s; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle.on { background: var(--ok); }
.toggle.on::after { left: 16px; }
.toggle.ramping { background: var(--warn); }

/* ---------- статус ---------- */
.banner { padding: 10px 14px; border-radius: var(--r); margin-bottom: 12px; background: var(--bad-soft); color: var(--bad); border: 1px solid #f3c1bb; }
.banner.info { background: var(--warn-soft); color: #7a4f0d; border-color: #f0dca8; }
.status { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 8px 12px; }
.kpi .k { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { font-family: var(--mono); font-size: 18px; font-weight: 500; }
.kpi .v small { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.kpi .d { font-size: 12px; color: var(--ink-2); }
.kpi.bad { border-color: #f3c1bb; background: var(--bad-soft); }
.kpi.bad .k, .kpi.bad .v { color: var(--bad); }
.kpi.warn { border-color: #f0dca8; background: var(--warn-soft); }
.kpi.warn .k, .kpi.warn .v { color: #8a5a10; }

.pumpbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pb-st { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 6px 10px; }
.pb-st b { font-size: 12px; margin-right: 2px; }
.pb-st .x { font-size: 11px; color: var(--ink-3); font-family: var(--mono); margin-right: 4px; }
.pb-st.lowh { border-color: #f0dca8; background: var(--warn-soft); }
.pb-st .hs { font-size: 11px; font-family: var(--mono); color: var(--ink-2); margin-left: 4px; }
.pb-st.lowh .hs { color: #8a5a10; font-weight: 500; }

.viewbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12px; color: var(--ink-2); }

/* ---------- графики ---------- */
.chart { margin: 0 0 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 10px 4px; }
.chart figcaption { font-size: 13px; font-weight: 600; padding: 0 4px 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.legend { font-weight: 400; font-size: 12px; color: var(--ink-2); display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 4px; }
.legend i.dash { border-top-style: dashed; }
.legend i.fill { height: 8px; border: 0; }
.plot { width: 100%; }
.uplot { font-family: Plex, system-ui, sans-serif; }
.u-legend { display: none; }
.u-select { background: rgba(194, 65, 12, .08); }
.pointpick { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; border: 1px solid var(--rule-2); background: #fff; border-radius: 12px; padding: 2px 9px 2px 7px; cursor: pointer; }
.chip .sw { width: 9px; height: 9px; border-radius: 50%; }
.chip.off { color: var(--ink-3); background: transparent; }
.chip.off .sw { opacity: .25; }
.chip .rm { color: var(--ink-3); margin-left: 2px; }
.addpt { padding: 6px 4px 6px; }
.addpt input { width: 90px; }

.steady-card table { border-collapse: collapse; font-size: 12px; width: 100%; }
.steady-card td, .steady-card th { padding: 3px 8px 3px 0; text-align: left; border-bottom: 1px solid var(--rule); }
.steady-card th { font-weight: 500; color: var(--ink-3); text-align: right; white-space: nowrap; }
.steady-card th:first-child { text-align: left; }
.steady-card td.n { font-family: var(--mono); text-align: right; }
.steady-card .facts { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; margin-bottom: 10px; }
.steady-card .facts b { font-family: var(--mono); font-weight: 500; }
.steady-card .log { font-family: var(--mono); font-size: 11px; color: var(--ink-3); max-height: 120px; overflow: auto; margin-top: 6px; white-space: pre; }

/* ---------- таблица ---------- */
.tablewrap { overflow: auto; max-height: calc(100vh - 200px); border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); margin-top: 10px; }
table.nodes { border-collapse: collapse; width: 100%; font-size: 12px; }
table.nodes th { position: sticky; top: 0; background: var(--panel); text-align: right; font-weight: 500; color: var(--ink-2); padding: 6px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
table.nodes td { font-family: var(--mono); text-align: right; padding: 3px 10px; border-bottom: 1px solid var(--rule); }
table.nodes td:first-child, table.nodes th:first-child { text-align: left; }
table.nodes tr.st td { background: #f3f1ec; font-weight: 500; }
table.nodes td.bad { color: var(--bad); background: var(--bad-soft); }
table.nodes td.warn { color: #8a5a10; background: var(--warn-soft); }

/* ---------- о модели ---------- */
.about { max-width: 760px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px 22px; }
.about h2 { font-size: 18px; margin-bottom: 8px; }
.about h3 { font-size: 14px; margin: 18px 0 6px; }
.about p, .about li { color: var(--ink-2); }
.about .formula { font-family: var(--mono); font-size: 12px; background: #f3f1ec; padding: 8px 10px; border-radius: 4px; color: var(--ink); overflow-x: auto; white-space: nowrap; }
#selfTests li.ok::marker { content: '✓  '; color: var(--ok); }
#selfTests li.fail::marker { content: '✗  '; color: var(--bad); }

/* ---------- мобильная ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; position: static; max-height: none; border-right: 0; padding: 12px; }
  body[data-tab=params] .side { display: flex; }
  body[data-tab=params] .main { display: none; }
  .mobile-only { display: block; }
  .top { padding: 8px 12px; gap: 8px; }
  .brand .sub { display: none; }
  .transport { margin-left: 0; width: 100%; gap: 6px; }
  .transport .btn { padding: 6px 9px; font-size: 12px; }
  .clock { font-size: 15px; min-width: 0; margin-left: auto; }
  .speed { font-size: 0; gap: 0; }
  .speed select { font-size: 12px; }
  .tabs button { padding: 10px 10px; font-size: 13px; }
  .tabs { padding: 0 8px; }
  .main { padding: 10px; }
  .status { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- свёрнутые настройки ---------- */
details.extra > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; }
details.extra > summary::-webkit-details-marker { display: none; }
details.extra > summary::before { content: "▸"; font-size: 11px; color: var(--ink-3); transition: transform .15s; display: inline-block; }
details.extra[open] > summary::before { transform: rotate(90deg); }
details.extra > summary h2 { margin-bottom: 0; }
details.extra[open] > summary { margin-bottom: 4px; }
.sub-h { font-size: 12px; font-weight: 600; color: var(--ink); margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.extra-foot { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); }
details.eqs { margin: 4px 0 8px; }
details.eqs summary { font-size: 14px; }
