:root {
  --bg: #0f0f14;
  --bg-card: #1a1a22;
  --bg-border: #2a2a35;
  --accent: #3b82f6;
  --text: #e4e4e7;
  --text-dim: #a1a1aa;
  --text-muted: #71717a;
  --success: #22c55e;
  --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--bg-border); }
.btn-danger { background: var(--danger); color: #fff; }

.error-msg {
  color: var(--danger);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

.link {
  color: var(--accent);
  cursor: pointer;
  text-align: center;
  display: block;
  margin-top: 12px;
  font-size: 13px;
}

/* Workspace list */
.ws-list { margin-top: 16px; }
.ws-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ws-card:hover { border-color: var(--accent); }
.ws-card__name { font-weight: 600; }
.ws-card__mode {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}
.ws-card__mode--paper { background: #3b82f620; color: var(--accent); }
.ws-card__mode--live { background: #22c55e20; color: var(--success); }
.ws-card__mode--demo { background: #f59e0b20; color: #f59e0b; }

.ws-status {
  font-size: 10px;
  color: var(--text-muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar__user { font-size: 12px; color: var(--text-dim); }
.topbar__logout { font-size: 12px; color: var(--danger); cursor: pointer; }

/* ── Terminal ── */
.terminal { display: flex; flex-direction: column; height: calc(100vh - 20px); }
.terminal__toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; flex-shrink: 0; flex-wrap: wrap;
}
.terminal__pair {
  background: var(--bg-card); border: 1px solid var(--bg-border);
  color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 13px;
}
.terminal__tfs { display: flex; gap: 2px; }
.tf-btn {
  background: none; border: 1px solid var(--bg-border); color: var(--text-dim);
  padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.tf-btn--active { background: var(--accent); color: #fff; border-color: var(--accent); }
.terminal__price { font-size: 16px; font-weight: 700; margin-left: auto; }
.terminal__chart { flex: 1; min-height: 300px; }

/* ── Full width for terminal ── */
.terminal #app, #app:has(.terminal) { max-width: 100%; padding: 10px; }

/* Data table */
.data-table { max-height: 60vh; overflow-y: auto; }

@media (max-width: 768px) {
  #app { max-width: 100%; padding: 10px; }
  .terminal__chart { min-height: 250px; }
}

/* Terminal fullwidth mode */
body.terminal-mode #app { max-width: 100%; }

/* Phase 3: tabs, signals, profile */
.terminal { height: 100vh; }
.terminal__chart { flex: 0 0 50%; min-height: 250px; }
.terminal__tabs {
  display: flex; gap: 0; border-top: 1px solid var(--bg-border);
  background: var(--bg-card); flex-shrink: 0;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 8px 4px; font-size: 11px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn--active { color: var(--accent); border-bottom-color: var(--accent); }
.terminal__panel { flex: 1; overflow-y: auto; padding: 8px; min-height: 100px; }

.empty-state { color: var(--text-muted); text-align: center; padding: 24px; font-size: 12px; }

.sig-card {
  background: var(--bg-card); border: 1px solid var(--bg-border);
  border-radius: 6px; padding: 8px 10px; margin-bottom: 6px;
}
.sig-row1 { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.sig-row2 { display: flex; align-items: center; gap: 8px; font-size: 11px; margin-top: 4px; }
.sig-tf { color: var(--text-muted); font-size: 10px; }
.sig-tag {
  font-size: 9px; background: var(--bg-border); color: var(--text-dim);
  padding: 1px 4px; border-radius: 3px; font-weight: 600;
}
.sig-conf {
  background: var(--bg-border); color: #fff; padding: 1px 6px;
  border-radius: 3px; font-weight: 600; font-size: 10px;
}
.sig-conf--mid { background: #f59e0b; }
.sig-conf--high { background: var(--success); }
.sig-time { color: var(--text-muted); font-size: 10px; margin-left: auto; }
.sig-status {
  font-size: 9px; padding: 2px 6px; border-radius: 3px;
  background: var(--bg-border); color: var(--text-dim); font-weight: 600;
}
.sig-status--accepted { background: var(--accent); color: #fff; }
.sig-status--rejected { background: var(--danger); color: #fff; }
.sig-status--risk_rejected { background: #f59e0b; color: #fff; }

.sig-actions { display: flex; gap: 4px; }
.sig-btn {
  width: 24px; height: 24px; border: none; border-radius: 4px;
  font-size: 11px; cursor: pointer; font-weight: 700;
}
.sig-btn--accept { background: var(--success); color: #fff; }
.sig-btn--reject { background: var(--danger); color: #fff; }

.profile-section { padding: 8px; }
.profile-section textarea {
  width: 100%; padding: 8px; background: var(--bg-card);
  border: 1px solid var(--bg-border); border-radius: 4px; color: var(--text);
}

/* ── Profile panel ── */
.terminal__chart { flex: 0 0 55%; }
.terminal__tabs { flex-shrink: 0; }
.terminal__panel { flex: 1; overflow-y: auto; padding: 4px 6px; min-height: 120px; }

/* ── Profile redesign ── */
.prof { display: flex; flex-direction: column; gap: 8px; }
.prof-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  padding: 10px 12px;
}
.prof-card-title {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase;
  margin-bottom: 8px;
}
.prof-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.prof-lbl {
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.prof-unit { font-size: 11px; color: var(--text-muted); }
.prof-tip  { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.prof-tip--rec { color: #f59e0b; }
.prof-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; line-height: 1.5; }
.prof-mode-hint { font-size: 11px; color: var(--text-dim); }
.prof-conf-bar {
  display: inline-block; width: 80px; height: 5px;
  background: var(--bg-border); border-radius: 3px; overflow: hidden; vertical-align: middle;
}
.prof-conf-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, #34d399 0%, #f59e0b 60%, #ef4444 100%);
  border-radius: 3px; transition: width .2s;
}
.prof-gap  { flex: 1; }
.prof-sel {
  padding: 3px 6px; background: var(--bg-body);
  border: 1px solid var(--bg-border); border-radius: 4px;
  color: var(--text); font-size: 11px; cursor: pointer;
}
.prof-sel option {
  background: #1e2030;
  color: #e2e8f0;
}
.prof-sel--wide { min-width: 220px; }
.prof-num {
  width: 44px; padding: 3px 5px; text-align: center;
  background: var(--bg-body); border: 1px solid var(--bg-border);
  border-radius: 4px; color: var(--text); font-size: 11px;
}
.prof-filter {
  width: 90px; padding: 3px 6px;
  background: var(--bg-body); border: 1px solid var(--bg-border);
  border-radius: 4px; color: var(--text); font-size: 11px;
}
.prof-btn {
  padding: 4px 10px; font-size: 11px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--bg-border);
  background: var(--bg-body); color: var(--text-dim);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.prof-btn:hover { background: var(--bg-hover); color: var(--text); }
.prof-btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.prof-btn--primary:hover { opacity: .85; }
.prof-btn--accent {
  background: rgba(245,158,11,.12); color: #f59e0b; border-color: rgba(245,158,11,.3);
}
.prof-btn--accent:hover { background: rgba(245,158,11,.22); }
.prof-count {
  background: var(--accent); color: #fff;
  padding: 2px 7px; border-radius: 4px; font-weight: 700; font-size: 11px;
}
/* keep old ctl classes for backward compat */
.prof-top { display: flex; flex-direction: column; gap: 4px; }
.prof-ctl { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 10px; }
.prof-ctl label { color: var(--text-dim); margin: 0; font-size: 10px; }
.prof-ctl select, .prof-ctl input[type=number], .prof-ctl input[type=text] {
  padding: 3px 5px; background: var(--bg-card);
  border: 1px solid var(--bg-border); border-radius: 3px;
  color: var(--text); font-size: 10px;
}
.prof-hint { font-size: 10px; color: var(--text-muted); }
.slots-count {
  background: var(--accent); color: #fff;
  padding: 1px 6px; border-radius: 3px; font-weight: 700; font-size: 11px;
}
.btn-sm {
  padding: 3px 8px; border: 1px solid var(--bg-border);
  background: var(--bg-card); color: var(--text-dim);
  border-radius: 3px; font-size: 10px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--bg-border); color: var(--text); }
.btn-primary-sm { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary-sm:hover { background: #2563eb; }
.btn-danger-sm { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-sm:hover { background: #dc2626; filter: brightness(0.9); }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: var(--text-muted); padding: 0 2px;
}
.btn-icon:hover { color: var(--danger); }

.slots-grid {
  flex: 1; overflow-y: auto;
  border: 1px solid var(--bg-border); border-radius: 4px;
}
.slots-table {
  width: 100%; border-collapse: collapse; font-size: 10px;
}
.slots-table th {
  background: var(--bg-card); position: sticky; top: 0; z-index: 1;
  padding: 3px 6px; text-align: left; color: var(--text-dim);
  font-weight: 600; border-bottom: 1px solid var(--bg-border);
  cursor: pointer; user-select: none;
}
.slots-table th:hover { color: var(--accent); }
.slots-table td { padding: 2px 6px; border-bottom: 1px solid rgba(42,42,53,0.2); }
.slots-table tr:hover td { background: rgba(255,255,255,0.02); }
.col-sym { min-width: 60px; }
.sym-cell { font-weight: 600; color: var(--text); cursor: pointer; }
.sym-cell:hover { color: var(--accent); }
.sym-row.row-black { opacity: 0.4; }
.tf-col { text-align: center; cursor: pointer; min-width: 32px; }
.tf-col:hover { color: var(--accent); }
.num { text-align: right; color: var(--text-dim); font-family: monospace; font-size: 10px; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.slot-chk {
  width: 13px; height: 13px; cursor: pointer; accent-color: var(--accent);
}

/* ── Table alignment fix ── */
.slots-table th, .slots-table td { vertical-align: middle; }
.slots-table th.tf-col, .slots-table th:last-child { text-align: center; }
.slots-table td.chk-cell { text-align: center; }
.slots-table th.num, .slots-table td.num { text-align: right; }
.slots-table th.sort-th { text-align: right; }
.slots-table th.col-sym { text-align: left; }
.slots-table td.sym-cell { text-align: left; }

/* ── Market modal ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg); border: 1px solid var(--bg-border);
  border-radius: 8px; width: 90%; max-width: 900px; max-height: 85vh;
  display: flex; flex-direction: column;
}
.auto-mode-tabs {
  display: flex; gap: 4px; background: var(--bg-body);
  border: 1px solid var(--bg-border); border-radius: 6px; padding: 3px;
}
.auto-mode-tab {
  flex: 1; padding: 6px 10px; font-size: 11px; border-radius: 4px;
  border: none; background: transparent; color: var(--text-dim); cursor: pointer;
  transition: background .12s, color .12s;
}
.auto-mode-tab:hover { color: var(--text); }
.auto-mode-tab--active {
  background: var(--bg-card); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.auto-hint-box {
  background: var(--bg-body); border: 1px solid var(--bg-border);
  border-radius: 6px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.auto-hint-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); }
.auto-hint-badge {
  font-size: 10px; font-weight: 700; padding: 1px 7px;
  border-radius: 3px; white-space: nowrap;
}
.auto-hint-badge--green  { background: rgba(52,211,153,.15); color: #34d399; }
.auto-hint-badge--yellow { background: rgba(245,158,11,.15); color: #f59e0b; }
.auto-hint-badge--orange { background: rgba(249,115,22,.15); color: #f97316; }
.auto-hint-badge--red    { background: rgba(239,68,68,.15);  color: #ef4444; }
.modal-head {
  padding: 12px 16px; border-bottom: 1px solid var(--bg-border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 14px;
}
.modal-ctl {
  padding: 8px 16px; display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid var(--bg-border); font-size: 11px;
}
.modal-ctl label { color: var(--text-dim); }
.modal-ctl select {
  padding: 4px 8px; background: var(--bg-card);
  border: 1px solid var(--bg-border); border-radius: 4px;
  color: var(--text); font-size: 11px;
}
.modal-body {
  flex: 1; overflow-y: auto; padding: 0;
}
.modal-body .slots-table td, .modal-body .slots-table th { padding: 4px 10px; }

/* ── Sort indicators + row toggle ── */
.sort-ind {
  font-size: 9px; color: var(--text-muted); margin-left: 3px;
  display: inline-block; transition: color 0.15s;
}
.sort-ind--active { color: var(--accent); font-weight: 700; }
.slots-table th.sort-th:hover .sort-ind { color: var(--text); }
.slots-table th.mkt-sort, .slots-table th.sort-th { cursor: pointer; user-select: none; }
.row-toggle-col { width: 24px; }
.row-toggle {
  cursor: pointer; text-align: center; user-select: none;
  color: var(--text-muted); font-size: 14px;
}
.row-toggle:hover { color: var(--accent); }
.sym-cell { cursor: default; }

/* ═══════════════════════════════════════════════════════
   Backtest Lab — full-width layout (body.backtest-mode)
   ═══════════════════════════════════════════════════════ */

body.backtest-mode #app { max-width: 100%; padding: 0; }
body.backtest-mode      { background: var(--bg); }

/* Top bar */
body.backtest-mode .topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: var(--bg-card);
    border-bottom: 1px solid var(--bg-border);
    position: sticky; top: 0; z-index: 20;
}
body.backtest-mode .topbar__user { font-weight: 600; font-size: 14px; }
body.backtest-mode .topbar__logout {
    color: var(--accent); cursor: pointer; font-size: 12px;
}
body.backtest-mode .topbar__logout:hover { text-decoration: underline; }

/* Main grid */
.bt-wrapper {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 12px; padding: 12px;
    height: calc(100vh - 45px);
}

.bt-side {
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: 6px; padding: 14px;
    overflow-y: auto;
}
.bt-main {
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: 6px; padding: 14px;
    overflow-y: auto;
    display: flex; flex-direction: column;
}

/* Mode tabs at top of side panel */
.bt-mode-tabs {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    gap: 4px; margin-bottom: 14px;
}
.bt-mode-tab {
    padding: 7px 4px; background: var(--bg); color: var(--text-dim);
    border: 1px solid var(--bg-border); border-radius: 4px;
    font-size: 11px; font-weight: 600; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bt-mode-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bt-mode-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text); }
.bt-mode-panel.hidden { display: none; }

/* Section titles */
.bt-section-title {
    font-size: 11px; text-transform: uppercase; color: var(--text-dim);
    letter-spacing: 0.5px; margin: 10px 0 6px;
    padding-bottom: 4px; border-bottom: 1px solid var(--bg-border);
}

/* Form elements inside side panel */
.bt-side .form-group { margin-bottom: 10px; }
.bt-side .form-group label {
    display: block; font-size: 11px; color: var(--text-dim);
    margin-bottom: 4px; font-weight: 500;
}
.bt-side input[type="text"],
.bt-side input[type="number"],
.bt-side select {
    width: 100%; padding: 6px 8px; font-size: 12px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--bg-border); border-radius: 4px;
}
.bt-side input:focus, .bt-side select:focus {
    outline: none; border-color: var(--accent);
}

/* Interval pills row */
.bt-iv-row {
    display: flex; flex-wrap: wrap; gap: 4px;
}
.bt-iv {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border: 1px solid var(--bg-border); border-radius: 14px;
    font-size: 11px; cursor: pointer; background: var(--bg); color: var(--text);
    user-select: none;
}
.bt-iv input { margin: 0; width: 12px; height: 12px; cursor: pointer; }
.bt-iv:has(input:checked) {
    background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Symbol box */
.bt-symbols-box { display: flex; flex-direction: column; gap: 6px; }
.bt-sym-actions { display: flex; gap: 4px; }
.bt-sym-actions .btn-sm { flex: 1; }
.bt-sym-list {
    max-height: 200px; overflow-y: auto;
    border: 1px solid var(--bg-border); border-radius: 4px;
    padding: 2px; background: var(--bg);
}
.bt-sym-item {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 6px; font-size: 11px; cursor: pointer;
    border-radius: 3px;
}
.bt-sym-item:hover { background: var(--bg-hover); }
.bt-sym-item input[type="checkbox"] {
    margin: 0; width: 13px; height: 13px; cursor: pointer;
    flex-shrink: 0;
}
.bt-sym-item > span:first-of-type { flex: 1; }
.bt-sym-cnt { color: var(--text-muted); font-size: 10px; }
.bt-sym-count {
    font-size: 11px; color: var(--text-dim);
    text-align: right; padding: 2px 4px;
}

.bt-run-status {
    margin-top: 10px; font-size: 11px; padding: 6px;
    border-radius: 3px; min-height: 20px;
}
.bt-run-status.ok  { color: var(--success); background: rgba(34,197,94,0.08); }
.bt-run-status.err { color: var(--danger);  background: rgba(239,68,68,0.08); }

.info-block {
    font-size: 11px; color: var(--text-dim);
    padding: 8px 10px; background: var(--bg);
    border-left: 3px solid var(--accent); margin-bottom: 10px;
    border-radius: 2px; line-height: 1.4;
}
.opt-grid-hint { font-size: 10px; color: var(--text-muted); margin: 6px 0 2px; }
.bt-side .form-group input + .opt-grid-hint { margin-top: 8px; }

/* Main panel tabs */
.bt-main-tabs {
    display: flex; gap: 4px; margin-bottom: 10px;
    border-bottom: 1px solid var(--bg-border); padding-bottom: 8px;
}
.bt-main-tab {
    padding: 6px 14px; background: var(--bg); color: var(--text-dim);
    border: 1px solid var(--bg-border); border-radius: 4px;
    font-size: 12px; cursor: pointer; font-weight: 500;
}
.bt-main-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bt-main-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

#bt-runs, #opt-runs { flex: 1; overflow: auto; }
#bt-runs.hidden, #opt-runs.hidden { display: none; }
.bt-empty {
    text-align: center; color: var(--text-muted);
    padding: 60px 20px; font-size: 13px;
}

/* Run tables */
.bt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bt-table th, .bt-table td {
    padding: 6px 8px; border-bottom: 1px solid var(--bg-border);
    text-align: left; vertical-align: middle;
}
.bt-table th {
    position: sticky; top: 0; background: var(--bg-card);
    font-weight: 600; color: var(--text-dim);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px;
    z-index: 1;
}
.bt-table td.num, .bt-table th.num {
    text-align: right; font-variant-numeric: tabular-nums;
}
.bt-table td.nowrap { white-space: nowrap; }
.bt-table tr[data-run], .bt-table tr[data-opt] { cursor: pointer; }
.bt-table tr[data-run]:hover, .bt-table tr[data-opt]:hover { background: var(--bg-hover); }
.bt-s-ok  { color: var(--success); font-weight: 600; }
.bt-s-err { color: var(--danger);  font-weight: 600; }
.bt-s-run { color: var(--accent);  font-weight: 600; }
.profit-pos { color: var(--success); }
.profit-neg { color: var(--danger); }

/* Detail overlay modal */
.bt-detail {
    position: fixed; inset: 0; background: rgba(0,0,0,0.78);
    z-index: 100; display: flex; padding: 20px; overflow: auto;
}
.bt-detail.hidden { display: none; }
.bt-detail-inner {
    background: var(--bg-card); border-radius: 8px;
    max-width: 1400px; width: 100%; margin: auto; padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.bt-detail-head {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--bg-border);
    padding-bottom: 12px; margin-bottom: 16px;
}
.bt-detail-head h3 { margin: 0; font-size: 16px; }
.bt-detail-inner h3 { margin: 0 0 12px; font-size: 15px; }
.bt-detail-inner h4 { margin: 18px 0 8px; font-size: 12px; }

.bt-metrics-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px; margin-bottom: 12px;
}
.bt-metric {
    background: var(--bg); border: 1px solid var(--bg-border);
    border-radius: 4px; padding: 10px 12px;
}
.bt-metric-label {
    font-size: 10px; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: 0.3px;
}
.bt-metric-val {
    font-size: 15px; font-weight: 600; margin-top: 3px;
    font-variant-numeric: tabular-nums;
}
.bt-slots-wrap, .bt-trades-wrap {
    max-height: 320px; overflow: auto;
    border: 1px solid var(--bg-border); border-radius: 4px;
    margin-bottom: 14px; background: var(--bg);
}
.bt-trades .long  { color: var(--success); font-weight: 600; }
.bt-trades .short { color: var(--danger);  font-weight: 600; }
.tp-dot {
    display: inline-block; width: 14px; height: 14px; line-height: 14px;
    text-align: center; border-radius: 2px; background: var(--success);
    color: #fff; font-size: 9px; margin-right: 1px;
}
.bt-json {
    font-family: monospace; font-size: 11px;
    background: var(--bg); padding: 10px; border-radius: 4px;
    border: 1px solid var(--bg-border); overflow: auto; max-height: 180px;
    color: var(--text);
}
.bt-inline { font-family: monospace; font-size: 10px; color: var(--text-dim); }
.btn-danger-sm {
    background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger-sm:hover { filter: brightness(0.9); }

/* Verdict + action bar + hints in modal */
.verdict {
    display: inline-block; margin-left: 10px;
    padding: 2px 10px; border-radius: 10px;
    font-size: 12px; font-weight: 600;
}
.verdict.good { background: rgba(34,197,94,0.15); color: var(--success); }
.verdict.bad  { background: rgba(239,68,68,0.15); color: var(--danger);  }
.bt-action-bar {
    background: var(--bg); border-left: 3px solid var(--accent);
    padding: 10px 14px; border-radius: 4px; margin-bottom: 14px;
}
.bt-action-hint { font-size: 12px; line-height: 1.5; color: var(--text); }
.bt-action-hint code {
    background: var(--bg-card); padding: 1px 5px; border-radius: 2px;
    font-family: monospace; font-size: 11px;
}
.bt-action-buttons { display: flex; gap: 8px; margin-top: 10px; }
.bt-action-buttons .btn { padding: 6px 14px; font-size: 12px; }
.metric-hint {
    display: inline-block; width: 14px; height: 14px; line-height: 14px;
    text-align: center; border-radius: 50%;
    background: var(--bg-hover); color: var(--text-muted);
    font-size: 10px; cursor: help; font-weight: 700;
}
.dir-long  { color: var(--success); font-weight: 600; }
.dir-short { color: var(--danger);  font-weight: 600; }

/* List hint + clickable row + row action buttons */
.list-hint {
    padding: 8px 10px; margin-bottom: 8px;
    background: rgba(59,130,246,0.08);
    border-left: 3px solid var(--accent);
    border-radius: 3px;
    font-size: 12px; color: var(--text-dim);
}
.bt-list-clickable tbody tr { transition: background 0.12s; }
.bt-list-clickable tbody tr:hover {
    background: var(--bg-hover);
    box-shadow: inset 3px 0 0 var(--accent);
}
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.row-open {
    padding: 4px 10px !important; font-size: 11px !important;
    font-weight: 600; white-space: nowrap;
}
.row-open:disabled {
    opacity: 0.4; cursor: not-allowed;
}
.btn-icon-del {
    background: transparent; border: 1px solid var(--bg-border);
    color: var(--text-muted); width: 24px; height: 24px;
    border-radius: 3px; cursor: pointer; font-size: 11px;
    padding: 0; line-height: 1;
}
.btn-icon-del:hover {
    background: var(--danger); color: #fff; border-color: var(--danger);
}

/* Auto-select summary + action blocks */
.as-summary {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: 6px; margin-bottom: 14px;
}
.as-summary.ok   { background: rgba(34,197,94,0.10);  border-left: 4px solid var(--success); }
.as-summary.warn { background: rgba(234,179,8,0.10);  border-left: 4px solid #eab308; }
.as-summary-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.as-summary-title { font-size: 13px; font-weight: 600; }
.as-summary-sub   { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.as-action-block {
    margin: 14px 0; padding: 14px 16px;
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.30);
    border-radius: 6px;
}
.as-action-block.applied {
    background: rgba(34,197,94,0.08);
    border-color: rgba(34,197,94,0.30);
}
.as-action-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.as-action-body  { font-size: 12px; color: var(--text-dim); line-height: 1.4; margin-bottom: 10px; }
.as-apply-btn    { padding: 8px 18px !important; font-size: 13px !important; font-weight: 600; }

.as-expand-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin-bottom: 14px;
}
.as-expand-card {
    background: var(--bg); border: 1px solid var(--bg-border);
    border-radius: 5px; padding: 12px; display: flex; flex-direction: column;
}
.as-expand-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.as-expand-sub   { font-size: 11px; color: var(--text-dim); flex: 1; margin-bottom: 10px; line-height: 1.4; }
.as-expand-btn   { padding: 6px 12px !important; font-size: 11px !important; }

@keyframes pulseKF {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.7); }
    50%      { box-shadow: 0 0 0 10px rgba(59,130,246,0); }
}
.pulse { animation: pulseKF 1s ease-in-out 2; }

.as-expand-hint {
    font-size: 12px; color: var(--text-dim);
    margin-bottom: 12px; line-height: 1.5;
    padding: 8px 12px; background: var(--bg); border-radius: 4px;
}
.as-expand-hint b { color: var(--accent); }

.as-expand-card { position: relative; }
.as-expand-card.recommended {
    border-color: #eab308;
    box-shadow: 0 0 0 1px #eab308, 0 0 12px rgba(234,179,8,0.15);
}
.as-badge {
    position: absolute; top: -9px; right: 10px;
    background: #eab308; color: #1a1510;
    font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 10px; letter-spacing: 0.3px;
}
.as-expand-card .as-expand-btn {
    margin-top: auto;
}

/* Quick-start block */
.quick-start-block {
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(147,51,234,0.15));
    border: 1px solid rgba(59,130,246,0.40);
    border-radius: 6px; padding: 12px;
    margin-bottom: 14px;
}
.quick-start-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.quick-start-desc  { font-size: 11px; color: var(--text-dim); line-height: 1.4; margin-bottom: 10px; }
.quick-start-btn   { width: 100%; padding: 9px !important; font-size: 12px !important; font-weight: 600; }

.label-hint {
    font-size: 10px; font-weight: 400;
    color: var(--text-muted); margin-left: 4px;
}

.slot-optimize-btn { padding: 3px 8px !important; font-size: 10px !important; white-space: nowrap; }
.slots-optimize-all {
    display: flex; align-items: center; gap: 10px;
    margin-top: 10px; padding: 10px 12px;
    background: var(--bg); border: 1px dashed var(--bg-border);
    border-radius: 4px;
}
.slots-optimize-hint { font-size: 10px; color: var(--text-muted); }

.exec-target-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 500;
    padding: 8px 10px; border: 1px dashed var(--bg-border);
    border-radius: 4px; cursor: pointer;
    background: var(--bg);
}
.exec-target-label:has(input:checked) {
    border-style: solid; border-color: #10b981;
    background: rgba(16,185,129,0.08);
}
.exec-target-cb { margin: 0; }
.exec-target-hint { font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.exec-target-hint code {
    background: var(--bg-hover); padding: 1px 5px; border-radius: 2px;
    font-family: monospace; font-size: 10px;
}
.exec-badge {
    display: inline-block; margin-left: 4px; font-size: 11px;
    opacity: 0.7;
}
.exec-badge.local { color: #10b981; }
.exec-badge.vps   { color: var(--text-muted); }

.params-cell {
    font-family: monospace; font-size: 10px;
    color: var(--text-dim); white-space: nowrap;
}
.dim { color: var(--text-muted); font-style: italic; }

/* Phase 5 — paper trading tabs */
.bal-bar {
    display: flex; gap: 10px; flex-wrap: wrap;
    padding: 8px 10px; background: var(--bg-card);
    border: 1px solid var(--bg-border); border-radius: 4px;
    margin-bottom: 10px;
}
.bal-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 2px 10px; border-right: 1px solid var(--bg-border);
}
.bal-item:last-child { border-right: none; }
.bal-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.bal-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hist-stats {
    display: flex; gap: 10px;
    padding: 8px 10px; margin-bottom: 10px;
    background: rgba(59,130,246,0.05);
    border-left: 3px solid var(--accent);
    border-radius: 3px;
}
.phase5-h4 {
    font-size: 11px; text-transform: uppercase; color: var(--text-dim);
    letter-spacing: 0.5px; margin: 10px 0 4px; padding-bottom: 3px;
    border-bottom: 1px solid var(--bg-border);
}
.trades-tbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.trades-tbl th, .trades-tbl td {
    padding: 6px 10px; border-bottom: 1px solid var(--bg-border);
    border-right: 1px solid rgba(255,255,255,0.04);
    text-align: left; vertical-align: middle; line-height: 1.5;
}
.trades-tbl th:last-child, .trades-tbl td:last-child { border-right: none; }
.trades-tbl th {
    background: var(--bg-card);
    font-weight: 600; color: var(--text-dim);
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
    position: sticky; top: 0; border-bottom: 2px solid rgba(255,255,255,0.08);
}
.trades-tbl td.num, .trades-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.trades-tbl td.nowrap { white-space: nowrap; }
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-muted); font-size: 12px;
}

/* Scanner status card on empty Signals tab */
.scan-status {
    max-width: 720px; margin: 30px auto;
    padding: 20px 24px; border-radius: 8px;
    border: 1px solid var(--bg-border); background: var(--bg-card);
}
.scan-status.ok   { border-left: 4px solid var(--success); }
.scan-status.warn { border-left: 4px solid #eab308; }
.scan-status h3   { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.scan-status p    { margin: 6px 0; font-size: 12px; line-height: 1.6; color: var(--text); }
.scan-status .scan-hint {
    margin-top: 12px; padding-top: 10px;
    border-top: 1px solid var(--bg-border);
    color: var(--text-dim); font-size: 11px;
}

/* Signals — table + status pills + detail */
.sig-summary {
    display: flex; gap: 12px; padding: 10px 12px;
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: 4px; margin-bottom: 8px;
    font-size: 12px;
}
.sig-summary-item { padding: 2px 8px; border-radius: 3px; background: var(--bg); }
.sig-tip {
    font-size: 12px; line-height: 1.5; padding: 8px 12px;
    background: rgba(59,130,246,0.08); border-left: 3px solid var(--accent);
    border-radius: 3px; margin-bottom: 10px; color: var(--text);
}
.sig-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sig-table th, .sig-table td {
    padding: 6px 8px; border-bottom: 1px solid var(--bg-border);
    text-align: left; vertical-align: middle;
}
.sig-table th {
    font-size: 10px; text-transform: uppercase; color: var(--text-dim);
    letter-spacing: 0.3px; background: var(--bg-card);
    position: sticky; top: 0;
}
.sig-table td.num, .sig-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sig-table td.nowrap { white-space: nowrap; }
.sig-table tr.sig-row { cursor: pointer; transition: background 0.1s; }
.sig-table tr.sig-row:hover { background: var(--bg-hover); }

.clickable-row { cursor: pointer; transition: background 0.1s; }
.clickable-row:hover { background: rgba(59,130,246,0.06); }
.row--selected { background: rgba(245,158,11,0.10) !important; outline: 1px solid rgba(245,158,11,0.35); }
.row--selected:hover { background: rgba(245,158,11,0.15) !important; }

/* Distance badges in active positions table */
.dist-sl { color: #4ade80; }
.dist-sl--warn   { color: #fbbf24; }
.dist-sl--danger { color: #f87171; }
.dist-tp { color: #34d399; }

.conf-pill {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
}
.conf-high { background: rgba(34,197,94,0.20); color: var(--success); }
.conf-mid  { background: rgba(234,179,8,0.20); color: #eab308; }
.conf-low  { background: rgba(148,163,184,0.20); color: var(--text-muted); }

.sig-st { font-size: 11px; padding: 1px 6px; border-radius: 3px; }
.st-ok    { background: rgba(34,197,94,0.15);  color: var(--success); }
.st-rej   { background: rgba(239,68,68,0.12);  color: #ef4444; }
.st-conv  { background: rgba(59,130,246,0.15); color: var(--accent); }
.st-exp   { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.st-wait  { background: rgba(234,179,8,0.15);  color: #eab308; }
.st-rej-bg{ background: rgba(239,68,68,0.10); padding: 6px 8px; border-radius: 3px; }

.sig-detail.hidden { display: none; }
.sig-detail-box {
    padding: 10px 14px; background: var(--bg);
    border-left: 3px solid var(--accent); margin: 4px 0;
    border-radius: 3px;
}
.sig-detail-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px 16px; font-size: 11px; line-height: 1.6;
}
.sig-detail-row { grid-column: span 2; }
.sig-detail-grid code {
    background: var(--bg-card); padding: 1px 5px; border-radius: 2px;
    font-family: monospace; font-size: 10px;
}
.dim { color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════
   TWO-COLUMN TERMINAL LAYOUT v2
   Левая (44%): табы + контент   Правая (56%): чарт + метрики
═══════════════════════════════════════════════════════ */
body.terminal-mode #app {
  max-width: 100% !important;
  padding: 0 !important;
  height: 100vh;
  overflow: hidden;
}
.terminal {
  display: flex !important;
  flex-direction: row !important;
  height: 100vh !important;
  overflow: hidden;
  gap: 0;
}

/* ── Левая колонка ── */
.terminal__left {
  width: 52%;
  min-width: 420px;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--bg-border);
  overflow: hidden;
  background: var(--bg);
}
.terminal__left-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
}
.btn-back {
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1;
  background: none;
  border: none;
  user-select: none;
}
.btn-back:hover { color: var(--text); background: var(--bg-border); }
.terminal__brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.terminal__tabs {
  display: flex !important;
  border-top: none !important;
  border-bottom: 1px solid var(--bg-border) !important;
  background: var(--bg-card) !important;
  flex-shrink: 0;
  padding: 0 2px;
  gap: 0;
  flex-wrap: nowrap;
}
.tab-btn {
  flex: 1 !important;
  padding: 11px 4px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.2px !important;
  border-bottom: 2px solid transparent !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  white-space: nowrap;
  background: none !important;
  color: var(--text-dim) !important;
  cursor: pointer;
}
.tab-btn--active { color: var(--accent) !important; border-bottom-color: var(--accent) !important; }
.tab-btn:hover:not(.tab-btn--active) { color: var(--text) !important; }
.terminal__panel {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 12px 14px !important;
  font-size: 13px !important;
  min-height: 0 !important;
}

/* ── Правая колонка ── */
.terminal__right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.terminal__toolbar {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px 12px !important;
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--bg-border) !important;
  flex-shrink: 0 !important;
  flex-wrap: nowrap !important;
}
.terminal__chart {
  flex: 0 0 57% !important;
  min-height: 180px !important;
}
.terminal__metrics {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--bg-border);
  background: var(--bg);
  min-height: 0;
  font-size: 13px;
}

/* ── Единый стиль всех таблиц в терминале ── */
.terminal__panel table {
  font-size: 12px !important;
  font-style: normal !important;
  border-collapse: collapse;
  width: 100%;
}
.terminal__panel table th {
  font-size: 10px !important;
  font-weight: 600 !important;
  font-style: normal !important;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted) !important;
  padding: 6px 8px !important;
  border-bottom: 1px solid var(--bg-border);
  white-space: nowrap;
}
.terminal__panel table td {
  padding: 6px 8px !important;
  font-style: normal !important;
  white-space: nowrap !important;
  border-bottom: 1px solid rgba(42,42,53,0.5);
  vertical-align: middle;
}
.terminal__panel table tr:hover td { background: rgba(255,255,255,0.02); }

/* Символ монеты — приглушённый, не белый */
.sym-col { font-size: 12px !important; font-weight: 600 !important; color: #cbd5e1 !important; letter-spacing: 0.2px; }

/* Порядковый номер сделки */
.trade-num { color: var(--text-muted) !important; font-size: 11px !important; font-weight: 400 !important; min-width: 24px; }

/* Причина — компактно */
.reason-cell { font-size: 11px !important; color: var(--text-dim) !important; white-space: nowrap; }

/* Направление — только стрелка */
.dir-arrow { font-size: 15px !important; text-align: center !important; font-style: normal !important; }
.dir-long { color: #34d399 !important; font-style: normal !important; }
.dir-short { color: #f87171 !important; font-style: normal !important; }

/* Приглушённые цвета PnL */
.profit-pos { color: #34d399 !important; }
.profit-neg { color: #f87171 !important; }

/* Confidence pill */
.conf-pill { padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.conf-high { background: rgba(52,211,153,0.15); color: #34d399; }
.conf-mid  { background: rgba(251,191,36,0.15);  color: #fbbf24; }
.conf-low  { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* Статус сигнала */
.sig-st { white-space: nowrap !important; font-size: 11px !important; padding: 2px 7px; border-radius: 3px; }
.st-ok   { background: rgba(52,211,153,0.12); color: #34d399; }
.st-rej  { background: rgba(248,113,113,0.1);  color: #f87171; }
.st-conv { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.st-exp  { background: rgba(148,163,184,0.1);  color: #94a3b8; }
.st-wait { background: rgba(251,191,36,0.12);  color: #fbbf24; }

/* TP dots */
.tp-dot { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 700;
  background: rgba(59,130,246,0.2); color: #60a5fa; margin-right: 2px; }

/* Кнопки в таблице */
.row-actions { white-space: nowrap; }
.row-actions .btn-sm { padding: 3px 9px !important; font-size: 11px !important; }
.btn-sm { padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--bg-border); background: var(--bg-card); color: var(--text); }
.btn-primary-sm { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.btn-danger-sm  { background: rgba(248,113,113,0.15) !important; color: #f87171 !important; border-color: rgba(248,113,113,0.3) !important; }

/* Заголовки секций */
.phase5-h4 { font-size: 11px !important; margin: 12px 0 6px !important; color: var(--text-muted) !important;
  font-weight: 600 !important; text-transform: uppercase; letter-spacing: 0.4px; }

/* hist-stats */
.hist-stats { display: flex; flex-wrap: wrap; gap: 0;
  background: var(--bg-card); border: 1px solid var(--bg-border); border-radius: 6px;
  overflow: hidden; margin-bottom: 12px; }
.hist-stats .bal-item { flex: 1; min-width: 90px; padding: 8px 12px;
  border-right: 1px solid var(--bg-border); }
.hist-stats .bal-item:last-child { border-right: none; }
.bal-label { font-size: 10px !important; color: var(--text-muted) !important; text-transform: uppercase; letter-spacing: 0.3px; }
.bal-val { font-size: 13px !important; font-weight: 700 !important; }

/* ── Metrics panel (правая нижняя) ── */
.mtr-bar {
  display: flex;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.mtr-item {
  flex: 1;
  min-width: 110px;
  padding: 8px 14px;
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mtr-item:last-child { border-right: none; }
.mtr-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.mtr-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mtr-val small { font-size: 11px; font-weight: 400; color: var(--text-dim); }
.mtr-dd { font-size: 11px; font-weight: 400; }
.mtr-scanner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  padding: 8px 12px;
}
.mtr-scanner-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-right: 4px;
}
.mtr-scanner-label b { color: var(--accent); }
.mtr-scanner label { font-size: 11px; color: var(--text-muted); }
.mtr-scanner select, .mtr-scanner input[type=number] {
  background: var(--bg);
  border: 1px solid var(--bg-border);
  color: var(--text);
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 12px;
}

/* sig-tip (подсказка над таблицей сигналов) */
.sig-tip { font-size: 11px; color: var(--text-muted); padding: 8px 10px;
  background: rgba(234,179,8,0.07); border-left: 2px solid #fbbf24;
  border-radius: 3px; margin-bottom: 8px; line-height: 1.5; }

/* ── TF кнопки и pair select чуть крупнее ── */
.terminal__pair { font-size: 13px !important; padding: 5px 10px !important; }
.tf-btn { font-size: 12px !important; padding: 5px 9px !important; }
.terminal__price { font-size: 17px !important; }

/* Presets */
.preset-row:hover { border-color: var(--accent) !important; }
.preset-row .preset-apply-btn:hover { background: var(--accent); color: #fff; }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — добавлено 2026-05-11
   ════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Сброс body/app */
  #app { max-width: 100% !important; padding: 0 !important; }

  /* Терминал — вертикально вместо горизонтально */
  .terminal {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
  }

  /* Левая колонка — полная ширина, без фиксированной высоты */
  .terminal__left {
    width: 100% !important;
    min-width: 0 !important;
    border-right: none !important;
    border-bottom: 2px solid var(--bg-border) !important;
    height: auto !important;
    max-height: 55vh;
    overflow: hidden;
  }

  /* Панель вкладок — скролл по горизонтали */
  .terminal__tabs {
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Контент панели — скролл */
  .terminal__panel {
    overflow-y: auto !important;
    max-height: calc(55vh - 80px);
  }

  /* Правая колонка — полная ширина */
  .terminal__right {
    width: 100% !important;
    flex: none !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Тулбар — перенос и уменьшение */
  .terminal__toolbar {
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 6px 8px !important;
  }

  /* График меньше на мобиле */
  .terminal__chart {
    flex: none !important;
    height: 250px !important;
    min-height: 200px !important;
  }

  /* Метрики — скролл */
  .terminal__metrics {
    flex: none !important;
    overflow-y: auto !important;
    max-height: 40vh;
    padding: 10px 12px !important;
  }

  /* Metrics bar — перенос */
  .mtr-bar { flex-wrap: wrap !important; }
  .mtr-item {
    min-width: 80px !important;
    flex: 1 1 calc(33% - 2px);
    border-bottom: 1px solid var(--bg-border);
  }

  /* Balance bar */
  .bal-bar { flex-wrap: wrap !important; }
  .bal-item { min-width: 80px; }

  /* Profile */
  .prof { padding: 6px !important; }
  .prof-card { padding: 8px !important; }
  .prof-row { flex-wrap: wrap !important; gap: 4px !important; }
  .prof-btn { min-height: 36px; padding: 6px 12px; }

  /* Presets */
  .preset-row { flex-wrap: wrap !important; }

  /* Slots table — горизонтальный скролл */
  .slots-grid { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }

  /* Кнопки TF чуть крупнее для тача */
  .tf-btn { padding: 6px 10px !important; font-size: 12px !important; }

  /* Заголовок левой панели */
  .terminal__left-head { padding: 8px 10px !important; }
  .terminal__brand { font-size: 13px !important; }

  /* Scanner bar — перенос */
  .mtr-scanner { flex-wrap: wrap !important; gap: 6px !important; }
}

@media (max-width: 480px) {
  /* Совсем маленькие экраны */
  .terminal__chart { height: 200px !important; min-height: 180px !important; }
  .mtr-item { min-width: 70px !important; font-size: 11px !important; }
  .tf-btn { padding: 4px 7px !important; font-size: 11px !important; }
  .tab-btn { font-size: 10px !important; padding: 8px 3px !important; }
  .terminal__price { font-size: 14px !important; }
  .terminal__pair { font-size: 12px !important; }
  .mtr-val { font-size: 12px !important; }
  .mtr-lbl { font-size: 9px !important; }

  /* Левая панель на 480px — чуть меньше */
  .terminal__left { max-height: 50vh; }
  .terminal__panel { max-height: calc(50vh - 80px); }

  /* Метрики */
  .terminal__metrics { max-height: 35vh; }
}

/* Level PnL badges — inline, same line as price */
.lvl-loss         { color: #f87171; font-size: 10px; font-weight: 500; opacity: 0.85; }
.lvl-loss--danger { color: #ff4444; font-weight: 700; opacity: 1; }
.lvl-gain         { color: #4ade80; font-size: 10px; font-weight: 500; opacity: 0.85; }

/* Active positions table — clean uniform look */
.trades-tbl td { font-size: 12px; color: var(--text-primary); }
.trades-tbl .dim { color: var(--text-dim); font-size: 11px; }
.trades-tbl .pos-cur-price { color: #e2e8f0; font-weight: 600; }
.trades-tbl .ts-col { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.trades-tbl tbody tr:hover { background: rgba(255,255,255,0.03); }

/* Signal row selection highlight */
.sig-row { cursor: pointer; transition: background 0.15s; }
.sig-row:hover { background: rgba(255,255,255,0.03); }
.sig-row--selected { background: rgba(245,158,11,0.10) !important; border-left: 3px solid var(--accent) !important; }
.sig-row--selected td:first-child { padding-left: 9px; }

/* Signal detail — human-readable explanation */
.sig-detail-explain { margin: 10px 0 6px; }
.sig-explain-dir { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.sig-explain-htf { font-size: 12px; font-weight: 500; margin-left: 8px; }
.sig-explain-trend { font-size: 11px; margin-left: 6px; }
.sig-explain-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sig-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 500;
    background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
    cursor: help; white-space: nowrap;
}
.sig-tag:hover { background: rgba(255,255,255,0.12); }
.sig-explain-score { font-size: 11px; margin-top: 4px; }
.sig-detail-rejection {
    margin-top: 8px; padding: 6px 10px; border-radius: 6px;
    background: rgba(248,113,113,0.08); border-left: 3px solid #f87171;
    font-size: 11px; color: #f87171;
}
.sig-detail-rejection span { font-weight: 600; }

/* Intent substatus chips */
.st-open  { background: rgba(74,222,128,0.15); color: #4ade80; border-color: rgba(74,222,128,0.3); }
.st-done  { background: rgba(100,116,139,0.15); color: #94a3b8; border-color: rgba(100,116,139,0.2); }

/* ── Auth page ── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-main);
}
.auth-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: 16px;
    padding: 40px 48px;
    min-width: 320px;
    max-width: 400px;
    gap: 0;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.auth-logo { margin-bottom: 20px; }
.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
    letter-spacing: 0.3px;
}
.auth-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    margin: 0 0 28px;
    text-align: center;
}
.auth-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 12px 0 0;
    text-align: center;
}
.btn-google {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
}
.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    color: #3c4043;
    text-decoration: none;
}

/* ── Scanner Runs Panel ── */
.scan-runs-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px 8px;
    margin-bottom: 12px;
    font-size: 12px;
}
.scan-runs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.scan-runs-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.scan-runs-hint { font-size: 11px; }
.scan-runs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.scan-runs-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    padding: 2px 10px 4px 0;
    border-bottom: 1px solid var(--border);
    cursor: default;
}
.scan-runs-table td {
    padding: 3px 10px 3px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    white-space: nowrap;
}
.scan-runs-table tr:last-child td { border-bottom: none; }
.scan-row-fresh td { color: var(--text-primary); }
.scan-found-yes { color: #26c281; font-weight: 700; }
.scan-skip-warn { color: #e5a335; }
.scan-time { font-family: monospace; font-size: 11px; }
.scan-dur  { font-size: 11px; }
.scan-runs-empty { font-size: 11px; }
.scan-regime-cell { display: flex; gap: 5px; flex-wrap: wrap; padding-top: 4px; }
/* Regime badges */
.rg-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    display: inline-block;
    font-family: monospace;
}
.rg-bull { background: rgba(38,194,129,0.15); color: #26c281; }
.rg-bear { background: rgba(239,83,80,0.15);  color: #ef5350; }
.rg-range { background: rgba(120,120,180,0.15); color: #9c9fce; }
.rg-vol  { background: rgba(229,163,53,0.15);  color: #e5a335; }

/* ── Scanner TF breakdown row ── */
.scan-tf-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.tf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(120,120,200,0.1);
    border: 1px solid rgba(120,120,200,0.2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: default;
}
.tf-chip b {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 12px;
}
/* Regime legend inline */
.rg-legend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.5;
    font-size: 10px;
}
.rg-legend .rg-badge {
    padding: 0 3px;
    font-size: 9px;
}

/* ═══════════════════ Analytics Dashboard (Phase 6) ═══════════════════ */
.an-shell { display: flex; flex-direction: column; height: 100%; }
.an-tabs {
    display: flex; gap: 2px; padding: 8px 12px 0;
    border-bottom: 1px solid var(--bg-border);
    flex-shrink: 0; flex-wrap: wrap;
}
.an-tab {
    padding: 5px 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
    border: none; border-bottom: 2px solid transparent;
    background: transparent; color: var(--text-muted); cursor: pointer;
    text-transform: uppercase; transition: color 0.15s, border-color 0.15s;
}
.an-tab:hover { color: var(--text); }
.an-tab--active { color: var(--accent); border-bottom-color: var(--accent); }

.an-panel { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }

.an-section { margin-bottom: 20px; }
.an-sec-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-muted);
    margin-bottom: 8px; padding-bottom: 4px;
    border-bottom: 1px solid var(--bg-border);
}

.an-kpi-row {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.an-kpi {
    background: var(--bg-card); border: 1px solid var(--bg-border);
    border-radius: 6px; padding: 10px 14px; min-width: 110px;
    display: flex; flex-direction: column; gap: 4px;
}
.an-kpi-val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.an-kpi-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.an-filters {
    display: flex; gap: 8px; align-items: center;
    padding: 8px 0 12px; flex-wrap: wrap;
}
.an-filter-btn { padding: 5px 14px; font-size: 12px; }

.an-bar-wrap {
    height: 6px; background: var(--bg-border); border-radius: 3px;
    margin-top: 4px; overflow: hidden;
}
.an-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
.an-bar--ok     { background: var(--success); }
.an-bar--warn   { background: #eab308; }
.an-bar--danger { background: var(--danger); }

.an-risk-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.an-risk-bar-row { font-size: 11px; color: var(--text-muted); }

.an-corr-group {
    display: inline-block; background: rgba(234,179,8,0.12); color: #eab308;
    border-radius: 4px; padding: 4px 10px; font-size: 11px; margin: 3px;
    border: 1px solid rgba(234,179,8,0.25);
}

/* ── Signal Context Panel ── */
.trade-ctx-panel {
    background: #13131a;
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 6px;
    margin: 6px 0 8px;
    overflow: hidden;
    animation: ctx-in 0.15s ease;
}
@keyframes ctx-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.ctx-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(245,158,11,0.07);
    border-bottom: 1px solid rgba(245,158,11,0.15);
    flex-wrap: wrap;
}
.ctx-sym   { font-weight: 700; font-size: 13px; color: #e2e8f0; }
.ctx-badge { background: rgba(99,102,241,0.2); color: #a5b4fc; font-size: 10px; padding: 1px 7px; border-radius: 10px; }
.ctx-score { font-size: 12px; font-weight: 600; }
.ctx-rr    { font-size: 11px; color: #94a3b8; }
.ctx-risk  { font-size: 11px; }
.ctx-close { font-size: 11px; margin-left: auto; }
.ctx-pnl   { font-size: 12px; font-weight: 600; }
.ctx-body  { padding: 8px 12px 10px; }
.ctx-row   { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 11px; }
.ctx-label { color: #64748b; min-width: 40px; }
.ctx-val   { color: #cbd5e1; display: flex; gap: 4px; align-items: center; }
.ctx-tag   { background: rgba(99,102,241,0.15); color: #a5b4fc; border-radius: 4px; padding: 1px 6px; font-size: 10px; }
.ctx-why   { font-size: 11px; color: #94a3b8; line-height: 1.6; margin: 4px 0; }
.ctx-warns { font-size: 11px; color: #fbbf24; line-height: 1.8; margin-top: 4px; }
.regime-volatile   { color: #f59e0b; }
.regime-range      { color: #60a5fa; }
.regime-trend_bull { color: #34d399; }
.regime-trend_bear { color: #f87171; }

/* ── Daily chart & day separators ───────────────────── */
.daily-chart-wrap {
    overflow-x: auto;
    padding: 10px 12px 4px;
    background: rgba(15,23,42,0.5);
    border-bottom: 1px solid #1e293b;
    margin-bottom: 2px;
}
.daily-chart-wrap svg { display: block; overflow: visible; }
.day-bar { cursor: pointer; transition: opacity .15s; }
.day-bar:hover { opacity: 1 !important; }
.day-sep-row td {
    background: rgba(30,41,59,0.7) !important;
    padding: 5px 10px !important;
    border-top: 1px solid #1e293b !important;
    border-bottom: none !important;
}
.day-sep-date {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    margin-right: 10px;
}
.day-sep-stats {
    font-size: 11px;
    color: #64748b;
}

/* ── Equity curve ──────────────────────────────────── */
.equity-wrap {
    padding: 10px 12px 6px;
    background: rgba(15,23,42,0.5);
    border-bottom: 1px solid #1e293b;
}
.equity-title {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.equity-range { color: #94a3b8; }
.day-bal { color: #64748b; font-size: 11px; }
