@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fira+Code:wght@400;500;600&display=swap');

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

:root {
  --bg:       #0d0f12;
  --bg2:      #111418;
  --panel:    #151a20;
  --border:   #1e2530;
  --border2:  #2a3545;
  --text:     #edf2f8;
  --dim:      #8a9bb8;
  --accent:   #4d8fff;
  --green:    #00d9a0;
  --red:      #ff4d6a;
  --yellow:   #f5a623;
  --sans:     'Manrope', system-ui, -apple-system, sans-serif;
  --mono:     'Fira Code', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'kern' 1;
}
/* Tabular figures everywhere numbers appear */
.stat-value, td, .statusbar-value { font-variant-numeric: tabular-nums; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Layout ────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 42px;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

/* ── Status bar ────────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  height: 36px;
  flex-shrink: 0;
}
.statusbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
}
.statusbar-group:first-child { padding-left: 0; }
.statusbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border2);
  flex-shrink: 0;
}
.statusbar-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.statusbar-value {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  font-weight: 500;
}
#status-bar .btn {
  font-size: 11px;
  padding: 3px 11px;
}

.site-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

nav {
  display: flex;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;        /* Firefox */
  -webkit-overflow-scrolling: touch;
}
nav::-webkit-scrollbar { display: none; }

nav a {
  display: block;
  padding: 0 13px;
  line-height: 42px;
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-bottom-color: var(--accent); }

.header-right {
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.session-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
.session-dot.running {
  background: var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { opacity: 0.82; background: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: default; }

#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
}
.view.active { display: block; }

/* ── Login ─────────────────────────────────────────────────── */
#view-login { padding: 0; overflow: hidden; }
#view-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

@keyframes login-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-form-wrap {
  width: 300px;
  animation: login-rise 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-sysid {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--border2);
  letter-spacing: 0.08em;
  margin-bottom: 44px;
}

.login-form { width: 100%; }

.login-field { margin-bottom: 28px; }
.login-field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.login-field input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  padding: 8px 0;
  outline: none;
  transition: border-color 0.2s;
}
.login-field input:focus { border-bottom-color: var(--accent); }

#btn-login {
  width: 100%;
  height: 40px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  margin-top: 8px;
  transition: opacity 0.15s;
}
#btn-login:hover:not(:disabled) { opacity: 0.82; }
#btn-login:disabled { opacity: 0.4; }

.login-error {
  color: var(--red);
  font-size: 11px;
  margin-top: 12px;
  min-height: 16px;
}

/* ── Panel / card ──────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Dashboard layout ──────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.stat-bar {
  grid-column: 1 / -1;
  display: flex;
  gap: 1px;
  background: var(--border);
}
.stat-item {
  flex: 1;
  background: var(--panel);
  padding: 12px 16px;
}
.stat-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
}
.stat-value.pos { color: var(--green); }
.stat-value.neg { color: var(--red); }
.stat-value.sm  { font-size: 14px; }

.chart-panel {
  overflow: hidden;
}
.chart-panel canvas { width: 100% !important; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

/* ── Tables ────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--mono);
}
th {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--dim);
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
  font-family: var(--sans);
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.tag.buy  { color: var(--green); border: 1px solid var(--green); }
.tag.sell { color: var(--red);   border: 1px solid var(--red);   }
.tag.hold { color: var(--dim);   border: 1px solid var(--border2); }

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ── Signals grid ──────────────────────────────────────────── */
.signals-table td.sig {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.signals-table td.sig.buy  { color: var(--green); }
.signals-table td.sig.sell { color: var(--red); }
.signals-table td.sig.none { color: var(--border2); }

td.flash { animation: flash 0.4s ease; }
@keyframes flash { 0%,100% { opacity:1; } 50% { opacity:0.2; } }

/* ── Activity feed ─────────────────────────────────────────── */
.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0;
}
.activity-item {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
}
.activity-item .time { color: var(--dim); margin-right: 8px; }
.activity-item.buy  { background: rgba(0, 217, 160, 0.04); }
.activity-item.sell { background: rgba(255, 77, 106, 0.04); }
.activity-item.err  { background: rgba(245, 166, 35, 0.04); color: var(--yellow); }

/* ── Backtest form ─────────────────────────────────────────── */
.backtest-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  height: 100%;
}
.form-grid { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.form-row  { display: flex; flex-direction: column; gap: 4px; }
.form-row label {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.02em;
}
.form-row input, .form-row select {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 9px;
  outline: none;
  width: 100%;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }
#params-container { display: flex; flex-direction: column; gap: 10px; }

.metrics-table { margin-bottom: 14px; }
.metrics-table td:first-child { color: var(--dim); width: 50%; }
.metrics-table td:last-child  { font-weight: 600; }

/* ── Config editor ─────────────────────────────────────────── */
.config-layout { max-width: 700px; }
.config-section { margin-bottom: 24px; }
.config-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.strategy-block {
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.strategy-block .strategy-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.strategy-block .strategy-params {
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.strategy-block .strategy-params .form-row { flex: 1; min-width: 120px; }

/* ── Toggle ────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 32px; height: 18px;
  flex-shrink: 0;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  cursor: pointer;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: white;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--dim);
}
.pagination .btn { padding: 3px 10px; }

/* ── Misc ──────────────────────────────────────────────────── */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.loading { color: var(--dim); padding: 20px; text-align: center; font-size: 13px; }
.toast {
  background: var(--panel);
  border: 1px solid var(--border2);
  padding: 11px 17px;
  font-size: 13px;
  animation: toast-in 0.2s ease;
}
.toast.ok  { border-color: var(--green); }
.toast.err { border-color: var(--red); }
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } to { opacity:1; } }

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  margin-bottom: 16px;
}

/* ── IB Gateway status ─────────────────────────────────────── */
.ib-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
.ib-dot.connected { background: var(--green); }
.ib-dot.disconnected { background: var(--red); }
.ib-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.03em;
  font-weight: 600;
}

/* ── AI insights view ──────────────────────────────────────── */
.ai-layout { max-width: 900px; display: flex; flex-direction: column; gap: 16px; }

.model-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 13px;
}
.model-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border2);
  color: var(--dim);
  font-family: var(--mono);
  white-space: nowrap;
}
.model-badge.active {
  border-color: var(--accent);
  color: var(--accent);
}
.model-badge.error {
  border-color: var(--red);
  color: var(--red);
}

.insight-block {
  padding: 16px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}
.insight-meta {
  font-size: 12px;
  color: var(--dim);
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
}

.ai-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ai-spinner {
  font-size: 10px;
  color: var(--dim);
  display: none;
}
.ai-spinner.visible { display: inline; }

/* ── Wizard ────────────────────────────────────────────────── */
.wizard-layout { max-width: 720px; margin: 0 auto; }

.wizard-step {
  display: none;
  flex-direction: column;
  gap: 18px;
}
.wizard-step.active { display: flex; }

.wizard-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.wizard-progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
}
.wizard-progress-dot.done   { background: var(--green); }
.wizard-progress-dot.active { background: var(--accent); }

.wizard-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.wizard-subtitle {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 2px;
  line-height: 1.5;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.choice-card {
  border: 1px solid var(--border2);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  user-select: none;
}
.choice-card:hover   { border-color: var(--accent); }
.choice-card.selected { border-color: var(--accent); background: rgba(61,126,255,.08); }
.choice-card .choice-icon { font-size: 18px; margin-bottom: 6px; }
.choice-card .choice-label { font-size: 13px; font-weight: 600; color: var(--text); }
.choice-card .choice-desc  { font-size: 12px; color: var(--dim); margin-top: 4px; line-height: 1.5; }

.sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.sector-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border2);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s;
  user-select: none;
}
.sector-chip:hover { border-color: var(--accent); }
.sector-chip.selected { border-color: var(--accent); background: rgba(61,126,255,.08); }
.sector-chip .risk-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.risk-dot.low       { background: var(--green); }
.risk-dot.medium    { background: var(--yellow); }
.risk-dot.high      { background: var(--red); }
.risk-dot.very_high { background: #ff00ff; }

.wizard-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
}

/* ── Config preview / review ───────────────────────────────── */
.config-review {
  font-size: 11px;
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.6;
}

/* ── Symbol browser modal ──────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  width: 800px;
  max-width: 96vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-search {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
}
.modal-search input:focus { border-color: var(--accent); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.symbol-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}
.symbol-group-header:not(:first-child) { margin-top: 14px; }

.symbol-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}
.symbol-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border2);
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.12s;
  user-select: none;
}
.symbol-chip:hover { border-color: var(--accent); }
.symbol-chip.selected {
  border-color: var(--green);
  color: var(--green);
}
.symbol-chip .sym-ticker { font-weight: 700; font-family: var(--mono); letter-spacing: .03em; }
.symbol-chip .sym-name   { font-size: 11px; color: var(--dim); }
.symbol-chip.selected .sym-name { color: var(--green); opacity: .75; }

.modal-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--dim);
}

/* ── Easy / Hard mode ──────────────────────────────────────── */

/* Items only visible in easy mode */
.hard-mode .easy-only { display: none !important; }
/* Items only visible in hard mode */
.easy-mode .hard-only { display: none !important; }

/* Hint text shown in easy mode, hidden in hard mode */
.easy-hint { display: none; }
.easy-mode .easy-hint { display: block; }

/* Strategy risk badges — shown always, styled differently per mode */
.strategy-risk-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-left: 5px;
  vertical-align: middle;
}
.strategy-risk-badge.low    { background: rgba(0,200,150,.12); color: var(--green); border: 1px solid rgba(0,200,150,.3); }
.strategy-risk-badge.medium { background: rgba(245,166,35,.12); color: var(--yellow); border: 1px solid rgba(245,166,35,.3); }
.strategy-risk-badge.high   { background: rgba(255,77,106,.12); color: var(--red); border: 1px solid rgba(255,77,106,.3); }
.strategy-risk-badge.very_high { background: rgba(200,0,255,.12); color: #cc66ff; border: 1px solid rgba(200,0,255,.3); }

/* In easy mode: show friendly strategy name instead of technical name */
.strategy-name-friendly { display: none; }
.strategy-name-tech     { display: inline; }
.easy-mode .strategy-name-friendly { display: inline; }
.easy-mode .strategy-name-tech     { display: none; }

/* Strategy description cards (extra context in easy mode) */
.strategy-easy-desc {
  display: none;
  font-size: 12px;
  color: var(--dim);
  padding: 4px 0 0 0;
  line-height: 1.6;
}
.easy-mode .strategy-easy-desc { display: block; }

/* Key suffix badge (visible last chars) */
.key-suffix {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--green);
  letter-spacing: .04em;
  flex-shrink: 0;
}

/* ── View mode toggle button ───────────────────────────────── */
#btn-view-mode {
  font-size: 11px;
  padding: 3px 9px;
  opacity: 0.7;
}
#btn-view-mode:hover { opacity: 1; }

/* ── IB Gateway dot — live mode ────────────────────────────── */
.ib-dot.live {
  background: var(--red) !important;
  box-shadow: 0 0 6px var(--red);
  animation: pulse-live 1.2s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Debug / Database tables ───────────────────────────────── */
.debug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--mono);
}
.debug-table td {
  padding: 6px 8px 6px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.debug-table tr:last-child td { border-bottom: none; }

.db-stats-bar {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.db-stat {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}
.db-stat:last-child { border-right: none; }
.db-stat-label {
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
}
.db-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
}

.db-strat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
  margin-top: 8px;
}
.db-strat-table th {
  text-align: left;
  padding: 6px 8px;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.db-strat-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.db-strat-table tr:last-child td { border-bottom: none; }

/* ── Disabled choice cards (wizard) ───────────────────────── */
.choice-card-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.choice-card-disabled a {
  pointer-events: auto;
  cursor: pointer;
  opacity: 1;
}

/* ── Start modal debug table ───────────────────────────────── */
#start-modal-body .debug-table td:first-child {
  width: 150px;
  padding-right: 16px;
}

/* ── Currency toggle ───────────────────────────────────────── */
.currency-toggle {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 10px;
  min-width: 54px;
  text-align: center;
  letter-spacing: 0.04em;
}

.sb-fx-rate {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.03em;
  white-space: nowrap;
  margin-left: 2px;
}

/* ── Wizard vs-panel ───────────────────────────────────────── */
.wizard-vs-panel {
  display: flex;
  gap: 0;
  border: 1px solid var(--border2);
  overflow: hidden;
  font-size: 12px;
}

.wizard-vs-col {
  flex: 1;
  padding: 14px 16px;
}

.wizard-vs-ai {
  background: rgba(61,126,255,0.05);
  border-right: 1px solid var(--border2);
}

.wizard-vs-manual {
  background: var(--bg2);
}

.wizard-vs-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 10px;
}

.wizard-vs-ai .wizard-vs-header { color: var(--accent); }

.wizard-vs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--dim);
  line-height: 1.5;
}

.wizard-vs-list li::before {
  content: '— ';
  color: var(--border2);
}

.wizard-vs-ai .wizard-vs-list li { color: var(--text); }
.wizard-vs-ai .wizard-vs-list li::before { color: var(--accent); content: '+ '; }

.wizard-vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 11px;
  color: var(--border2);
  background: var(--bg);
  flex-shrink: 0;
  border-right: 1px solid var(--border2);
}

/* ── Config tab bar ────────────────────────────────────────── */
.config-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.config-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 16px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.config-tab:hover { color: var(--text); }
.config-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── Preset cards ──────────────────────────────────────────── */
.preset-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.preset-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.preset-card:hover { border-color: var(--accent); }
.preset-card.selected {
  border-color: var(--accent);
  background: rgba(77,143,255,.08);
}
.preset-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.preset-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.preset-risk-badge {
  font-size: 10px;
  font-family: var(--mono);
  border: 1px solid;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: auto;
}
.preset-card-desc {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
  margin-bottom: 10px;
}
.preset-card-bullets {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.7;
}
.preset-card.selected .preset-card-bullets { color: var(--text); }

/* ── Style cards ───────────────────────────────────────────── */
.style-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.style-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.style-card:hover { border-color: var(--accent); }
.style-card.selected {
  border-color: var(--accent);
  background: rgba(77,143,255,.08);
}
.style-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.style-card-desc {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.45;
  margin-bottom: 4px;
}
.style-card-detail {
  font-size: 10px;
  color: var(--dim);
  opacity: 0.7;
}
.style-card.selected .style-card-desc { color: var(--text); }

/* ── Live trading mode ─────────────────────────────────────── */
#status-bar.live-mode {
  background: rgba(220, 38, 38, 0.15);
  border-top-color: var(--red);
}

.live-badge {
  display: none;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--red);
  padding: 3px 10px;
  border-radius: 4px;
  animation: live-pulse 1.5s ease-in-out infinite;
  margin: 0 8px;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.trade-mode-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 12px;
  min-width: 58px;
}
.trade-mode-btn.live {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  animation: live-pulse 1.5s ease-in-out infinite;
}

.ib-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  margin-left: 8px;
  flex-shrink: 0;
}
.ib-live-dot.connected { background: var(--green); }

/* ── Paper analysis ────────────────────────────────────────── */
.analysis-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.analysis-stat-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}
.analysis-stat-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
  margin-bottom: 4px;
}
.analysis-stat-label {
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Live confirm modal ────────────────────────────────────── */
.live-confirm-modal {
  max-width: 460px;
  border: 2px solid var(--red);
}

/* ── Users & Audit Log ─────────────────────────────────────── */
.role-badge {
  display: inline-block;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border2);
  color: var(--dim);
}
.role-badge.role-superadmin {
  color: #cc66ff;
  border-color: #cc66ff;
}
.role-badge.role-admin {
  color: var(--accent);
  border-color: var(--accent);
}
.role-badge.role-viewer {
  color: var(--dim);
}

.audit-action {
  display: inline-block;
  font-size: 11px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--dim);
}
.audit-action.ok   { color: var(--green); border-color: var(--green); background: rgba(0,217,160,0.05); }
.audit-action.err  { color: var(--red);   border-color: var(--red);   background: rgba(255,77,106,0.05); }
.audit-action.warn { color: var(--yellow);border-color: var(--yellow);background: rgba(245,166,35,0.05); }

.btn-sm {
  font-size: 10px;
  padding: 2px 8px;
  margin-left: 4px;
}

/* ── Page transitions ──────────────────────────────────────── */
@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-enter {
  animation: view-fade-in 0.22s ease forwards;
}

/* ── Panel hover lift ──────────────────────────────────────── */
.panel {
  transition: border-color 0.15s;
}
.panel:hover {
  border-color: var(--border2);
}

/* ── Button ripple feedback ────────────────────────────────── */
.btn:not(:disabled):active {
  transform: scale(0.97);
  transition: transform 0.08s;
}

/* nav a transitions already defined above */

/* ── Live Bot View panel ───────────────────────────────────── */
.live-view-panel {
  flex-shrink: 0;
}

.live-view-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.live-view-dot.idle     { background: var(--border2); }
.live-view-dot.scanning {
  background: var(--accent);
  animation: pulse 0.8s ease-in-out infinite;
}
.live-view-dot.trading  {
  background: var(--green);
  animation: pulse 0.5s ease-in-out infinite;
}

/* Live signal row */
.live-signal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  border-radius: 3px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--mono);
  transition: background 0.2s;
  min-height: 24px;
}
.live-signal-row:last-child { border-bottom: none; }
.live-sym   { font-weight: 700; color: var(--text); min-width: 48px; }
.live-price { color: var(--dim); min-width: 60px; }
.live-sig-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ── Status bar FX rate — always visible ───────────────────── */
.sb-fx-rate {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.03em;
  white-space: nowrap;
  margin-left: 2px;
  min-width: 80px;
}

/* ── Stat item subtle hover ────────────────────────────────── */
.stat-item {
  transition: background 0.15s;
}
.stat-item:hover {
  background: rgba(255,255,255,0.025);
}

/* ── Toast container stacking ──────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}
/* Override original .toast positioning (now managed by #toast-container) */
.toast {
  position: static;
}

/* ── Status bar glow when session running ──────────────────── */
@keyframes statusbar-glow {
  0%, 100% {
    box-shadow: 0 -2px 12px rgba(0, 217, 160, 0.10);
    border-top-color: rgba(0, 217, 160, 0.35);
  }
  50% {
    box-shadow: 0 -2px 22px rgba(0, 217, 160, 0.26);
    border-top-color: rgba(0, 217, 160, 0.75);
  }
}
#status-bar.session-running {
  animation: statusbar-glow 2.2s ease-in-out infinite;
}

/* ── Responsive header / nav ───────────────────────────────── */
@media (max-width: 900px) {
  header { padding: 0 10px; }
  .site-name { font-size: 11px; margin-right: 12px; }
  /* Hide less-critical status bar labels on small screens */
  .statusbar-label { display: none; }
  .statusbar-sep   { display: none; }
  #status-bar { padding: 0 8px; }
  .statusbar-group { padding: 0 6px; }
}

@media (max-width: 600px) {
  /* Hide site name to give nav maximum room */
  .site-name { display: none; }
  nav a { padding: 0 9px; font-size: 12px; }
  .sb-fx-rate { display: none; }
}

/* In-page Simple/Expert view-mode toggle button */
.btn-view-mode {
  font-size: 11px;
  padding: 3px 10px;
  color: var(--dim);
  border-color: var(--border);
}
.btn-view-mode:hover { color: var(--text); }

/* View-mode button aligned to right of stat-bar */
.stat-bar-viewmode {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 8px;
  flex-shrink: 0;
}

