/* ═══════════════════════════════════════════════════════════
   APEX Terminal — terminal.css
   Торговый терминал: toolbar 56px / панели 260 px + 320 px.
   Палитра та же, что на лендинге (style.css): королевский синий #1e40af.
   Тёмная / светлая тема — data-theme на <html> (assets/theme.js).
   ═══════════════════════════════════════════════════════════ */

/* ═══ Тёмная тема (по умолчанию) ═══ */
:root,
[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-2: #0f1420;
  --card: #141824;
  --border: #1e2533;
  --text: #e6e8eb;
  --muted: #8b95a5;
  --accent: #1e40af;
  --accent-hover: #1e3a8a;
  --accent-light: #2563eb;
  --accent-glow: rgba(30, 64, 175, 0.4);
  --accent-soft: rgba(30, 64, 175, 0.12);
  --accent-line: rgba(30, 64, 175, 0.5);
  --profit: #26a269;
  --loss: #c01c28;

  --bg-rgb: 10, 14, 26;
  --bg-2-rgb: 15, 20, 32;
  --card-rgb: 20, 24, 36;
  --border-rgb: 30, 37, 51;
  --accent-rgb: 30, 64, 175;
  --accent-light-rgb: 37, 99, 235;
  --profit-rgb: 38, 162, 105;
  --loss-rgb: 192, 28, 40;
  --shadow-rgb: 0, 0, 0;

  --surface-hover: #1a2030;
  --handle-bg: #2b3446;
  --scroll: #232b3d;
  --scroll-hover: #2f3a51;
  --text-2: #c3cad6;
  --muted-2: #5d6675;
  --muted-3: #b6bec9;
  --warn: #d9a94a;
  --on-accent: #f7f8ff;
  --on-profit: #04140d;
  --on-loss: #fff5f5;
  --panel-bg: rgba(20, 24, 36, 0.92);

  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

  color-scheme: dark;

  --toolbar-h: 56px;
  --left-w: 260px;
  --right-w: 320px;
  --handle: 8px;

  --radius-sm: 10px;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* ═══ Светлая тема ═══ */
[data-theme="light"] {
  --bg: #f8f9fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1a1d24;
  --muted: #6b7280;
  --accent: #1e40af;
  --accent-hover: #1e3a8a;
  --accent-light: #2563eb;
  --accent-glow: rgba(30, 64, 175, 0.25);
  --accent-soft: rgba(30, 64, 175, 0.1);
  --accent-line: rgba(30, 64, 175, 0.45);
  --profit: #16a34a;
  --loss: #dc2626;

  --bg-rgb: 248, 249, 251;
  --bg-2-rgb: 255, 255, 255;
  --card-rgb: 255, 255, 255;
  --border-rgb: 229, 231, 235;
  --accent-rgb: 30, 64, 175;
  --accent-light-rgb: 37, 99, 235;
  --profit-rgb: 22, 163, 74;
  --loss-rgb: 220, 38, 38;
  --shadow-rgb: 15, 23, 42;

  --surface-hover: #f1f5f9;
  --handle-bg: #cbd5e1;
  --scroll: #cbd5e1;
  --scroll-hover: #94a3b8;
  --text-2: #4b5563;
  --muted-2: #9ca3af;
  --muted-3: #6b7280;
  --warn: #b45309;
  --on-accent: #ffffff;
  --on-profit: #ffffff;
  --on-loss: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.92);

  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

/* Терминал занимает ровно вьюпорт: без прокрутки страницы,
   скроллятся только внутренние области панелей */
html, body { height: 100%; margin: 0; overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

::selection { background: rgba(var(--accent-rgb), 0.32); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }

.up { color: var(--profit); }
.down { color: var(--loss); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ─── Каркас: toolbar + бесшовный bento ─────────── */
.term {
  --col-left: var(--left-w);
  --col-right: var(--right-w);

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--toolbar-h) minmax(0, 1fr);
  grid-template-areas:
    "toolbar"
    "bento";
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(var(--accent-rgb), 0.16), transparent 60%),
    var(--bg);
}

.term.is-left-collapsed { --col-left: var(--handle); }
.term.is-right-collapsed { --col-right: var(--handle); }

.bento {
  grid-area: bento;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
  grid-template-rows: minmax(0, 1fr) 210px;
  grid-template-areas:
    "chart  dom"
    "pos    jarvis";
  gap: 8px;
  min-height: 0;
  padding: 8px;
}

.bento-cell {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: none;
  overflow: hidden;
}

.bento-chart { grid-area: chart; display: flex; flex-direction: column; }
.bento-chart .chart-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.bento-chart .term-chart { flex: 1; min-height: 0; height: auto; }

.bento-dom {
  grid-area: dom;
  display: flex;
  flex-direction: column;
}
.bento-pos { grid-area: pos; display: flex; flex-direction: column; }
.bento-jarvis { grid-area: jarvis; display: flex; flex-direction: column; }
.bento-jarvis .chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 0;
  background: transparent;
}

.dom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px 6px;
}
.dom-kicker {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-light);
}
.dom-legend { display: flex; gap: 10px; }
.leg {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.leg-bid { color: var(--profit); }
.leg-ask { color: var(--loss); }
.dom-foot { flex: 0 0 auto; }

.ob-row.is-quote-bid { box-shadow: inset 2px 0 0 #34d399; }
.ob-row.is-quote-ask { box-shadow: inset 2px 0 0 #b91c1c; }
.ob-row.is-quote-bid::after,
.ob-row.is-quote-ask::after {
  content: "Q";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font: 700 8px/1 var(--mono);
  color: #fafaf9;
}

.chart-hub {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.hud-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 12px;
  border: 1px solid rgba(148, 197, 255, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #dbe7f5;
  font: 600 12px/1.2 Inter, system-ui, sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.hud-btn:hover {
  border-color: rgba(34, 211, 238, 0.9);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.4), 0 0 16px rgba(34, 211, 238, 0.32);
}
.hud-btn:active { transform: translateY(1px); }

.pos-split {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.pairs-pane, .pos-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pairs-pane { border-right: 1px solid var(--border); }
.pairs-pane .pair-list { flex: 1; overflow: auto; }
.term-shadow { display: none !important; }
.pos-table-wrap { flex: 1; overflow: auto; }
.pos-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.pos-table th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  background: rgba(7, 11, 22, 0.95);
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.pos-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.pos-table tr:hover td { background: rgba(56, 189, 248, 0.06); }
.pos-hint { font-family: var(--mono); font-size: 10px; color: var(--accent-light); }
.skew-bar {
  display: inline-block;
  width: 52px;
  height: 4px;
  margin-right: 6px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
  vertical-align: middle;
  overflow: hidden;
}
.skew-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #38bdf8);
}

.tb-btn--neon {
  border-color: rgba(30, 58, 138, 0.65);
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.55);
  box-shadow: none;
}
.tb-btn--neon:hover { background: rgba(30, 58, 138, 0.55); }
.chat-bloom { margin-left: auto; font-size: 11px; padding: 4px 10px; }

/* ─── Toolbar ──────────────────────────────── */
.toolbar {
  grid-area: toolbar;
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: var(--toolbar-h);
  padding: 0 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.tb-left, .tb-right, .tb-center {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tb-center { gap: 10px; }

.tb-logo {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent);
  padding: 0 6px 0 2px;
  white-space: nowrap;
}
.tb-logo:hover { color: var(--accent-hover); }

.mode-switch {
  display: flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.mode-btn {
  padding: 4px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.is-active { background: var(--accent); color: var(--on-accent); }

.tf-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.tf-btn {
  min-width: 36px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.tf-btn:hover { color: var(--text); background: var(--card); }
.tf-btn.is-active { background: var(--accent); color: var(--on-accent); }

.tb-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.tb-btn:hover { border-color: rgba(var(--accent-rgb), 0.5); color: var(--on-accent); background: rgba(var(--accent-rgb), 0.12); }

.tb-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.tb-icon:hover { border-color: rgba(var(--accent-rgb), 0.5); background: rgba(var(--accent-rgb), 0.12); }

/* ─── Переключатели языка и темы (топ-бар) ─── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.header-controls .tb-btn {
  min-width: 46px;
  padding: 6px 8px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.header-controls .tb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.header-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.header-btn .icon-sun { display: block; }
.header-btn .icon-moon { display: none; }

/* ─── Popover «Индикаторы» ─────────────────── */
.popover-host { position: relative; }

.popover {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 40;
  width: 246px;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 12px 32px rgba(var(--shadow-rgb), 0.45);
}

.pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12.5px;
  cursor: pointer;
}
.pop-row input { accent-color: var(--accent); }
.pop-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

/* ─── Панели + «язычки» сворачивания ───────── */
.panel {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: var(--bg-2);
}
.panel--left { grid-area: left; border-right: 1px solid var(--border); }
.panel--right { grid-area: right; border-left: 1px solid var(--border); }

.panel-inner {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: var(--left-w);
  height: 100%;
  min-height: 0;
  transition: transform 0.32s ease;
}
.panel--right .panel-inner {
  width: var(--right-w);
  left: auto;
  right: 0;
}

.term.is-left-collapsed .panel--left .panel-inner {
  transform: translateX(calc(var(--handle) - var(--left-w)));
}
.term.is-right-collapsed .panel--right .panel-inner {
  transform: translateX(calc(var(--right-w) - var(--handle)));
}

.panel-handle {
  position: absolute;
  top: 0;
  z-index: 6;
  width: var(--handle);
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--card);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.panel--left .panel-handle { right: 0; }
.panel--right .panel-handle { left: 0; }

/* «Язычок»: стрелка показывает, куда уедет панель */
.panel-handle::after {
  content: '◄';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  line-height: 1;
  color: var(--muted-2);
  transition: color 0.2s ease;
}
.panel--right .panel-handle::after { content: '►'; }
.term.is-left-collapsed .panel--left .panel-handle::after { content: '►'; }
.term.is-right-collapsed .panel--right .panel-handle::after { content: '◄'; }

.panel-handle:hover { background: var(--surface-hover); }
.panel-handle:hover::after { color: var(--accent); }

.panel-head {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-head--split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ob-pair { letter-spacing: 0.04em; color: var(--text); }

/* ─── Поиск пары ───────────────────────────── */
.pair-search { padding: 0 10px 8px; }

.pair-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.2s ease;
}
.pair-search input::placeholder { color: var(--muted-2); }
.pair-search input:focus { border-color: rgba(var(--accent-rgb), 0.6); }

/* ─── Список пар ───────────────────────────── */
.pair-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 8px;
}

.pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.pair-row:hover { background: var(--card); }
.pair-row.is-active { background: rgba(var(--accent-rgb), 0.14); }

.pair-sym { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pair-tick {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
}
.pair-name { font-size: 12.5px; font-weight: 600; }
.pair-quote { font-size: 11px; color: var(--muted); }

.pair-num { text-align: right; }
.pair-price { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pair-change { font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ─── Нижний блок: новости / логи ──────────── */
.side-bottom {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--card); color: var(--text); }

.tab-fold {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.25s ease, color 0.2s ease;
}
.tab-fold:hover { color: var(--text); }
.side-bottom.is-collapsed .tab-fold { transform: rotate(180deg); }
.side-bottom.is-collapsed .tab-body { display: none; }

.tab-body {
  height: 208px;
  overflow-y: auto;
  padding: 8px 10px 10px;
}
.side-bottom[data-tab="news"] .feed--logs { display: none; }
.side-bottom[data-tab="logs"] .feed:not(.feed--logs) { display: none; }

.feed li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(var(--border-rgb), 0.7);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.feed li:last-child { border-bottom: 0; }
.feed time {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}
.feed--logs li { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.feed--logs li.is-warn { color: var(--warn); }
.feed--logs li.is-ok { color: var(--profit); }

/* ─── Центр ────────────────────────────────── */
.center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.chart-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.chart-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  text-transform: uppercase;
}

.chart-tf { color: var(--muted); font-weight: 500; }

.src-badge {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.src-badge.is-live { border-color: rgba(var(--profit-rgb), 0.5); color: var(--profit); }

.chart-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-price #term-change { font-size: 12.5px; font-weight: 600; }

.term-chart { flex: 1 1 auto; min-height: 220px; height: auto; width: 100%; }
.term-chart canvas,
.term-chart > div { border-radius: 8px; }

/* ─── AI-чат ───────────────────────────────── */
.chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.chat-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-hint { font-size: 11px; color: var(--muted-2); }

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.msg {
  max-width: 76%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}
.msg--user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
}
.msg--ai {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  background: var(--card);
}
.msg--ai .msg-src {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.msg.is-pending { color: var(--muted); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
}

.chat-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}
.chat-form input::placeholder { color: var(--muted-2); }
.chat-form input:focus { border-color: rgba(var(--accent-rgb), 0.6); }

.chat-send {
  width: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.chat-send:hover { background: var(--accent-hover); }

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 12px;
}

/* ─── Кнопки [⤢]: развернуть чат / график ───── */
.chat-fs-btn,
.chart-fs-btn {
  margin-left: auto;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.chat-fs-btn:hover,
.chart-fs-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.55);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-light);
}

/* ─── Чат на весь экран: график скрыт ───────── */
.term.is-chat-fullscreen .chart-card { display: none; }

.chat-fs-hub { display: none; }

.chat.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding: 28px 40px 40px;
  background: var(--bg);
}
.chat.fullscreen .chat-fs-hub {
  display: flex;
  flex: 0 0 auto;
  margin-bottom: 14px;
  border: 1px solid rgba(148, 197, 255, 0.18);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
}
.chat.fullscreen .chat-log { padding: 24px 0; gap: 14px; }
.chat.fullscreen .msg { max-width: 62%; font-size: 14px; }
.chat.fullscreen .chat-form { padding: 12px 0 0; }
.chat.fullscreen .chat-chips { padding: 12px 0 0; }

/* ─── График на весь экран: чат скрыт ───────── */
.term.is-chart-fullscreen .chat { display: none; }

.chart-card.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 0;
  background: var(--bg);
}
.chart-card.fullscreen .chart-head { flex: 0 0 auto; margin-bottom: 12px; }
.chart-card.fullscreen .term-chart {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.chip:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--on-accent);
}

/* ─── Правая панель ────────────────────────── */
.balance-card {
  margin: 12px 12px 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.balance-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.balance-value {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge-dry {
  padding: 2px 7px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: 6px;
  background: rgba(var(--accent-rgb), 0.12);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.balance-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ─── Стакан ───────────────────────────────── */
.orderbook {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 6px;
}

.ob-head {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 6px;
  padding: 4px 8px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.ob-head span:not(:first-child) { text-align: right; }

.ob-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.ob-row {
  --vol: 0.12;
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 6px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, var(--vol)) 0%,
    rgba(56, 189, 248, calc(var(--vol) * 0.42)) 58%,
    rgba(56, 189, 248, 0) 100%
  );
}
.ob-row span { position: relative; z-index: 1; }
.ob-row span:not(:first-child) { text-align: right; color: var(--muted-3); }

.ob-row .bar {
  position: absolute;
  top: 50%;
  height: 3px;
  right: 0;
  z-index: 0;
  border-radius: 1px;
  transform: translateY(-50%);
}
.ob-asks .ob-row .bar { background: rgba(185, 28, 28, 0.55); }
.ob-bids .ob-row .bar { background: rgba(52, 211, 153, 0.5); }

.ob-asks .ob-row span:first-child { color: var(--loss); }
.ob-bids .ob-row span:first-child { color: var(--profit); }

.ob-mid {
  margin: 6px 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ─── Режим «Авто» ─────────────────────────── */
.auto-status {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.12);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-light);
  text-align: center;
}

.btn-open-order {
  margin: 12px;
  padding: 11px 14px;
  border: 1px solid rgba(30, 58, 138, 0.7);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.72);
  color: #e6e8eb;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.btn-open-order:hover { background: #1e3a8a; transform: translateY(-1px); }
.btn-open-order:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ─── Форма ордера (вылетает справа) ───────── */
.order-form {
  position: fixed;
  top: var(--toolbar-h);
  right: 0;
  bottom: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: 340px;
  max-width: 92vw;
  border-left: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.78);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.55);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform 0.32s ease, visibility 0.32s ease;
}
.order-form.is-open { transform: translateX(0); visibility: visible; }

.of-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.of-badge {
  padding: 2px 7px;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: 6px;
  background: rgba(var(--accent-rgb), 0.12);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

.of-close {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.of-close:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.5); }

.of-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 14px;
}

.of-field { display: flex; flex-direction: column; gap: 6px; }
.of-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.of-label b {
  margin-left: 4px;
  color: var(--accent);
  letter-spacing: 0;
  font-size: 12px;
}

.of-field input[type="number"],
.of-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}
.of-field input[type="number"]:focus,
.of-field select:focus { border-color: rgba(var(--accent-rgb), 0.6); }

.of-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 10px 0;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.of-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg-2);
  border-radius: 50%;
  background: #1e3a8a;
  box-shadow: 0 0 0 1px rgba(30, 58, 138, 0.45);
  cursor: pointer;
}
.of-field input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--bg-2);
  border-radius: 50%;
  background: #1e3a8a;
  cursor: pointer;
}
.of-field input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 3px;
  background: var(--border);
}

.of-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
}

.seg-btn {
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--card); color: var(--text); }
.seg-btn.is-long.is-active { background: var(--profit); color: var(--on-profit); }
.seg-btn.is-short.is-active { background: var(--loss); color: var(--on-loss); }

.input-unit { display: flex; gap: 6px; }
.input-unit input { flex: 1 1 auto; min-width: 0; }

.unit-btn {
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.unit-btn:hover { color: var(--text); }
.unit-btn.is-active {
  border-color: rgba(30, 58, 138, 0.65);
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
}

.of-summary {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}
.of-summary b { color: var(--text); font-variant-numeric: tabular-nums; }

.of-submit {
  margin-top: 2px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.2s ease;
}
.of-submit.is-long { background: var(--profit); color: var(--on-profit); }
.of-submit.is-short { background: var(--loss); color: var(--on-loss); }
.of-submit:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ─── Пустые состояния / вспомогательное ───── */
.pair-empty,
.feed-empty {
  padding: 14px 10px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ─── Toasts ───────────────────────────────── */
.toasts {
  position: fixed;
  right: 16px;
  /* Выше кнопки «Открыть ордер» (12px margin + 40px высота + 16px зазор),
     иначе тост ложится текстом на подпись основной кнопки. */
  bottom: 68px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.toast {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 12px 32px rgba(var(--shadow-rgb), 0.45);
  font-size: 12.5px;
  line-height: 1.5;
  animation: toast-in 0.25s ease;
}
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease, transform 0.3s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Адаптив ──────────────────────────────── */
@media (max-width: 1280px) {
  .term { --left-w: 232px; --right-w: 290px; }
  .tb-btn { padding: 6px 10px; font-size: 12px; }
  .bento { grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.85fr); }
}

@media (max-width: 1100px) {
  .term { --left-w: 212px; --right-w: 268px; }
  .chat-hint { display: none; }
  .bento {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 1fr) minmax(320px, 1fr) 200px 220px;
    grid-template-areas:
      "chart"
      "dom"
      "pos"
      "jarvis";
  }
  .pos-split { grid-template-columns: 160px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .chart-hub { flex-wrap: wrap; }
  .hud-btn { flex: 1 1 140px; }
  .msg { max-width: 88%; }
  .tab-body { height: 160px; }
}

/* ─── Телефоны: панели-оверлеи + лента в тулбаре ─────────────
   Раскладка терминала плотная и рассчитана на ≥900px: три колонки
   (212 / 1fr / 268) физически не влезают в 390px. На телефоне обе
   боковые панели сжаты до «язычков», а раскрытая панель
   показывается оверлеем поверх центральной колонки. */
@media (max-width: 700px) {
  .term {
    --handle: 20px;                /* палец должен попадать по «язычку» */
    --panel-overlay-w: min(86vw, 320px);
    --left-w: var(--handle);
    --right-w: var(--handle);
  }

  /* тулбар — горизонтальная лента: кнопки не наезжают друг на друга */
  .toolbar {
    gap: 8px;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tb-left, .tb-center, .tb-right { flex: 0 0 auto; }
  .popover-host,
  #settings-btn { display: none; }
  .tb-logo { font-size: 13px; }
  .mode-btn { padding: 4px 8px; font-size: 12px; }
  .tf-btn { min-width: 30px; padding: 4px 6px; }

  /* раскрытая панель шире своей колонки и накрывает центр */
  .panel { overflow: visible; z-index: 20; }
  .panel-inner,
  .panel--right .panel-inner {
    width: var(--panel-overlay-w);
    background: var(--bg-2);
    box-shadow: 0 18px 48px rgba(var(--shadow-rgb), 0.5);
  }
  .panel--right .panel-inner { border-left: 1px solid var(--border); }

  /* сворачивание: содержимое уезжает за край, «язычок» остаётся в колонке */
  .term.is-left-collapsed .panel--left .panel-inner {
    transform: translateX(calc(var(--handle) - var(--panel-overlay-w)));
  }
  .term.is-right-collapsed .panel--right .panel-inner {
    transform: translateX(calc(var(--panel-overlay-w) - var(--handle)));
  }
}

/* ─── Reduced motion ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .term,
  .panel-inner,
  .order-form,
  .tab-fold { transition: none; }
  .toast { animation: none; }
  .btn-open-order:hover,
  .of-submit:hover { transform: none; }
}





/* ─── Линк «назад на панель» и логотип-ссылка (terminal.html) ────────
   Топбар терминала стал навигацией: ← Панель → dashboard.html,
   ⚡ APEX → dashboard.html, 👤/⚙ → dashboard.html#profile / #settings. */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 13px;
  text-decoration: none; transition: all 0.2s;
  white-space: nowrap;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

.logo-link {
  text-decoration: none; color: inherit;
  display: inline-flex; align-items: center; gap: 8px;
}
.logo-link:hover { opacity: 0.85; }

/* логотип в топбаре — это .tb-logo.logo-link: color: inherit из .logo-link
   не должен перебивать акцентный цвет .tb-logo (правило ниже, специфичность выше) */
.tb-logo.logo-link { color: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 14px; line-height: 1;          /* как было у .tb-icon */
  text-decoration: none; color: var(--text); transition: background 0.2s;
}
.icon-btn:hover { background: rgba(var(--accent-rgb), 0.15); }  /* rgba(30, 64, 175, 0.15) */
