/* ---------- Конструктор формулы (formula.js) ---------- */
.modal-card.fx-card { text-align: left; padding: 0; width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.fx-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.fx-head h3 { margin: 0; font-size: 19px; }
.fx-lead { margin: 0; padding: 0 20px 12px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.fx-body { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.fx-body > * { flex-shrink: 0; }
.fx-sides { display: flex; flex-direction: column; gap: 12px; }
.fx-side { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.fx-side-head { display: flex; align-items: center; gap: 8px; }
.fx-side-head b { font-size: 14px; }
.fx-side-head .muted { font-size: 12px; }
.fx-empty { margin: 0; color: var(--muted); font-size: 12.5px; }
.fx-leg {
  display: grid; gap: 6px 8px; align-items: start;
  grid-template-columns: 38px minmax(150px, 200px) minmax(0, 1fr) 118px 30px;
  grid-template-areas: "op ex find coef del" ". dt dt dt dt";
}
.fx-op { grid-area: op; height: 40px; border-radius: 8px; background: var(--surface-2); color: var(--accent); font-weight: 700; font-size: 17px; border: 1px solid var(--border); }
.fx-op:hover { border-color: var(--accent); }
.fx-ex { grid-area: ex; min-width: 0; }
.fx-ex .sf-select, .fx-ex select { width: 100%; }
.fx-ex .sf-select-trigger { height: 40px; }
.fx-find { grid-area: find; position: relative; min-width: 0; }
.fx-search { width: 100%; height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); }
.fx-search:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fx-search:disabled { background: var(--surface-2); cursor: not-allowed; }
.fx-chosen { width: 100%; height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent-soft); text-align: left; overflow: hidden; }
.fx-chosen b { font-size: 14px; flex: none; }
.fx-chosen span { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fx-coef { grid-area: coef; display: flex; align-items: center; height: 40px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--card); }
.fx-coef button { width: 32px; height: 100%; color: var(--accent); font-size: 16px; font-weight: 700; border-right: 1px solid var(--border); }
.fx-coef button:hover { background: var(--accent-soft); }
.fx-coef input { flex: 1; min-width: 0; height: 100%; padding: 0 8px; text-align: right; font-size: 14px; }
.fx-del { grid-area: del; width: 30px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 6px; }
.fx-del:hover { background: var(--neg-soft); color: var(--neg); }
.fx-del svg { width: 14px; height: 14px; }
.fx-leg-details { grid-area: dt; color: var(--muted); font-size: 11.5px; padding: 0 2px; overflow-wrap: anywhere; }
.fx-add { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px dashed var(--border-strong); color: var(--accent); font-size: 12.5px; font-weight: 550; }
.fx-add:hover:not(:disabled) { background: var(--accent-soft); border-style: solid; border-color: var(--accent); }
.fx-add:disabled { opacity: .45; cursor: not-allowed; }
.fx-add svg { width: 13px; height: 13px; }
.fx-drop { margin-top: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 14px 40px rgba(12, 16, 51, .22); padding: 4px; }
.fx-list { max-height: 264px; overflow-y: auto; display: flex; flex-direction: column; }
.fx-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; padding: 8px 10px; border-radius: 8px; text-align: left; }
.fx-item:hover, .fx-item:focus-visible { background: var(--hover); }
.fx-item b { grid-column: 1; grid-row: 1; font-size: 14px; }
.fx-item .fx-kind { grid-column: 2; grid-row: 1; font-size: 11px; color: var(--muted); white-space: nowrap; }
.fx-item .fx-desc { grid-column: 1 / -1; grid-row: 2; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-none { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.fx-more { width: 100%; padding: 9px; }
.fx-tv { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.fx-tv-title { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.fx-tv-body { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.fx-tv-body code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.fx-now { font-size: 12.5px; }
.fx-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--neg-soft); color: var(--neg); font-size: 12px; }
.fx-error[hidden] { display: none; }
.fx-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.fx-foot .btn { height: 40px; padding: 0 20px; }
@media (max-width: 640px) {
  .fx-leg { grid-template-columns: 38px minmax(0, 1fr) 30px; grid-template-areas: "op ex del" "op find find" "op coef coef" ". dt dt"; }
  .fx-coef { width: 140px; }
}

.formula-live { max-width: 1200px; margin: 0 auto; }
.formula-live-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.formula-live-head h1 { font-size: 22px; margin: 0; overflow-wrap: anywhere; }
.formula-live-summary { padding: 20px; margin-bottom: 16px; }
.formula-live-summary code { display: block; white-space: normal; overflow-wrap: anywhere; margin: 10px 0; }
.formula-live-spread { font-size: 30px; }
.formula-live-legs { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.formula-live-leg { padding: 18px; }
.formula-live-leg h3 { margin: 8px 0; }
.formula-live-leg dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; font-size: 12px; }
.formula-live-leg dt { color: var(--muted); }
.formula-live-leg dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.formula-live-leg p { overflow-wrap: anywhere; }
.formula-live-note { margin-top: 16px; padding: 16px; color: var(--muted); }
@media (max-width: 600px) { .formula-live-head h1 { width: 100%; } .fx-card .fx-ex { max-height: 110px; overflow-y: auto; } }
