/* Inline order ticket (right rail, «Угода»). Exchange-style: compact 32px controls, tabular numbers. */
#ticketPanel { padding: 0; overflow-y: auto; overflow-x: hidden; }
.tf { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); min-width: 0; font-family: var(--sans); }
.tf * { box-sizing: border-box; }
.tf-num, .tf-box input, .tf-row b, .tf-sides .px, .tf-levnum input { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tf-k { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }

/* top line: available balance + margin / leverage chips */
.tf-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--rule); }
.tf-avail { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tf-avail .tf-k { font-size: var(--fs-2xs); line-height: 1; }
.tf-avail b { font-size: var(--fs-lg); line-height: 1.1; font-weight: 600; color: var(--text); }
.tf-chips { display: flex; gap: 4px; flex: none; }
.tf-chip { height: 26px; padding: 0 var(--s2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--panel2); color: var(--text); font: 500 var(--fs-xs)/1 var(--sans); cursor: pointer; transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease); }
.tf-chip:hover { border-color: var(--accent); background: var(--hover); }
.tf-chip-lev { font-family: var(--mono); font-weight: 600; color: var(--accent-hover); min-width: 44px; }
.tf-chip[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* inline leverage slider */
.tf-levpop { padding: var(--s2) var(--s3); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-md); display: grid; gap: 6px; }
.tf-levpop[hidden] { display: none; }
.tf-levrow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s2); }
.tf-levrow input[type=range] { width: 100%; min-width: 0; margin: 0; }
.tf-levnum { display: inline-flex; align-items: center; gap: 2px; }
.tf-levnum input { width: 48px; height: 28px; text-align: right; padding: 0 4px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-sm); }
.tf-levnum i { font-style: normal; color: var(--muted); }
.tf-marks, .tf-pcts { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.tf-marks button, .tf-pcts button { height: 22px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); border-radius: var(--r-sm); font: 500 var(--fs-2xs)/1 var(--mono); cursor: pointer; padding: 0; }
.tf-marks button:hover, .tf-pcts button:hover { color: var(--text); border-color: var(--accent); }

.tf-pair { display: flex; align-items: baseline; gap: var(--s2); }
.tf-pair b { font-size: var(--fs-sm); font-weight: 600; }
.tf-pair span { font-size: var(--fs-2xs); color: var(--soft); }

/* order type */
.tf-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; padding: 2px; }
.tf-seg > button { height: 28px; font-size: var(--fs-sm); }
.tf-seg > button.active { background: var(--selected); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* boxed field: label left, number right, unit suffix */
.tf-box { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s2); min-width: 0; background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: text; transition: border-color var(--dur-fast) var(--ease); }
.tf-box:hover { border-color: var(--border-strong); }
.tf-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.tf-box input { flex: 1 1 0; min-width: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; outline: 0; background: transparent; color: var(--text); text-align: right; font-size: var(--fs-sm); box-shadow: none; -moz-appearance: textfield; }
.tf-box input::-webkit-outer-spin-button, .tf-box input::-webkit-inner-spin-button, .tf-levnum input::-webkit-outer-spin-button, .tf-levnum input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tf-box input::placeholder { color: var(--soft); }
.tf-box i { font-style: normal; font-size: var(--fs-2xs); color: var(--soft); flex: none; }
.tf-box.is-off { background: transparent; border-style: dashed; }
.tf-box.is-off input { color: var(--muted); }
.tf-box.is-off .tf-mini { display: none; }
.tf-mini, .tf-unit { flex: none; height: 22px; padding: 0 6px; border: 1px solid var(--border-strong); background: var(--surface3); color: var(--accent-hover); border-radius: 4px; font: 500 var(--fs-2xs)/1 var(--sans); cursor: pointer; }
.tf-unit { min-width: 52px; color: var(--text); font-family: var(--mono); }
.tf-unit::after { content: " ⇄"; color: var(--soft); }
.tf-mini:hover, .tf-unit:hover { border-color: var(--accent); }

/* size: percent of available balance × leverage */
.tf-pct { display: grid; grid-template-columns: 1fr 40px; align-items: center; gap: var(--s2); margin-top: -2px; }
.tf-pct input[type=range] { width: 100%; margin: 0; min-width: 0; }
.tf-pct input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent-fill) var(--p, 0%), var(--border-strong) var(--p, 0%)); }
.tf-pct span { text-align: right; font-size: var(--fs-xs); color: var(--muted); }

/* TP / SL */
.tf-check { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text); cursor: pointer; padding-top: var(--s2); border-top: 1px solid var(--rule); }
.tf-check input { margin: 0; accent-color: var(--accent); width: 14px; height: 14px; }
.tf-check-s { border: 0; padding: 0; font-size: var(--fs-xs); color: var(--muted); }
.tf-tpsl { display: grid; gap: 4px; }
.tf-tpsl[hidden] { display: none; }
.tf-leg { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 4px; align-items: center; }
.tf-tag { font: 700 var(--fs-2xs)/1 var(--mono); text-align: center; padding: 4px 0; border-radius: 4px; }
.tf-leg-tp .tf-tag { color: var(--long); background: var(--long-soft); }
.tf-leg-sl .tf-tag { color: var(--short); background: var(--short-soft); }
.tf-leg-tp .tf-box:focus-within { border-color: var(--long); box-shadow: none; }
.tf-leg-sl .tf-box:focus-within { border-color: var(--short); box-shadow: none; }
.tf-hint { min-height: 14px; margin: 0 0 2px 28px; font: 400 var(--fs-2xs)/1.3 var(--mono); }
.tf-hint:empty { display: none; }
.tf-up { color: var(--long); }
.tf-down { color: var(--short); }

/* live summary */
.tf-result { display: grid; gap: 4px; padding-top: var(--s2); border-top: 1px solid var(--rule); }
.tf-rows { display: grid; gap: 3px; }
.tf-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); font-size: var(--fs-xs); }
.tf-row span { color: var(--muted); }
.tf-row b { font-weight: 500; color: var(--text); text-align: right; }
.tf-row b.warn { color: var(--liq); }
.tf-row b small { font-size: var(--fs-2xs); color: var(--soft); margin-left: 4px; }
.tf-warn { margin-top: 4px; padding: 6px var(--s2); font-size: var(--fs-2xs); line-height: 1.35; color: var(--warning); background: var(--warning-soft); border-left: 2px solid var(--warning); border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* long / short */
.tf-sides { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s1); position: sticky; bottom: 0; z-index: 2; padding: var(--s2) 0; background: var(--panel); box-shadow: 0 -10px 10px -8px #000000A0; }
.tf-sides .btn { height: 40px; padding: 0 var(--s2); justify-content: center; gap: 6px; font-weight: 700; font-size: var(--fs-md); min-width: 0; white-space: nowrap; }
.tf-sides .px { font-weight: 600; font-size: var(--fs-sm); }
.tf-sides .btn:disabled { opacity: .35; filter: saturate(.5); cursor: not-allowed; }
.tf-demo { margin: 0; text-align: center; font-size: var(--fs-2xs); color: var(--soft); }

/* order confirmation */
#ticketPanel #confirmCard { margin: 0 var(--s3) var(--s3); border-color: var(--border-strong); }
#ticketPanel #confirmCard.is-long { border-top: 2px solid var(--long); }
#ticketPanel #confirmCard.is-short { border-top: 2px solid var(--short); }
#confirmCard .confirm-rows div b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
#confirmCard.is-long #confirmOk { background: var(--long); color: var(--on-long); }
#confirmCard.is-short #confirmOk { background: var(--short); color: var(--on-short); }

/* open positions under the order form (fills the empty lower part of the right panel) */
.tf-pos { margin: 0 var(--s3) var(--s3); padding-top: var(--s3); border-top: 1px solid var(--rule); font-family: var(--sans); }
.tf-pos-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); font-size: var(--fs-xs); color: var(--muted); }
.tf-pos-head b { font-weight: 600; letter-spacing: .02em; color: var(--text); }
.tf-pos-n { padding: 1px 6px; border-radius: var(--r-pill); background: var(--panel2); font: 500 var(--fs-2xs)/1.4 var(--mono); }
.tf-pos-list { display: grid; gap: 2px; }
.tf-pos-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto 22px; align-items: center; gap: var(--s2); min-height: 32px; padding: 0 2px 0 var(--s2); border-radius: var(--r-sm); background: var(--panel2); font-size: var(--fs-xs); }
.tf-pos-row > * { min-width: 0; white-space: nowrap; }
.tf-pos-sym { justify-self: start; padding: 0; border: 0; background: none; color: var(--text); font: 600 var(--fs-sm)/1 var(--sans); cursor: pointer; }
.tf-pos-sym:hover { color: var(--accent-hover); }
.tf-pos-side { font-size: var(--fs-2xs); font-weight: 600; }
.tf-pos-size, .tf-pos-pnl { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.tf-pos-size { color: var(--muted); }
.tf-pos-pnl { font-weight: 600; min-width: 52px; }
.tf-pos-x { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: 400 16px/1 var(--sans); cursor: pointer; }
.tf-pos-x:hover { background: var(--short-soft); color: var(--short); }
.tf-pos-empty { margin: 0; padding: var(--s3) 0; text-align: center; font-size: var(--fs-xs); color: var(--soft); }
