@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* TrendBot Console — компоненты. Все значения из tokens.css; префикс классов tb-. */

:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.tb-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tb-muted { color: var(--ink-muted); }
.tb-profit { color: var(--profit); }
.tb-loss { color: var(--loss); }
.tb-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.tb-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.tb-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tb-label { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; color: var(--ink-muted); }
.tb-caption { font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ---------- Card ---------- */
.tb-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); }
.tb-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.tb-card__title { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0; }

/* ---------- Mode banner ---------- */
.tb-mode { display: flex; align-items: center; gap: var(--space-3); min-height: var(--banner-h); padding: 0 var(--space-4); font-size: 12px; line-height: 16px; font-weight: 500; border-bottom: 1px solid var(--line); }
.tb-mode__tag { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.6px; padding: 2px 6px; border-radius: var(--radius-sm); }
.tb-mode__right { margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tb-mode--paper { background: var(--surface); color: var(--ink-muted); }
.tb-mode--paper .tb-mode__tag { border: 1px solid var(--line-strong); color: var(--mode-paper); }
.tb-mode--testnet { background: var(--warning-soft); color: var(--warning-ink); border-bottom-color: transparent; }
.tb-mode--testnet .tb-mode__tag { background: var(--mode-testnet); color: var(--on-warning); }
.tb-mode--live { background: var(--mode-live); color: var(--on-danger); border-bottom-color: transparent; }
.tb-mode--live .tb-mode__tag { background: var(--on-danger); color: var(--danger); }

/* Standalone mode tag (key cards, tables, nav) */
.tb-modetag { display: inline-block; font-family: var(--font-mono); font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.6px; padding: 1px 6px; border-radius: var(--radius-sm); }
.tb-modetag--paper { border: 1px solid var(--line-strong); color: var(--mode-paper); }
.tb-modetag--testnet { background: var(--mode-testnet); color: var(--on-warning); }
.tb-modetag--live { background: var(--mode-live); color: var(--on-danger); }

/* ---------- Status pill ---------- */
.tb-status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface-raised); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.tb-status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.tb-status__meta { color: var(--ink-muted); font-family: var(--font-mono); font-weight: 400; }
.tb-status--running .tb-status__dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.tb-status--paused { background: var(--warning-soft); border-color: transparent; color: var(--warning-ink); }
.tb-status--paused .tb-status__dot { background: var(--warning); border-radius: 1px; }
.tb-status--halted, .tb-status--error { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.tb-status--halted .tb-status__dot, .tb-status--error .tb-status__dot { background: var(--danger-ink); border-radius: 1px; transform: rotate(45deg); }
.tb-status--offline .tb-status__dot { background: transparent; border: 1.5px solid var(--ink-muted); }
.tb-status--offline { color: var(--ink-muted); }
@media (prefers-reduced-motion: no-preference) {
  .tb-status--running .tb-status__dot { animation: tb-beat 2.4s ease-in-out infinite; }
  @keyframes tb-beat { 50% { box-shadow: 0 0 0 5px var(--success-soft); } }
}

/* ---------- Button ---------- */
.tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-md); padding: 0 14px; border-radius: var(--radius-md); border: 1px solid transparent; font: 500 14px/20px var(--font-sans); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color .12s, border-color .12s, color .12s; }
.tb-btn--primary { background: var(--accent); color: var(--on-accent); }
.tb-btn--primary:hover { background: var(--accent-hover); }
.tb-btn--secondary { background: var(--surface-raised); color: var(--ink); border-color: var(--line-strong); }
.tb-btn--secondary:hover { border-color: var(--ink-muted); }
.tb-btn--ghost { background: transparent; color: var(--ink-muted); }
.tb-btn--ghost:hover { background: var(--surface-raised); color: var(--ink); }
.tb-btn--danger { background: var(--danger); color: var(--on-danger); }
.tb-btn--danger:hover { filter: brightness(1.08); }
.tb-btn--danger-outline { background: transparent; color: var(--danger-ink); border-color: var(--danger-ink); }
.tb-btn--danger-outline:hover { background: var(--danger-soft); }
.tb-btn--sm { height: var(--control-sm); padding: 0 10px; font-size: 13px; }
.tb-btn--lg { height: var(--control-lg); padding: 0 18px; font-weight: 600; }
.tb-btn--block { width: 100%; }
.tb-btn:disabled, .tb-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }

/* ---------- Chip ---------- */
.tb-chip { display: inline-flex; align-items: center; gap: var(--space-1); height: 22px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-sunken); color: var(--ink-muted); font-size: 12px; line-height: 16px; white-space: nowrap; }
.tb-chip--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tb-chip--success { background: var(--success-soft); border-color: transparent; color: var(--success-ink); }
.tb-chip--warning { background: var(--warning-soft); border-color: transparent; color: var(--warning-ink); }
.tb-chip--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.tb-chip--mono { font-family: var(--font-mono); }
.tb-chip .tb-icon { width: 12px; height: 12px; }

/* ---------- Side tag (LONG/SHORT) ---------- */
.tb-side { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .6px; padding: 1px 6px; border-radius: var(--radius-sm); border: 1px solid currentColor; }
.tb-side--long { color: var(--profit); }
.tb-side--short { color: var(--loss); }

/* ---------- KPI tile ---------- */
.tb-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.tb-kpi__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 24px; line-height: 28px; font-weight: 500; color: var(--ink); margin-top: var(--space-1); white-space: nowrap; }
.tb-kpi--hero .tb-kpi__value { font-size: 32px; line-height: 36px; letter-spacing: -.5px; }
.tb-kpi__delta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; line-height: 16px; }
.tb-kpi__sub { font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ---------- Limit meter ---------- */
.tb-meter { display: flex; flex-direction: column; gap: 6px; }
.tb-meter__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.tb-meter__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink); }
.tb-meter__value b { font-weight: 500; }
.tb-meter__track { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--line); overflow: hidden; }
.tb-meter__fill { position: absolute; inset: 0 auto 0 0; border-radius: var(--radius-pill); background: var(--ink-muted); }
.tb-meter--warn .tb-meter__fill { background: var(--warning); }
.tb-meter--crit .tb-meter__fill { background: var(--danger-ink); }
.tb-meter--warn .tb-meter__value b { color: var(--warning-ink); }
.tb-meter--crit .tb-meter__value b { color: var(--danger-ink); }
.tb-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; height: 6px; }
.tb-seg > i { border-radius: 2px; background: var(--surface-sunken); border: 1px solid var(--line); }
.tb-seg > i.on { background: var(--ink-muted); border-color: transparent; }
.tb-seg--full > i.on { background: var(--warning); }

/* ---------- Callout ---------- */
.tb-callout { display: grid; grid-template-columns: 16px 1fr; gap: 2px var(--space-2); padding: var(--space-3) 14px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); }
.tb-callout .tb-icon { margin-top: 2px; }
.tb-callout__title { font-weight: 600; }
.tb-callout__body { grid-column: 2; color: var(--ink-muted); }
.tb-callout__body .tb-num { color: var(--ink); }
.tb-callout__actions { grid-column: 2; margin-top: var(--space-2); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.tb-callout--info { background: var(--accent-soft); border-color: transparent; }
.tb-callout--info .tb-icon, .tb-callout--info .tb-callout__title { color: var(--accent); }
.tb-callout--warning { background: var(--warning-soft); border-color: transparent; }
.tb-callout--warning .tb-icon, .tb-callout--warning .tb-callout__title { color: var(--warning-ink); }
.tb-callout--danger { background: var(--danger-soft); border-color: transparent; }
.tb-callout--danger .tb-icon, .tb-callout--danger .tb-callout__title { color: var(--danger-ink); }
.tb-callout--warning .tb-callout__body, .tb-callout--danger .tb-callout__body, .tb-callout--info .tb-callout__body { color: var(--ink); }

/* ---------- Field ---------- */
.tb-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tb-field__label { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; line-height: 18px; font-weight: 500; }
.tb-field__key { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); font-weight: 400; }
.tb-field__changed { margin-left: auto; font-size: 11px; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.tb-field__changed::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.tb-input { display: flex; align-items: center; height: var(--control-md); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-sunken); overflow: hidden; }
.tb-input:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.tb-input input, .tb-input select { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); padding: 0 var(--space-3); font: 400 14px/20px var(--font-mono); font-variant-numeric: tabular-nums; outline: none; }
.tb-input__unit { padding: 0 var(--space-3); color: var(--ink-muted); font-family: var(--font-mono); font-size: 12px; border-left: 1px solid var(--line); height: 100%; display: flex; align-items: center; }
.tb-field--changed .tb-input { background: var(--accent-soft); }
.tb-field--error .tb-input { border-color: var(--danger-ink); }
.tb-field__hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.tb-field__error { font-size: 12px; line-height: 16px; color: var(--danger-ink); display: flex; gap: 4px; align-items: flex-start; }
.tb-field__error .tb-icon { width: 14px; height: 14px; margin-top: 1px; }
.tb-field__rec { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Segmented (radio switch) ---------- */
.tb-segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--line); }
.tb-segmented button { height: 30px; padding: 0 12px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-muted); font: 500 13px/18px var(--font-sans); cursor: pointer; }
.tb-segmented button[aria-pressed="true"] { background: var(--surface-raised); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

/* ---------- Choice card (strategy model) ---------- */
.tb-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.tb-choice { position: relative; display: flex; flex-direction: column; gap: var(--space-2); text-align: left; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.tb-choice:hover { border-color: var(--ink-muted); }
.tb-choice[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.tb-choice__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tb-choice__name { font-family: var(--font-mono); font-weight: 500; font-size: 14px; }
.tb-choice__radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.tb-choice[aria-checked="true"] .tb-choice__radio { border: 5px solid var(--accent); }
.tb-choice__desc { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.tb-choice__stats { display: flex; gap: var(--space-3); font-family: var(--font-mono); font-size: 12px; padding-top: var(--space-2); border-top: 1px solid var(--line); }
.tb-choice__stats span { color: var(--ink-muted); }

/* ---------- Table ---------- */
.tb-table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: auto; }
.tb-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
.tb-table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-muted); padding: 10px var(--space-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tb-table td { height: var(--row-h); padding: 0 var(--space-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tb-table tr:last-child td { border-bottom: 0; }
.tb-table tbody tr:hover td { background: var(--surface-raised); }
.tb-table .n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tb-table .t { font-family: var(--font-mono); color: var(--ink-muted); }
.tb-table tr.is-skipped td { color: var(--ink-muted); }

/* ---------- Price ladder ---------- */
.tb-ladder { position: relative; padding: 36px 0 34px; }
.tb-ladder__rail { position: relative; height: 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); border: 1px solid var(--line); }
.tb-ladder__risk { position: absolute; top: -1px; bottom: -1px; background: var(--danger-soft); border-left: 2px solid var(--chart-stop); }
.tb-ladder__gain { position: absolute; top: -1px; bottom: -1px; background: var(--success-soft); }
.tb-ladder__mark { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.tb-ladder__mark i { display: block; width: 2px; height: 18px; border-radius: 1px; }
.tb-ladder__lbl { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-family: var(--font-mono); font-size: 11px; line-height: 14px; text-align: center; }
.tb-ladder__lbl small { display: block; font-family: var(--font-sans); color: var(--ink-muted); font-size: 11px; }
.tb-ladder__mark--up .tb-ladder__lbl { bottom: 22px; }
.tb-ladder__mark--down .tb-ladder__lbl { top: 22px; }
.tb-ladder__mark--liq i { background: repeating-linear-gradient(var(--chart-stop) 0 3px, transparent 3px 5px); }
.tb-ladder__mark--stop i { background: var(--chart-stop); }
.tb-ladder__mark--entry i { background: var(--chart-entry); }
.tb-ladder__mark--price i { background: var(--ink); width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); }
.tb-ladder__mark--high i { background: var(--chart-high); }
.tb-ladder__mark--liq .tb-ladder__lbl, .tb-ladder__mark--stop .tb-ladder__lbl { color: var(--danger-ink); }
.tb-ladder__mark--entry .tb-ladder__lbl { color: var(--accent); }
.tb-ladder__mark--high .tb-ladder__lbl { color: var(--warning-ink); }

/* ---------- Dialog ---------- */
.tb-scrim { position: fixed; inset: 0; background: rgba(5, 7, 10, .62); display: grid; place-items: center; padding: var(--space-4); }
.tb-dialog { width: min(460px, 100%); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); }
.tb-dialog__head { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-6) var(--space-6) 0; }
.tb-dialog__glyph { width: 36px; height: 36px; border-radius: var(--radius-md); display: grid; place-items: center; flex: none; background: var(--danger-soft); color: var(--danger-ink); }
.tb-dialog__glyph .tb-icon { width: 20px; height: 20px; }
.tb-dialog__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.tb-dialog__lead { margin: 2px 0 0; color: var(--ink-muted); }
.tb-dialog__body { padding: var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.tb-dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--line); }
.tb-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--line); }
.tb-facts dt { color: var(--ink-muted); font-size: 13px; }
.tb-facts dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.tb-facts .is-key dd { color: var(--danger-ink); font-weight: 500; }
.tb-otp { display: flex; gap: 6px; }
.tb-otp input { width: 40px; height: var(--control-lg); text-align: center; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--ink); font: 500 18px/24px var(--font-mono); }

/* ---------- Key card ---------- */
.tb-key { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.tb-key__head { display: flex; align-items: center; gap: var(--space-3); padding: 14px var(--space-4); border-bottom: 1px solid var(--line); }
.tb-key__name { font-weight: 600; }
.tb-key__secret { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-4) var(--space-4) 0; padding: 10px var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 13px; }
.tb-checks { list-style: none; margin: 0; padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; }
.tb-checks li { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; border-bottom: 1px dashed var(--line); }
.tb-checks li:last-child { border-bottom: 0; }
.tb-checks .tb-icon { width: 16px; height: 16px; }
.tb-checks .ok .tb-icon { color: var(--success-ink); }
.tb-checks .warn .tb-icon, .tb-checks .warn .r { color: var(--warning-ink); }
.tb-checks .bad .tb-icon, .tb-checks .bad .r { color: var(--danger-ink); }
.tb-checks .r { margin-left: auto; font-size: 12px; color: var(--ink-muted); }
.tb-key__foot { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); background: var(--bg); }

/* ---------- Diff ---------- */
.tb-diff { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.tb-diff__row { display: grid; grid-template-columns: minmax(140px, 1fr) auto auto auto; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); border-bottom: 1px solid var(--line); font-size: 13px; }
.tb-diff__row:last-child { border-bottom: 0; }
.tb-diff__key { font-family: var(--font-mono); }
.tb-diff__key small { display: block; font-family: var(--font-sans); color: var(--ink-muted); font-size: 12px; }
.tb-diff__old { font-family: var(--font-mono); color: var(--ink-muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.tb-diff__arrow { color: var(--ink-faint); }
.tb-diff__new { font-family: var(--font-mono); font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 2px 6px; border-radius: var(--radius-sm); }
.tb-diff__row--risk { background: var(--warning-soft); }
.tb-diff__row--risk .tb-diff__new { color: var(--warning-ink); background: transparent; box-shadow: inset 0 0 0 1px var(--warning-ink); }
.tb-diff__note { grid-column: 1 / -1; font-size: 12px; color: var(--warning-ink); display: flex; gap: 4px; align-items: center; }

/* ---------- Nav / shell ---------- */
.tb-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }
.tb-nav { background: var(--surface); border-right: 1px solid var(--line); padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.tb-nav__brand { display: flex; align-items: center; gap: var(--space-2); padding: 4px 8px 16px; font-weight: 600; }
.tb-nav__brand .tb-num { font-size: 12px; color: var(--ink-muted); font-weight: 400; }
.tb-nav__mark { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); position: relative; overflow: hidden; }
.tb-nav__mark::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 5px; height: 9px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: skewY(-28deg); }
.tb-nav__section { padding: 14px 8px 6px; }
.tb-nav__item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; border-radius: var(--radius-md); color: var(--ink-muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.tb-nav__item:hover { background: var(--surface-raised); color: var(--ink); }
.tb-nav__item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.tb-nav__badge { margin-left: auto; font-family: var(--font-mono); font-size: 11px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--ink-muted); border: 1px solid var(--line); }
.tb-nav__badge--warn { background: var(--warning-soft); color: var(--warning-ink); border-color: transparent; }
.tb-topbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-8); border-bottom: 1px solid var(--line); }
.tb-topbar h1 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.tb-topbar__right { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.tb-page { padding: var(--space-6) var(--space-8); display: flex; flex-direction: column; gap: var(--space-4); }
.tb-grid { display: grid; gap: var(--space-4); }
.tb-grid--kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 760px) {
  .tb-shell { grid-template-columns: 1fr; }
  .tb-nav { display: none; }
  .tb-topbar, .tb-page { padding-left: var(--space-4); padding-right: var(--space-4); }
  .tb-grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Chart card (PriceChart, EquityChart) ---------- */
.tb-chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.tb-chart__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.tb-chart__title { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: var(--space-2); }
.tb-chart__tools { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.tb-chart__legend { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); padding: var(--space-2) var(--space-4); font-family: var(--font-mono); font-size: 12px; line-height: 16px; color: var(--ink-muted); border-bottom: 1px solid var(--line); }
.tb-chart__legend b { color: var(--ink); font-weight: 500; }
.tb-chart__canvas { position: relative; height: 340px; }
.tb-chart__canvas--sm { height: 200px; }
.tb-chart__keys { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-4) var(--space-3); font-size: 12px; color: var(--ink-muted); }
.tb-key-item { display: inline-flex; align-items: center; gap: 6px; }
.tb-key-item i { width: 14px; height: 0; border-top: 2px solid; }
.tb-key-item i.dash { border-top-style: dashed; }
.tb-key-item i.dot { width: 8px; height: 8px; border: 0; border-radius: 50%; }
.tb-toggle { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-md); border: 1px solid var(--line); background: transparent; color: var(--ink-muted); font: 500 12px/16px var(--font-sans); cursor: pointer; }
.tb-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--line-strong); background: var(--surface-raised); }
.tb-toggle i { width: 10px; height: 2px; border-radius: 1px; }

/* ---------- Trade history ---------- */
.tb-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.tb-summary > div { padding: var(--space-3) var(--space-4); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.tb-summary > div:last-child { border-right: 0; }
.tb-summary b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 16px; line-height: 24px; font-weight: 500; }
.tb-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.tb-filters .tb-chip--accent button { background: none; border: 0; padding: 0; margin-left: 2px; color: inherit; cursor: pointer; font: inherit; }
.tb-rbar { display: inline-grid; grid-template-columns: 48px 48px; align-items: center; height: 10px; vertical-align: middle; }
.tb-rbar > span { height: 8px; }
.tb-rbar__neg { justify-self: end; background: var(--hist-neg); border-radius: 2px 0 0 2px; }
.tb-rbar__pos { justify-self: start; background: var(--hist-pos); border-radius: 0 2px 2px 0; }
.tb-rbar::before { content: ""; grid-column: 1 / 3; grid-row: 1; justify-self: center; width: 1px; height: 12px; background: var(--line-strong); }
.tb-rbar > span { grid-row: 1; }
.tb-rbar__neg { grid-column: 1; }
.tb-rbar__pos { grid-column: 2; }
.tb-expand { width: 24px; height: 24px; border: 0; background: transparent; color: var(--ink-muted); border-radius: var(--radius-sm); cursor: pointer; display: grid; place-items: center; }
.tb-expand:hover { background: var(--surface-sunken); color: var(--ink); }
.tb-expand[aria-expanded="true"] .tb-icon { transform: rotate(90deg); }
.tb-table tr.is-detail td { height: auto; padding: var(--space-3) var(--space-4) var(--space-4) 44px; background: var(--bg); white-space: normal; }
.tb-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3) var(--space-6); }
.tb-detail dt { font-size: 11px; line-height: 16px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-muted); }
.tb-detail dd { margin: 2px 0 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.tb-exit { font-size: 12px; color: var(--ink-muted); }

/* ---------- Tab bar (мобильная замена Nav, < 760px; см. Nav/README.md) ---------- */
.tb-tabbar { display: none; }
@media (max-width: 760px) {
  .tb-tabbar { position: sticky; bottom: 0; z-index: 5; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-top: 1px solid var(--line); }
  .tb-tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--control-lg); padding: 6px 4px; color: var(--ink-muted); text-decoration: none; font-size: 11px; line-height: 14px; font-weight: 500; }
  .tb-tabbar a[aria-current="page"] { color: var(--accent); }
  .tb-page { padding-bottom: var(--space-8); }
  .tb-grid--2 { grid-template-columns: 1fr !important; }
}
.tb-topbar__menu { position: relative; }
.tb-topbar__menu details > summary { list-style: none; cursor: pointer; }
.tb-topbar__menu details > summary::-webkit-details-marker { display: none; }
.tb-topbar__menu details[open] > div { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay); padding: var(--space-2); display: flex; flex-direction: column; gap: 2px; z-index: 6; }
.tb-topbar__menu details[open] > div button, .tb-topbar__menu details[open] > div a { width: 100%; justify-content: flex-start; }
.tb-choice input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tb-choice:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.tb-scrim[hidden] { display: none; }
.tb-scrim { z-index: 20; }
/* ---------- правки при сборке панели (2026-10-19) ---------- */
[hidden] { display: none !important; }
.tb-key__foot { flex-wrap: wrap; }
@media (max-width: 760px) {
  .tb-mode { flex-wrap: wrap; height: auto; padding: 6px var(--space-3); row-gap: 2px; }
  .tb-mode__right { margin-left: 0; width: 100%; }
  .tb-topbar { flex-wrap: wrap; row-gap: var(--space-2); }
  .tb-topbar__right { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .tb-page { padding-bottom: 72px; }
  .tb-table-wrap { max-width: 100%; }
  .tb-choices { grid-template-columns: 1fr; }
}
html, body { min-height: 100%; }
.tb-shell { min-height: calc(100vh - var(--banner-h)); }
