/* ── Design System Onix.Finance ─────────────────────────────────────────── */

:root {
  --bg:         #080b12;
  --bg-card:    rgba(14,14,26,0.7);
  --bg-glass:   rgba(16,18,30,0.65);
  --bg-input:   rgba(22,27,38,0.8);
  --bg-surface: #0c0f18;
  --border:     rgba(255,255,255,0.06);
  --border-light:rgba(255,255,255,0.04);
  --border-glow: rgba(20,241,149,0.15);
  --text:       #e6edf3;
  --text-dim:   #8b949e;
  --text-muted: #484f58;
  --green:      #14f195;
  --green-dim:  rgba(20,241,149,0.08);
  --green-glow: rgba(20,241,149,0.25);
  --red:        #f85149;
  --red-bg:     rgba(248,81,73,0.08);
  --blue:       #58a6ff;
  --purple:     #9945ff;
  --orange:     #f0883e;
  --yellow:     #e3b341;
  --radius:     10px;
  --radius-lg:  14px;
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.5);
  --shadow-glow:0 0 30px rgba(20,241,149,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

/* Subtle grid pattern on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(20,241,149,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(153,69,255,0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

header {
  background: rgba(10,13,20,0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 52px;
  flex-shrink: 0;
  gap: 16px;
  z-index: 50;
  position: relative;
}
header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(20,241,149,0.15) 50%, transparent);
}

.logo {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: -0.2px;
}
.logo span { color: rgba(20,241,149,0.7); }

.header-badge {
  font-size: 10px;
  background: var(--green-dim);
  color: var(--green);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(20,241,149,0.12);
  letter-spacing: 0.3px;
}
.points-badge {
  background: rgba(255,215,0,0.08);
  color: #ffd700;
  border-color: rgba(255,215,0,0.15);
  cursor: pointer;
  transition: background 0.2s;
}
.points-badge:hover {
  background: rgba(255,215,0,0.15);
}
.points-tab {
  background: none;
  border: none;
  color: #666;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.points-tab.active {
  color: #ffd700;
  border-bottom-color: #ffd700;
}
.quest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #1a1a2e;
}
.quest-info { flex: 1; }
.quest-name { font-size: 13px; color: #ddd; }
.quest-pts { font-size: 11px; color: #ffd700; }
.quest-btn {
  padding: 4px 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.quest-btn.claim {
  background: #00d4aa;
  color: #000;
}
.quest-btn.done {
  background: rgba(255,255,255,0.05);
  color: #666;
  cursor: default;
}
.quest-btn.pending {
  background: rgba(255,215,0,0.1);
  color: #ffd700;
  cursor: default;
}

.header-wallet {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-left: auto;
  background: rgba(255,255,255,0.03);
  padding: 4px 10px;
  border-radius: 6px;
}

.header-btn {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s ease;
  font-weight: 500;
}
.header-btn:hover {
  border-color: rgba(255,255,255,0.12);
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

/* ── Layout ───────────────────────────────────────────────────────────────── */

.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  width: 310px;
  flex-shrink: 0;
  background: rgba(10,13,20,0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Custom scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section h3 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* Scenario cards */
.scenario-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scenario-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.scenario-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(20,241,149,0.06) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .2s;
}
.scenario-card:hover {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
}
.scenario-card:hover::before { opacity: 1; }
.scenario-card.active {
  border-color: rgba(20,241,149,0.35);
  background: rgba(20,241,149,0.04);
  box-shadow: 0 0 20px rgba(20,241,149,0.06), inset 0 1px 0 rgba(20,241,149,0.1);
}
.scenario-card.active::before { opacity: 1; }
.scenario-icon { font-size: 20px; margin-bottom: 4px; position: relative; }
.scenario-name { font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 4px; position: relative; }
.scenario-desc { font-size: 10px; color: var(--text-dim); line-height: 1.4; position: relative; }
.scenario-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 2px; position: relative;
}
.best-for-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  font-size: 9px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: relative;
}

/* Risk level dot */
.risk-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}
.risk-dot.risk-low    { background: #14f195; box-shadow: 0 0 4px rgba(20,241,149,0.5); }
.risk-dot.risk-medium { background: #e3b341; box-shadow: 0 0 4px rgba(227,179,65,0.5); }
.risk-dot.risk-high   { background: #f14444; box-shadow: 0 0 4px rgba(241,68,68,0.5); }

/* Strategy info panel */
.strategy-info {
  margin: 0 0 8px 0;
  padding: 10px 12px !important;
  background: rgba(20,241,149,0.03);
  border: 1px solid rgba(20,241,149,0.12);
  border-radius: var(--radius);
}
.strategy-info-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.strategy-info-title {
  font-size: 12px; font-weight: 600; color: var(--text);
}
.strategy-info-desc {
  font-size: 11px; color: var(--text-dim); line-height: 1.45;
  margin-bottom: 8px;
}
.strategy-info-row {
  display: flex; gap: 6px; align-items: baseline;
  font-size: 10px; line-height: 1.4; margin-bottom: 4px;
}
.strategy-info-row .info-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  min-width: 56px;
}
.strategy-info-row .info-value {
  color: var(--text-dim);
}
.strategy-info-caveat {
  display: flex; gap: 6px; align-items: flex-start;
  font-size: 10px; color: #e3b341;
  margin-top: 6px; padding: 6px 8px;
  background: rgba(227,179,65,0.06);
  border: 1px solid rgba(227,179,65,0.18);
  border-radius: 4px;
  line-height: 1.4;
}
.strategy-info-caveat .caveat-icon { flex-shrink: 0; }

@media (max-width: 480px) {
  .scenario-grid { grid-template-columns: 1fr 1fr; }
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}
.mode-btn {
  flex: 1;
  padding: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
.mode-btn.active {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Risk toggle */
.risk-toggle { display: flex; gap: 4px; }
.risk-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
.risk-btn.active {
  background: rgba(88,166,255,0.08);
  border-color: rgba(88,166,255,0.3);
  color: var(--blue);
}
.risk-btn:hover:not(.active) {
  border-color: rgba(255,255,255,0.1);
}

/* Fields */
.field { margin-bottom: 10px; }
.field label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input, .field select {
  width: 100%;
  background: #131720;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  transition: all .2s;
}
.field select option {
  background: #131720;
  color: var(--text);
  padding: 6px;
}
.field select optgroup {
  background: #0d1117;
  color: #58a6ff;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.5px;
  padding: 8px 0;
}
.field input:focus, .field select:focus {
  border-color: rgba(88,166,255,0.4);
  background: rgba(88,166,255,0.03);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.06);
}
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* Pair dropdown */
.pair-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: var(--shadow-md);
}
.pair-dropdown.open { display: block; }
.pair-dropdown-item {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.pair-dropdown-item:hover { background: rgba(255,255,255,0.05); }

/* Buttons */
.btn-run {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  letter-spacing: 0.3px;
}
.btn-run:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-simulate {
  background: linear-gradient(135deg, #1a7f3f, #238636);
  color: white;
  box-shadow: 0 2px 12px rgba(35,134,54,0.25);
}
.btn-simulate:hover:not(:disabled) {
  background: linear-gradient(135deg, #1f9447, #2ea043);
  box-shadow: 0 4px 20px rgba(35,134,54,0.35);
  transform: translateY(-1px);
}

.btn-create {
  background: linear-gradient(135deg, #0fd882, #14f195);
  color: #0a0a0f;
  box-shadow: 0 2px 16px rgba(20,241,149,0.2);
}
.btn-create:hover:not(:disabled) {
  box-shadow: 0 4px 24px rgba(20,241,149,0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-outline:hover {
  border-color: rgba(255,255,255,0.12);
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

/* New exchange button */
.btn-new-exchange {
  display: block; width: 100%; margin-top: 6px; padding: 7px;
  font-size: 11px; background: rgba(255,255,255,0.02);
  border: 1px dashed rgba(255,255,255,0.08);
  color: var(--text-dim); cursor: pointer; border-radius: 8px;
  transition: all .2s;
}
.btn-new-exchange:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(20,241,149,0.03);
}

/* Radio group */
.radio-group { display: flex; gap: 16px; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 12px; color: var(--text-dim);
}
.radio-label input[type="radio"] { display: none; }
.radio-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12); display: inline-block;
  transition: all .2s;
}
.radio-label input:checked ~ .radio-dot.live {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(20,241,149,0.4);
}
.radio-label input:checked ~ .radio-dot.dry {
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 10px rgba(227,179,65,0.3);
}

/* ── Main area ────────────────────────────────────────────────────────────── */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  background: rgba(10,13,20,0.5);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.tab {
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.3px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--green);
}
.tab-badge {
  font-size: 10px;
  background: var(--green-dim);
  color: var(--green);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid rgba(20,241,149,0.12);
}

.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-panel.active { display: flex; }

/* Metrics bar */
.metrics-bar {
  display: flex;
  padding: 12px 20px;
  gap: 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,13,20,0.4);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.metric { text-align: center; }
.metric-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-val.pos { color: var(--green); text-shadow: 0 0 20px rgba(20,241,149,0.2); }
.metric-val.neg { color: var(--red); text-shadow: 0 0 20px rgba(248,81,73,0.2); }
.metric-lbl {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 2px;
}

/* Charts */
.chart-area { flex: 1; min-height: 0; position: relative; }
.osc-area { height: 130px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* Signal status */
.signal-bar {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  background: rgba(10,13,20,0.3);
}
.signal-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 11px;
}
.signal-chip .s-label { color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; }
.signal-chip .s-value { color: var(--text); font-weight: 600; }

/* ── Bots tab ─────────────────────────────────────────────────────────────── */

.bots-list {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bots-summary {
  background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.bots-summary .bs-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.bots-summary .bs-hint {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
  margin-left: 3px;
}
.bots-summary .bs-pnl {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.bots-summary .bs-pnl.pos { color: var(--green, #4ade80); }
.bots-summary .bs-pnl.neg { color: var(--red, #ef4444); }
.bots-summary .bs-sep {
  color: var(--text-muted);
  margin: 0 4px;
  font-weight: 400;
}
.bots-summary .bs-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.bot-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}
.bot-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06) 50%, transparent);
}
.bot-card:hover {
  border-color: rgba(255,255,255,0.1);
  background: rgba(14,14,26,0.85);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.bot-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.bot-dot.running {
  background: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
.bot-dot.stopped { background: rgba(255,255,255,0.1); }
.bot-dot.dry {
  background: var(--purple);
  box-shadow: 0 0 10px rgba(153,69,255,0.3);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.bot-info { flex: 1; min-width: 0; }
.bot-name { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.bot-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.bot-pnl { text-align: right; min-width: 80px; }
.bot-pnl-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bot-pnl-val.pos { color: var(--green); text-shadow: 0 0 16px rgba(20,241,149,0.2); }
.bot-pnl-val.neg { color: var(--red); text-shadow: 0 0 16px rgba(248,81,73,0.2); }

.bot-actions { display: flex; gap: 6px; }
.bot-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  font-weight: 500;
}
.bot-btn:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text);
  background: rgba(255,255,255,0.07);
}
.bot-btn.danger:hover {
  border-color: rgba(248,81,73,0.4);
  color: var(--red);
  background: rgba(248,81,73,0.06);
}

/* Bot detail modal */
.bot-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bot-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 92%;
  max-width: 920px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .25s ease;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0,0,0,0.3);
}
@keyframes modalIn {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.bot-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}
.bot-modal-header h2 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -0.3px; }

.bot-modal-status {
  font-size: 10px; font-weight: 700; padding: 4px 12px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px;
}
.bot-modal-status.running {
  background: rgba(20,241,149,0.1);
  color: var(--green);
  border: 1px solid rgba(20,241,149,0.15);
}
.bot-modal-status.stopped {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.bot-modal-status.dry {
  background: rgba(153,69,255,0.1);
  color: #9945ff;
  border: 1px solid rgba(153,69,255,0.15);
}

.bot-modal-actions { margin-left: auto; display: flex; gap: 6px; }
.bot-modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  transition: color .15s;
}
.bot-modal-close:hover { color: var(--text); }

.bot-modal-meta {
  padding: 10px 24px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.2px;
}

.bot-modal-metrics {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.bot-modal-metrics .metric {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  border-right: 1px solid var(--border);
}
.bot-modal-metrics .metric:last-child { border-right: none; }

.bot-modal-position {
  padding: 14px 24px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}
.bot-modal-position strong { color: var(--text); }

.bot-modal-chart { width: 100%; height: 300px; }
.bot-modal-osc { width: 100%; height: 130px; border-top: 1px solid var(--border); }
.bot-modal-signals {
  display: flex; gap: 8px; padding: 12px 24px; flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.add-bot {
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.add-bot:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(20,241,149,0.02);
}

/* ── Config drawer ────────────────────────────────────────────────────────── */

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed; top: 0; right: -380px; bottom: 0;
  width: 370px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 100;
  padding: 24px;
  overflow-y: auto;
  transition: right .3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.3);
}
.drawer.open { right: 0; }
.drawer h2 {
  font-size: 15px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: -0.3px;
}
.drawer-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); font-size: 18px; cursor: pointer;
  transition: color .15s;
}
.drawer-close:hover { color: var(--text); }
.drawer-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.drawer-footer { font-size: 11px; color: var(--text-muted); }

/* ── Empty / loading ──────────────────────────────────────────────────────── */

.empty-chart {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  flex-direction: column;
  gap: 8px;
}

/* ── Toast notifications ─────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: rgba(12,15,24,0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  min-width: 300px;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .35s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.toast-out {
  animation: toastOut .25s ease forwards;
}

.toast-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.toast.success { border-color: rgba(20,241,149,0.2); }
.toast.success .toast-icon { background: rgba(20,241,149,0.1); color: var(--green); }

.toast.error { border-color: rgba(248,81,73,0.2); }
.toast.error .toast-icon { background: rgba(248,81,73,0.1); color: var(--red); }

.toast.info { border-color: rgba(88,166,255,0.2); }
.toast.info .toast-icon { background: rgba(88,166,255,0.1); color: var(--blue); }

.toast.warning { border-color: rgba(240,136,62,0.2); }
.toast.warning .toast-icon { background: rgba(240,136,62,0.1); color: var(--orange); }

.toast-body { flex: 1; line-height: 1.4; }
.toast-msg { color: var(--text-dim); font-size: 12px; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity .15s;
}
.toast-close:hover { opacity: 1; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(40px) scale(0.95); }
}

/* ── Opportunities tab ─────────────────────────────────────────────────────── */

.tab-badge.new-badge {
  background: linear-gradient(135deg, #14f195, #0fd882);
  color: #080b12;
  font-weight: 700;
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 4px;
  margin-left: 4px;
}

.opportunities-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}
.opportunities-toolbar select,
.opportunities-toolbar .btn-refresh {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.opportunities-toolbar .btn-refresh:hover { background: rgba(20,241,149,0.08); border-color: rgba(20,241,149,0.3); }
.opp-status { color: var(--text-muted); font-size: 11px; margin-left: auto; }

.opp-top-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
  background: rgba(20,241,149,0.02);
  border-bottom: 1px solid var(--border);
}
.opp-pick {
  background: rgba(14,14,26,0.6);
  border: 1px solid rgba(20,241,149,0.18);
  border-radius: 10px;
  padding: 14px;
}
.opp-pick-label {
  font-size: 9px;
  color: #14f195;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-bottom: 6px;
}
.opp-pick-pair { font-size: 18px; font-weight: 700; color: var(--text); }
.opp-pick-action { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.opp-pick-strat { font-size: 11px; color: var(--text-muted); margin-top: 6px; font-family: monospace; }

.opp-categories { padding: 16px; }
.opp-category {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.opp-cat-header {
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.opp-cat-count {
  background: rgba(20,241,149,0.1);
  color: #14f195;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
}
.opp-list { padding: 8px; display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 768px) {
  .opp-list { grid-template-columns: 1fr 1fr; }
}

.opp-card {
  background: rgba(14,14,26,0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}
.opp-tier {
  display: inline-block;
  width: 28px;
  height: 24px;
  border-radius: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 24px;
}
.opp-tier-Splus, .opp-tier-S { background: rgba(20,241,149,0.15); color: #14f195; }
.opp-tier-A { background: rgba(88,166,255,0.15); color: #58a6ff; }
.opp-tier-B { background: rgba(227,179,65,0.15); color: #e3b341; }
.opp-tier-C { background: rgba(241,68,68,0.12); color: #f14444; }

.opp-meta { font-size: 12px; min-width: 0; }
.opp-pair-line { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.opp-pair { font-weight: 600; color: var(--text); }
.opp-action-pill {
  font-size: 9px; padding: 2px 6px; border-radius: 4px; font-weight: 700;
}
.opp-action-LONG { background: rgba(20,241,149,0.15); color: #14f195; }
.opp-action-SHORT { background: rgba(241,68,68,0.15); color: #f14444; }
.opp-action-WATCH { background: rgba(227,179,65,0.15); color: #e3b341; }
.opp-rationale { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.opp-strat-info { font-size: 10px; color: var(--text-muted); font-family: monospace; }

.opp-card-actions { display: flex; flex-direction: column; gap: 4px; }
.opp-btn {
  background: rgba(20,241,149,0.08);
  border: 1px solid rgba(20,241,149,0.25);
  color: #14f195;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.opp-btn:hover { background: rgba(20,241,149,0.15); }
.opp-btn-secondary {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
  color: var(--text-dim);
}

.opp-strength-bar {
  height: 3px;
  background: rgba(255,255,255,0.04);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.opp-strength-fill {
  height: 100%;
  background: linear-gradient(90deg, #14f195, #0fd882);
  transition: width .3s;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Stacked layout — sidebar (form) becomes a vertical block above the chart.
     Visible only when Backtest tab is active (toggled via body[data-tab]). */
  .app-layout { flex-direction: column; overflow: visible; }
  .sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  body[data-tab="bots"] .sidebar,
  body[data-tab="opportunities"] .sidebar { display: none; }
  .main-area { width: 100%; min-height: 50vh; }

  /* Sidebar sections — tighter spacing on mobile */
  .sidebar-section { padding: 12px 16px; }
  .scenario-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

  .metrics-bar { gap: 14px; padding: 10px 16px; }
  .toast-container { left: 16px; right: 16px; }
  .toast { min-width: auto; }
  header { padding: 0 12px; height: 48px; }
  .header-wallet { display: none; }

  /* Touch targets — Apple HIG / Material minimum.
     Excludes dense control rows (bot card actions, opp card actions) which keep
     their compact sizing for information density. */
  button.btn-run,
  button.btn-simulate,
  button.btn-create,
  button.btn-outline,
  button.btn-new-exchange,
  .lp-cta-top,
  .mode-btn,
  .risk-btn {
    min-height: 44px;
  }

  /* iOS Safari auto-zoom prevention: inputs/selects must be ≥16px on focus */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  /* Metrics bar squeeze — 6 KPIs need to wrap cleanly */
  .metrics-bar { gap: 10px; padding: 10px 12px; }
  .metric-val { font-size: 15px; }
  .metric-lbl { font-size: 8px; }

  /* Signal bar wraps tighter */
  .signal-bar { gap: 6px; padding: 8px 12px; }
  .signal-chip { padding: 4px 9px; font-size: 10px; }

  /* Drawer: full-width on small phones (was 370px fixed, overflows 375px viewport) */
  .drawer { width: 100%; right: -100%; padding: 20px 16px; }

  /* Bots list padding */
  .bots-list { padding: 12px; gap: 8px; }
  .bots-summary { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .bots-summary .bs-pnl { font-size: 18px; }
  .bots-summary .bs-meta { text-align: left; font-size: 10px; }

  /* Tabs: reduce horizontal pressure */
  .tabs { padding: 0 12px; gap: 4px; }

  /* Bot detail modal — overhauled as bottom sheet (Phase B3 prep, hooked here for early CSS-only fallback) */
  .bot-modal-overlay { align-items: flex-end; }
  .bot-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    animation: sheetUp .28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .bot-modal-header { padding: 14px 18px; }
  .bot-modal-header h2 { font-size: 15px; }
  .bot-modal-meta { padding: 10px 18px; font-size: 11px; }
  .bot-modal-metrics { flex-wrap: wrap; }
  .bot-modal-metrics .metric { flex: 0 0 50%; padding: 12px 6px; border-right: none; border-bottom: 1px solid var(--border); }
  .bot-modal-metrics .metric:nth-last-child(-n+2) { border-bottom: none; }
  .bot-modal-chart { height: 220px; }
  .bot-modal-osc { height: 100px; }
  .bot-modal-signals { padding: 10px 16px; gap: 6px; }
  .bot-modal-close { font-size: 26px; padding: 4px 8px; min-width: 36px; }

  /* Bot card: vertical stack so info/PnL/actions don't squish at 375px */
  .bot-card { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
  .bot-card .bot-dot { position: absolute; top: 14px; left: 14px; }
  .bot-info { padding-left: 18px; }
  .bot-pnl { text-align: left; min-width: 0; padding-left: 18px; }
  .bot-actions { width: 100%; }
  .bot-actions .bot-btn { flex: 1; padding: 10px; font-size: 12px; }

  /* Opportunities card: stack action column under meta on narrow */
  .opp-card { grid-template-columns: auto 1fr; }
  .opp-card-actions { grid-column: 1 / -1; flex-direction: row; gap: 6px; }
  .opp-card-actions .opp-btn { flex: 1; padding: 10px; font-size: 11px; }
  .opp-top-picks { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
}
