/* s3aguard — конструктор: плоская нейтральная система в стиле shadcn/ui (zinc).
   Тема: html[data-theme] = dark (по умолчанию) | light. Токены сверены с Franken UI (MIT). */
:root {
  --bg: hsl(240 10% 3.9%);
  --panel: hsl(240 6% 7%);
  --panel2: hsl(240 6% 6%);
  --card: hsl(240 6% 7%);
  --border: hsl(240 3.7% 15.9%);
  --border-strong: hsl(240 4% 24%);
  --hover: hsl(240 4% 12%);
  --fg: hsl(0 0% 98%);
  --muted: hsl(240 5% 64.9%);
  --accent: hsl(234 89% 68%);
  --accent2: hsl(263 80% 68%);
  --ok: hsl(158 64% 52%);
  --err: hsl(0 72% 60%);
  --warn: hsl(38 92% 58%);
  --node: hsl(240 6% 9%);
  --ring: hsl(234 89% 68% / .4);
  --radius: 10px;
  --radius-sm: 8px;
}
html[data-theme="light"] {
  --bg: hsl(240 6% 97%);
  --panel: hsl(0 0% 100%);
  --panel2: hsl(240 5% 99%);
  --card: hsl(0 0% 100%);
  --border: hsl(240 5.9% 90%);
  --border-strong: hsl(240 5% 78%);
  --hover: hsl(240 4.8% 96%);
  --fg: hsl(240 10% 3.9%);
  --muted: hsl(240 3.8% 46.1%);
  --accent: hsl(234 89% 56%);
  --accent2: hsl(263 70% 58%);
  --ok: hsl(158 64% 38%);
  --err: hsl(0 72% 48%);
  --warn: hsl(32 95% 38%);
  --node: hsl(0 0% 100%);
  --ring: hsl(234 89% 56% / .28);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Montserrat", system-ui, sans-serif; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* topbar */
.f-top { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--panel2); }
.f-brand { font-weight: 800; font-size: 17px; }
.f-sub { color: var(--muted); font-weight: 600; font-size: 13px; }
.f-actions { display: flex; align-items: center; gap: 12px; }
.f-user { color: var(--muted); font-size: 13px; }
.f-back { color: var(--accent); text-decoration: none; font-size: 14px; }
.theme-toggle { background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 8px; cursor: pointer; width: 32px; height: 32px; }

.f-gate { display: flex; flex-direction: column; gap: 10px; align-items: center;
  margin-top: 18vh; color: var(--fg); }

.f-app { display: flex; height: calc(100vh - 53px); }
.f-side { width: 250px; border-right: 1px solid var(--border); padding: 10px;
  overflow-y: auto; background: var(--panel2); }
.f-side-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-weight: 700; }
.f-list { display: flex; flex-direction: column; gap: 6px; }
.f-flow { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel); cursor: pointer; }
.f-flow.active { border-color: var(--accent); }
.f-flow b { font-size: 13px; }
.f-flow .fv { display: flex; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.tag { padding: 1px 6px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.tag.pub { background: rgba(53,208,160,.18); color: var(--ok); }
.tag.draft { background: rgba(255,255,255,.08); color: var(--muted); }
.tag.rob { background: rgba(109,141,255,.18); color: var(--accent); }

.f-main { flex: 1; position: relative; }
.f-empty { margin: 14vh auto; width: 420px; text-align: center; color: var(--muted); }
.f-editor { display: flex; flex-direction: column; height: 100%; }
.f-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.f-name { flex: 1; min-width: 200px; background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 14px; }
.f-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.f-tools { display: flex; gap: 6px; }
.f-btn { background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.f-btn:hover { border-color: var(--accent); }
.f-btn.accent { background: linear-gradient(90deg,var(--accent),var(--accent2)); color:#fff; border:none; }
.f-btn.danger { background:none; color: var(--err); border-color: rgba(255,93,108,.4); }
.f-btn.sm { padding: 4px 8px; font-size: 11px; }

.f-workspace { display: flex; flex: 1; min-height: 0; position: relative; }
/* сворачиваемые колонки палитры/свойств */
.f-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--panel2); transition: width .18s ease; }
.f-pal-col { width: 210px; border-right: 1px solid var(--border); }
.f-props-col { width: 300px; border-left: 1px solid var(--border); }
.f-col.closed { width: 0; border: none; }
.f-col.closed .f-panel-head { visibility: hidden; }
.f-panel-head { flex: none; display: flex; justify-content: space-between; align-items: center;
  gap: 6px; padding: 6px 10px; font-size: 12px; font-weight: 700;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.f-col-btn { background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 6px; cursor: pointer; width: 22px; height: 22px; font-size: 11px; flex: none; }
.f-col-btn:hover { background: var(--panel); }
.f-col-open { position: absolute; top: 50%; transform: translateY(-50%); width: 20px; height: 56px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--accent);
  border-radius: 8px; cursor: pointer; font-size: 13px; padding: 0; z-index: 5; }
.f-col-open.left { left: 3px; }
.f-col-open.right { right: 3px; }
.f-col-open:hover { background: var(--panel); }
.f-palette { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }
.f-palette h4 { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.pal-item { cursor: grab; padding: 5px 8px; margin-bottom: 3px; border-radius: 6px;
  font-size: 12px; border: 1px solid transparent; }
.pal-item:hover { border-color: var(--border); background: var(--panel); }
.pal-item .cat { color: var(--muted); }
.pal-item .pal-ic { display: inline-block; width: 18px; margin-right: 2px; text-align: center; }

/* поле «Инструмент» (тикер): живой поиск + пометка типа (Акция/Фьючерс/…) */
.tk-field { position: relative; width: 100%; }
.tk-field input { width: 100%; }
.f-ip .tk-field { flex: 1; min-width: 0; }
.tk-res { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 40;
  max-height: 190px; overflow: auto; background: var(--node); border: 1px solid var(--border);
  border-radius: 8px; margin-top: 2px; }
.tk-res.open { display: block; }
.tk-res .ticker-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  cursor: pointer; font-size: 12px; }
.tk-res .ticker-row:hover { background: var(--panel); }
.tk-res .tk-none { padding: 6px 8px; font-size: 11px; color: var(--muted); }
.tk-badge { font-size: 10px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tk-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* атрибуция библиотеки графиков (Apache-2.0) + контейнеры графиков */
/* атрибуция библиотеки графиков: всегда по центру низа */
.attrib { display: block; width: 100%; text-align: center; margin: 0 auto;
  padding: 8px 14px 14px; font-size: 11px; }
.lwc { width: 100%; height: 100%; }
.pal-item.pal-info { color: var(--accent2); font-style: italic; }
.pal-item.pal-info::after { content: " ●"; font-style: normal; font-size: 9px; vertical-align: 1px; opacity: .7; }

.f-canvas { position: relative; flex: 1; overflow: hidden; background:
  radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px) 0 0/22px 22px, var(--bg); }
html[data-theme="light"] .f-canvas { background:
  radial-gradient(rgba(0,0,20,.10) 1px, transparent 1px) 0 0/22px 22px, var(--bg); }
.f-canvas-hint { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none; text-align:center;
  max-width: 90%; z-index: 60; }
/* единый трансформируемый мир: и провода, и ноды в нём — зум/сдвиг не разъезжаются */
#f-view { position: absolute; left: 0; top: 0; width: 0; height: 0;
  transform-origin: 0 0; will-change: transform; }
.f-nodes { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; z-index: 3; }
.f-node { position: absolute; width: 172px; background: var(--node);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  cursor: grab; user-select: none; }
.f-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(109,141,255,.35); }
.f-node.dragging { z-index: 80; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.f-node .nh { font-size: 12px; font-weight: 700; margin-bottom: 6px; display:flex; justify-content:space-between; gap:6px; padding-right: 20px; }
.f-node .nh .ntype { color: var(--muted); font-weight: 500; font-size: 10px; }
.f-node-x { position: absolute; top: 4px; right: 4px; width: 17px; height: 17px; line-height: 1;
  border: none; border-radius: 6px; background: var(--panel2); color: var(--muted); cursor: pointer;
  font-size: 10px; opacity: 0; transition: opacity .12s, background .12s, color .12s; z-index: 3; }
.f-node:hover .f-node-x, .f-node.selected .f-node-x { opacity: .9; }
.f-node-x:hover { background: var(--err); color: #fff; }
.f-node.display { width: 250px; }
.f-ports { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); }
.ports-row { display: flex; justify-content: space-between; gap: 6px; }
.ports-col { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); min-width: 40px; }
.ports-col.right { align-items: flex-end; }
.port { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.port.out { justify-content: flex-end; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent2);
  border: 2px solid var(--node); cursor: crosshair; flex: none; transition: transform .1s, box-shadow .1s; }
.dot:hover { transform: scale(1.4); }
.dot.out.active { background: #fff; box-shadow: 0 0 0 3px var(--accent2); transform: scale(1.4); }
.dot.in.target { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,208,160,.5); transform: scale(1.3); }
.f-status-hot { color: var(--accent); font-weight: 700; }
.f-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 2; }
.f-wires path { stroke: var(--accent); stroke-width: 2; fill: none; opacity:.85;
  pointer-events: stroke; }
.f-wires path.f-temp { stroke: var(--ok); stroke-dasharray: 6 4; stroke-width: 2.2; }
.f-wires path.hot { stroke: var(--err); stroke-width: 2.6; }
.f-wires path:hover { stroke: var(--err); cursor: pointer; pointer-events: stroke; }
/* кнопка удаления линии (на середине; видна при наведении на линию/кнопку) */
.f-wires .f-edge-x { pointer-events: all; cursor: pointer; opacity: 0; transition: opacity .12s; }
.f-wires .f-edge-x.show { opacity: 1; }
.f-wires .f-edge-x circle { fill: var(--panel2); stroke: var(--border); stroke-width: 1.5; }
.f-wires .f-edge-x path.glyph { stroke: var(--err); stroke-width: 1.8; fill: none; }
.f-wires .f-edge-x:hover circle { fill: var(--err); }
.f-wires .f-edge-x:hover path.glyph { stroke: #fff; }
/* ---- зум-контролы и миникарта ---- */
.f-zoomctl { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 4px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; z-index: 70; }
.f-zoom-btn { width: 24px; height: 24px; border: none; background: var(--panel); color: var(--fg);
  border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; }
.f-zoom-btn:hover { background: rgba(109,141,255,.2); }
.f-zoom-label { font-size: 11px; color: var(--muted); padding: 0 6px; min-width: 40px; text-align: center; }
.f-minimap-wrap { position: absolute; right: 8px; bottom: 26px; width: 170px; height: 115px;
  border: 1px solid var(--border); border-radius: 8px; background: rgba(11,14,22,.6); z-index: 70;
  cursor: crosshair; overflow: hidden; }
html[data-theme="light"] .f-minimap-wrap { background: rgba(242,244,251,.85); }
.f-minimap-wrap canvas { width: 170px; height: 115px; display: block; }
.f-minimap-cap { position: absolute; left: 4px; bottom: 2px; font-size: 8px; color: var(--muted);
  pointer-events: none; text-shadow: 0 0 3px var(--bg); }
/* ---- живой стакан в display-ноде ---- */
.book-live { font-size: 10px; font-family: ui-monospace, Consolas, monospace; margin-top: 4px;
  display: flex; flex-direction: column; max-height: 360px; }
.book-live .bk-empty { color: var(--muted); padding: 4px 2px; font-family: "Montserrat", system-ui, sans-serif; }
.book-live .bk-mid { display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 3px 2px; margin: 2px 0; font-size: 12px; font-weight: 700; }
.book-live .bk-mid .bb { color: var(--ok); }
.book-live .bk-mid .ba { color: var(--err); }
.book-live .bk-mid .bspread { color: var(--muted); font-weight: 500; font-size: 9px; }
.book-live .bk-side { display: flex; flex-direction: column; gap: 1px; }
.book-live .bk-row { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 4px; }
.book-live .bk-row.ask { grid-template-columns: 1fr 42px; }
.book-live .bk-row .bk-p { text-align: right; }
.book-live .bk-row.ask .bk-p { text-align: left; }
.book-live .bk-bar-wrap { position: relative; height: 9px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.book-live .bk-row.bid .bk-bar { position:absolute; right:0; top:0; bottom:0; background: rgba(53,208,160,.35); }
.book-live .bk-row.ask .bk-bar { position:absolute; left:0; top:0; bottom:0; background: rgba(255,93,108,.35); }
.book-live .bk-row .bk-q { position: absolute; top:0; height:9px; font-size:8px; line-height:9px;
  color: var(--fg); padding: 0 2px; white-space: nowrap; }
.book-live .bk-row.bid .bk-q { right: 2px; }
.book-live .bk-row.ask .bk-q { left: 2px; }
.f-help { font-size: 12px; line-height: 1.45; color: var(--fg); background: var(--panel);
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 7px;
  padding: 8px; margin-bottom: 10px; }
.f-help .h { font-weight: 700; display: block; margin-bottom: 3px; }
.f-help .p { display:block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.f-help code { background: var(--panel2); padding: 0 3px; border-radius: 4px; font-size: 11px; }

.f-props { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.f-props-empty { color: var(--muted); font-size: 13px; }
.f-props-title { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-weight: 700; }
.f-props label { display:block; margin-bottom: 8px; font-size: 12px; color: var(--fg); }
.f-props input:not([type="checkbox"]):not([type="radio"]), .f-props select { width: 100%; margin-top: 3px; background-color: var(--panel);
  color: var(--fg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }

.f-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 40; }
.f-modal-card { width: 380px; background: var(--node); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; }
.f-modal-card h3 { margin-top: 0; }
.f-modal-card label { display: block; margin-bottom: 10px; font-size: 13px; }
.f-input { width: 100%; background-color: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; margin-top: 3px; }
.f-modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.f-muted-in { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 3px; }

/* инлайн-редактирование параметров прямо в ноде (1-2 поля) */
.f-inline-p { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border); }
.f-ip { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.f-ip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.f-ip input:not([type="checkbox"]):not([type="radio"]), .f-ip select { background-color: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 5px; font-size: 11px; min-width: 0; width: 100%; }
/* числовое поле — компактное, но СЖИМАЕМОЕ (flex: none + width: 100% = выезд за ноду).
   :not(...) — чтобы перебить специфичность общего правила выше */
.f-ip input[type="number"]:not([type="checkbox"]):not([type="radio"]) { flex: 0 1 78px; min-width: 46px; width: auto; }
.f-node.display { padding-bottom: 8px; }

/* попап-поиск ноды при отпускании перетаскиваемой линии */
.f-connect-menu { position: absolute; z-index: 90; width: 280px; max-height: 300px;
  display: flex; flex-direction: column; background: var(--node); border: 1px solid var(--accent);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); overflow: hidden; }
.f-connect-menu .fcm-inp { border: none; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--fg); padding: 8px 10px; font-size: 13px; outline: none; }
.f-connect-menu .fcm-from { padding: 4px 10px; font-size: 10px; border-bottom: 1px solid var(--border); }
.f-connect-menu .fcm-list { overflow-y: auto; }
.f-connect-menu .fcm-item { padding: 6px 10px; font-size: 12px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; }
.f-connect-menu .fcm-item .lbl { font-weight: 600; }
.f-connect-menu .fcm-item .typ { color: var(--muted); font-size: 10px; white-space: nowrap; }
.f-connect-menu .fcm-item:hover, .f-connect-menu .fcm-item.hl { background: rgba(109,141,255,.18); }
.f-connect-menu .fcm-sep { padding: 5px 10px 2px; font-size: 10px; color: var(--muted);
  border-top: 1px solid var(--border); margin-top: 2px; }
.f-connect-menu .fcm-item.add .lbl { color: var(--accent); }
.f-connect-menu .fcm-foot { font-size: 9px; color: var(--muted); padding: 4px 10px;
  border-top: 1px solid var(--border); }

/* ================= групповое выделение + имя ноды ================= */
.f-node { z-index: 2; }
/* заметки-фон — отдельный слой ПОД проводами и нодами (DOM-порядок в #f-view:
   #f-note-bg < svg#f-wires < #f-nodes), поэтому не перехватывают клики по нодам */
#f-note-bg { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; z-index: 1; }
.f-node.display.f-node-note { overflow: hidden; padding: 0; }
/* марки-область выделения (Shift+drag по пустой канве) */
.f-marquee { position: absolute; z-index: 120; pointer-events: none; border: 1px solid var(--accent);
  background: rgba(109,141,255,.14); border-radius: 3px; }
/* поле «Название ноды» в панели свойств */
.f-node-name-row { display: block; margin-bottom: 10px; }
.f-node-name-row .f-muted-in { white-space: normal; }

/* ================= нода-«Заметка» ================= */
.f-node-note { border-radius: 10px; padding: 0; box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: grab; }
.f-node-note .f-note-inner { position: absolute; inset: 0; padding: 10px 14px; overflow: auto; }
.f-node-note .f-note-title { font-size: 12px; font-weight: 800; margin-bottom: 4px; opacity: .9; }
.f-node-note .f-note-text { font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.f-node-note .f-note-text.empty { color: inherit; opacity: .6; }
/* ручка изменения размера в правом нижнем углу заметки */
.f-note-resize { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; padding: 0;
  border: none; background: transparent; color: inherit; opacity: .55; cursor: nwse-resize; font-size: 13px;
  line-height: 1; z-index: 4; }
.f-node-note:hover .f-note-resize, .f-node-note.selected .f-note-resize { opacity: 1; }
/* свойства заметки в правой панели */
.f-props textarea, .f-props textarea.f-note-ta { width: 100%; background-color: var(--panel); color: var(--fg);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; margin-top: 3px; resize: vertical;
  font-family: inherit; font-size: 12px; }
.f-note-sw { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.f-note-sw-btn { width: 34px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; font-size: 11px; font-weight: 700; background: var(--panel); color: var(--muted); }
.f-note-sw-btn:hover { border-color: var(--accent); }
.f-note-sw-btn.on { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.f-note-wh { display: flex; gap: 10px; }
.f-note-wh label { flex: 1; }

/* ================= виджеты терминала внутри display-нод конструктора =================
   Ноды «График», «Стакан», «Обезличенные сделки» + остальные виджеты раздела
   «Терминал» рисуются общим кодом (window.S3AW из terminal.js). */
.f-widget { display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.f-widget > .term-b { padding: 6px; }
.f-widget > .term-b.p0 { padding: 0; }
.f-widget .term-h { display: none; }   /* в ноде роль заголовка играет .nh */
/* ручка масштабирования ноды-виджета (правый нижний угол, как у заметки) */
.f-widget-rz { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 16px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel2); color: var(--muted);
  cursor: nwse-resize; font-size: 11px; line-height: 1; opacity: 0; transition: opacity .12s; z-index: 6; }
.f-node:hover .f-widget-rz, .f-node.selected .f-widget-rz { opacity: 1; }
.f-widget-rz:hover { background: var(--panel); color: var(--accent); }

/* ================= вертикальный стакан (нода «Стакан» в конструкторе) ================= */
.book-live .nb { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; min-height: 0; overflow-y: auto; }
.book-live .nb-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.book-live .nb-head { font-size: 10px; text-align: center; margin-bottom: 3px; opacity: .9; }
.book-live .nb-bids .nb-head { color: var(--ok); }
.book-live .nb-asks .nb-head { color: var(--err); }
.book-live .nb-lvl { position: relative; height: 19px; display: flex; align-items: center;
  gap: 4px; padding: 0 6px; border-radius: 4px; font-size: 11px; overflow: hidden;
  color: var(--fg); background: var(--panel); }
.book-live .nb-bar { position: absolute; top: 0; bottom: 0; opacity: .22; border-radius: 4px; }
.book-live .nb-bids .nb-bar { right: 0; background: var(--ok); }
.book-live .nb-asks .nb-bar { left: 0; background: var(--err); }
.book-live .nb-price, .book-live .nb-qty { position: relative; z-index: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.book-live .nb-bids .nb-price { margin-right: auto; }
.book-live .nb-asks .nb-qty { margin-right: auto; }
.book-live .nb-empty { color: var(--muted); font-size: 10px; text-align: center; padding: 2px 0; }
.book-live .nb-mid { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 4px 8px; font-size: 11px; padding: 5px 8px; margin-top: 6px; background: var(--panel);
  border-radius: 7px; color: var(--muted); }
.book-live .nb-mid .nb-bb { color: var(--ok); font-weight: 700; }
.book-live .nb-mid .nb-ba { color: var(--err); font-weight: 700; }
.book-live .nb-mid .nb-bimb { width: 100%; font-size: 10px; text-align: center; }

/* поиск в палитре «Ноды» */
.f-pal-search { width: 100%; padding: 6px 8px; margin-bottom: 6px; background: var(--panel);
  color: var(--fg); border: 1px solid var(--border); border-radius: 7px; font-size: 12px; outline: none; }
.f-pal-search::placeholder { color: var(--muted); }
.f-pal-groups { display: flex; flex-direction: column; }
.f-pal-none { padding: 6px 2px; font-size: 12px; }

/* ручка растягивания высоты ноды-стакана (низ-справа) */
.f-bk-resize { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 14px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel2); color: var(--muted);
  cursor: ns-resize; font-size: 10px; line-height: 1; opacity: 0; transition: opacity .12s; z-index: 4; }
.f-node:hover .f-bk-resize, .f-node.selected .f-bk-resize { opacity: 1; }
.f-bk-resize:hover { background: var(--panel); color: var(--accent); }

/* нода «График (свечи)» */
.chart-live { height: 210px; overflow: hidden; margin-top: 4px; }
.chart-live svg { display: block; width: 100%; height: 100%; }
.f-chart-intv { background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; font-size: 10px; padding: 1px 4px; margin-left: auto; }
.chart-live .bk-empty { color: var(--muted); padding: 6px 2px; font-family: "Montserrat", system-ui, sans-serif; font-size: 11px; }
/* ручка масштаба графика (низ-справа: тянуть угол) */
.f-chart-resize { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 16px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel2); color: var(--muted);
  cursor: nwse-resize; font-size: 11px; line-height: 1; opacity: 0; transition: opacity .12s; z-index: 4; }
.f-node:hover .f-chart-resize, .f-node.selected .f-chart-resize { opacity: 1; }
.f-chart-resize:hover { background: var(--panel); color: var(--accent); }





/* ============================================================================
   РЕСКИН 2026-09 — плоская нейтральная система (shadcn/ui). Имена классов
   сохранены, JS/HTML не менялись: только внешний вид.
   ========================================================================== */

.f-top { background: var(--panel); border-bottom: 1px solid var(--border); }
.f-brand { font-weight: 700; letter-spacing: -0.01em; }
.f-back { font-weight: 500; }
.theme-toggle { border-radius: var(--radius-sm); background: var(--panel); }
.theme-toggle:hover { border-color: var(--border-strong); }

/* кнопки */
.f-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background .14s, border-color .14s;
}
.f-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.f-btn.accent { background: hsl(0 0% 98%); color: hsl(240 6% 10%); border: 1px solid transparent; }
.f-btn.accent:hover { background: hsl(0 0% 90%); }
html[data-theme="light"] .f-btn.accent { background: hsl(240 5.9% 10%); color: hsl(0 0% 98%); }
html[data-theme="light"] .f-btn.accent:hover { background: hsl(240 5.9% 18%); }
.f-btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent);
  background: color-mix(in srgb, var(--err) 9%, transparent); }
.f-col-btn { border-radius: var(--radius-sm); background: var(--card); }
.f-col-btn:hover { background: var(--hover); }
.f-col-open { border-radius: var(--radius-sm); background: var(--card); color: var(--accent); }

/* колонки и палитра */
.f-col { background: var(--panel2); }
.f-panel-head { font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pal-item { border-radius: var(--radius-sm); padding: 6px 8px; }
.pal-item:hover { border-color: var(--border-strong); background: var(--hover); }

/* лист флоу */
.f-flow { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.f-flow:hover { border-color: var(--border-strong); background: var(--hover); }
.f-flow.active { border-color: var(--accent); background: var(--hover); }

/* нода на канве */
.f-node {
  background: var(--node);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(0 0% 0% / .35);
}
.f-node:hover { border-color: var(--border-strong); }
.f-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.f-node.dragging { box-shadow: 0 12px 32px hsl(0 0% 0% / .45); }
.f-node .nh { font-size: 12px; font-weight: 650; letter-spacing: -0.01em; }
.f-node-x { border-radius: 6px; background: var(--panel2); }
.f-node-x:hover { background: var(--err); color: #fff; }
.dot { border-color: var(--node); }

/* меню соединения / поиск */
.f-connect-menu { background: var(--node); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 16px 40px hsl(0 0% 0% / .5); }
.f-connect-menu .fcm-item:hover { background: var(--hover); }
.tk-res { background: var(--node); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 12px 32px hsl(0 0% 0% / .45); }

/* свойства ноды */
.f-props input:not([type="checkbox"]):not([type="radio"]), .f-props select, .f-modal input:not([type="checkbox"]):not([type="radio"]), .f-modal select, .f-input {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.f-props input:focus, .f-props select:focus, .f-modal input:focus, .f-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}
.f-modal-card { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 24px 60px hsl(0 0% 0% / .55); }
