@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Roboto+Mono:wght@400;500;700&display=swap");

:root {
  color-scheme: dark;
  --bg:        #0c0e10;
  --panel:     #141820;
  --panel-2:   #1c2229;
  --panel-3:   #222b33;
  --text:      #e8f0f2;
  --muted:     #8fa4ad;
  --line:      #1e2832;
  --line-2:    #2a3540;
  --cyan:      #2fd6c8;
  --cyan-dim:  rgba(47, 214, 200, 0.12);
  --cyan-glow: rgba(47, 214, 200, 0.22);
  --green:     #7ed64a;
  --green-dim: rgba(126, 214, 74, 0.10);
  --amber:     #edb048;
  --amber-dim: rgba(237, 176, 72, 0.10);
  --red:       #f06060;
  --red-dim:   rgba(240, 96, 96, 0.10);
  --blue:      #4a9eff;
  --radius:    9px;
  --radius-sm: 6px;
  --shadow:    0 2px 16px rgba(0,0,0,0.45);
  --shadow-sm: 0 1px 8px rgba(0,0,0,0.35);
  --transition:150ms ease;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a58; }

/* ─────────────────── TOPBAR ─────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(12, 14, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(47, 214, 200, 0.06);
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 700; }

/* ─────────────────── TOPBAR ACTIONS ─────────────────── */

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(47, 214, 200, 0.45);
  border-radius: var(--radius-sm);
  background: var(--cyan-dim);
  color: var(--cyan);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
button:hover {
  background: rgba(47, 214, 200, 0.20);
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}
button:disabled { opacity: 0.45; cursor: wait; }

button.danger {
  border-color: rgba(240, 96, 96, 0.45);
  background: var(--red-dim);
  color: var(--red);
}
button.danger:hover {
  background: rgba(240, 96, 96, 0.20);
  border-color: var(--red);
  box-shadow: 0 0 10px rgba(240,96,96,0.22);
}
button.danger.armed {
  border-color: rgba(237, 176, 72, 0.8);
  background: rgba(237, 176, 72, 0.15);
  color: var(--amber);
  box-shadow: 0 0 10px rgba(237,176,72,0.2);
  animation: armed-pulse 2.5s infinite;
}
@keyframes armed-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(237,176,72,0.2); }
  50%       { box-shadow: 0 0 18px rgba(237,176,72,0.45); }
}

/* ─────────────────── MODE SELECTOR ─────────────────── */

.mode-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12,14,16,0.8);
}
.mode-selector button {
  min-height: 28px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
}
.mode-selector button:hover { color: var(--text); border-color: var(--line-2); background: var(--panel); }
.mode-selector button.active {
  border-color: rgba(47, 214, 200, 0.65);
  background: rgba(47, 214, 200, 0.10);
  color: var(--cyan);
  box-shadow: none;
}

/* ─────────────────── LIVE GATES ─────────────────── */

.live-gates {
  display: flex;
  gap: 6px;
  align-items: stretch;
  flex-wrap: wrap;
}
.live-gates button { flex: 1 0 auto; min-width: 130px; }
.live-gates button { min-height: 38px; font-size: 11px; padding: 0 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.arm-label { font-weight: 700; letter-spacing: .04em; line-height: 1.2; }
.arm-cap   { font-size: 9.5px; font-weight: 500; opacity: 0.75; letter-spacing: .03em; line-height: 1; }

.cap-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  transition: border-color var(--transition);
}
.cap-input:focus-within { border-color: var(--cyan); }
.cap-input span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.cap-input input {
  width: 76px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-height: unset;
}

/* ─────────────────── MAIN LAYOUT ─────────────────── */

main {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 20px 22px;
  overflow-x: hidden;
}

/* ─────────────────── METRIC CARDS ─────────────────── */

.metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.metrics article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 100px;
  min-width: 0;
  display: grid;
  align-content: space-between;
  padding: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.metrics article::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--line);
  transition: background var(--transition);
}
.metrics article:hover { border-color: var(--line-2); }

.metrics span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.metrics small { color: var(--muted); font-size: 11px; }
.metrics strong {
  margin-top: 6px;
  color: var(--cyan);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: "Roboto Mono", ui-monospace, monospace;
}

/* Accent overrides for specific metric states */
.metrics article.pnl-positive strong { color: var(--green); }
.metrics article.pnl-positive::before { background: linear-gradient(90deg, var(--green), transparent); }
.metrics article.pnl-negative strong { color: var(--red); }
.metrics article.pnl-negative::before { background: linear-gradient(90deg, var(--red), transparent); }
.metrics article.live-armed strong { color: var(--amber); }
.metrics article.live-armed::before { background: linear-gradient(90deg, var(--amber), transparent); animation: armed-glow 2.5s infinite; }
@keyframes armed-glow {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ─────────────────── PANELS ─────────────────── */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { color: var(--text); }
.panel-head span { color: var(--muted); font-size: 11px; }

/* ─────────────────── STRATEGY CONFIG PANEL ─────────────────── */

.strategy-config-panel {
  margin-top: 14px;
  border-color: rgba(47, 214, 200, 0.18);
}
.strategy-config-panel .panel-head { border-bottom-color: rgba(47, 214, 200, 0.12); }
.strategy-config-panel .panel-head h2 { color: var(--cyan); }

.config-toggle-btn {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.config-toggle-btn:hover { color: var(--text); border-color: #3a4a58; box-shadow: none; }

/* ── Mode selector (Aggressive / Neutral / Premium Select) ── */
.cfg-mode-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}

.cfg-mode-tab {
  min-height: unset;
  padding: 10px 20px 12px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition);
  position: relative;
  display: grid;
  gap: 2px;
  text-align: center;
  margin-bottom: -1px;
}
.cfg-mode-tab strong { display: block; font-size: 13px; font-weight: 800; }
.cfg-mode-tab small  { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.cfg-mode-tab:hover  { color: var(--text); box-shadow: none; }
.cfg-mode-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  background: transparent;
  box-shadow: none;
}
/* Dot showing which mode the bot is currently running */
.cfg-mode-tab.running::after {
  content: '';
  position: absolute;
  top: 8px; right: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
  animation: pulse-dot 2s infinite;
}

/* ── Unified 3-column config view ── */
.cfg-unified {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.cfg-section {
  display: grid;
  gap: 10px;
}

.cfg-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.cfg-section-head h3 {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}
.cfg-section-head h3 em {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 6px;
}

/* reuse config-value for the live display */
.config-value {
  font-family: "Roboto Mono", monospace;
  font-size: 15px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0;
  min-width: 52px;
  text-align: right;
}

.config-row {
  display: grid;
  gap: 6px;
}

.config-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.config-label .config-value {
  font-size: 13px;
  min-width: 52px;
}

/* legacy compat — keep config-grid for admin table overrides */
.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
/* legacy compat */
.config-mode-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 14px;
}
.config-mode-card.active-mode {
  border-color: rgba(47, 214, 200, 0.45);
  background: rgba(47, 214, 200, 0.04);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  min-height: unset;
  padding: 0;
  border: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--cyan-glow);
  cursor: pointer;
  transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--cyan);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
input[type="range"]:focus { outline: none; box-shadow: none; }

.leverage-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.preset-btn {
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition);
  letter-spacing: 0.04em;
}
.preset-btn:hover { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-dim); box-shadow: none; }
.preset-btn.active { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-dim); }

.config-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.config-field {
  display: grid;
  gap: 5px;
}
.config-field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.config-field input[type="number"],
.config-field input[type="text"] {
  min-height: 32px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-3);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  font-family: "Roboto Mono", monospace;
  font-weight: 600;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.config-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.config-save-btn {
  width: 100%;
  min-height: 34px;
  margin-top: 14px;
  border: 1px solid rgba(47, 214, 200, 0.45);
  border-radius: var(--radius-sm);
  background: var(--cyan-dim);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.config-save-btn:hover {
  background: rgba(47, 214, 200, 0.20);
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.config-save-btn.saved {
  border-color: rgba(126, 214, 74, 0.55);
  background: rgba(126, 214, 74, 0.10);
  color: var(--green);
}

/* ─────────────────── ALERT PANEL ─────────────────── */

.safety-panel { margin-top: 14px; }
.alert-list { display: grid; gap: 8px; }

.alert {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 11px 13px;
  background: var(--panel-2);
  transition: border-color var(--transition);
}
.alert strong, .alert span { display: block; }
.alert strong { margin-bottom: 4px; font-size: 13px; }
.alert span { color: #c8d8dc; line-height: 1.45; font-size: 13px; }

.alert.critical {
  border-color: rgba(240, 96, 96, 0.55);
  background: rgba(240, 96, 96, 0.06);
}
.alert.critical strong { color: var(--red); }
.alert.warning {
  border-color: rgba(237, 176, 72, 0.55);
  background: rgba(237, 176, 72, 0.06);
}
.alert.warning strong { color: var(--amber); }
.alert.ok {
  border-color: rgba(126, 214, 74, 0.45);
  background: rgba(126, 214, 74, 0.05);
}
.alert.ok strong { color: var(--green); }

/* ─────────────────── GRID LAYOUTS ─────────────────── */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  margin-top: 14px;
}
.grid + .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.live-audit-grid { grid-template-columns: minmax(0, 1fr); }

.performance-panel { margin-top: 14px; max-width: 100%; overflow: hidden; }

/* ─────────────────── EQUITY CURVE ─────────────────── */

.equity-viewport {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 260px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #050708;
}
#equityCurve {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  border: 0;
  background: transparent;
}

/* ─────────────────── SIM METRICS ─────────────────── */

.sim-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.sim-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}
.sim-card h3 { margin: 0 0 10px; font-size: 13px; color: var(--cyan); }
.sim-card dl { display: grid; gap: 0; margin: 0; }
.sim-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.sim-card div:last-child { border-bottom: none; }
.sim-card dt { color: var(--muted); font-size: 12px; }
.sim-card dd { margin: 0; font-weight: 700; font-size: 13px; font-family: "Roboto Mono", monospace; }
.sim-card a { display: inline-block; margin-top: 12px; color: var(--cyan); font-size: 12px; font-weight: 700; text-decoration: none; }
.sim-card a:hover { text-decoration: underline; }

/* ─────────────────── STRATEGY CARDS ─────────────────── */

.strategy-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.strategy-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
  transition: border-color var(--transition);
}
.strategy-card strong { display: block; color: var(--cyan); margin-bottom: 6px; font-size: 13px; }
.strategy-card.no-trade strong { color: var(--amber); }
.strategy-card.execute strong { color: var(--green); }
.strategy-card.execute { border-color: rgba(126, 214, 74, 0.25); }
.strategy-card p { color: #c8d8dc; line-height: 1.45; font-size: 13px; }
.strategy-card small { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }

.risk-list {
  margin: 0;
  padding-left: 18px;
  color: #c8d8dc;
  line-height: 1.75;
  font-size: 13px;
}

/* ─────────────────── TABLES ─────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.indicator-monitor,
.market-core-panel,
.strategy-matrix-panel,
.live-monitor { margin-top: 14px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}
td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
}

/* ─────────────────── PILLS & BADGES ─────────────────── */

.trade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.trade-pill.open  { border-color: rgba(126,214,74,0.5); color: var(--green); background: rgba(126,214,74,0.07); }
.trade-pill.pending { border-color: rgba(237,176,72,0.5); color: var(--amber); background: rgba(237,176,72,0.07); }
.trade-pill.local { border-color: rgba(47,214,200,0.4); color: var(--cyan); background: rgba(47,214,200,0.07); }

.decision-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  min-width: 86px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.decision-pill.execute { border-color: rgba(126,214,74,0.5); color: var(--green); background: rgba(126,214,74,0.07); }
.decision-pill.blocked { border-color: rgba(237,176,72,0.5); color: var(--amber); background: rgba(237,176,72,0.07); }

.feed-pill, .hash-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.feed-pill.fresh { border-color: rgba(126,214,74,0.5); color: var(--green); background: rgba(126,214,74,0.07); }
.feed-pill.stale { border-color: rgba(240,96,96,0.5); color: var(--red); background: rgba(240,96,96,0.07); }
.hash-pill { color: var(--cyan); background: rgba(47,214,200,0.07); border-color: rgba(47,214,200,0.3); }

/* ─────────────────── TABLE ROW STATES ─────────────────── */

.positive { color: var(--green); font-weight: 800; font-family: "Roboto Mono", monospace; }
.negative { color: var(--red);   font-weight: 800; font-family: "Roboto Mono", monospace; }
.warning  { color: var(--amber); font-weight: 800; }
.muted-cell { color: var(--muted); }
.fresh-text { color: var(--green) !important; }
.stale-text { color: var(--red)   !important; }

.execute-row td { background: rgba(126, 214, 74, 0.03); }
.blocked-row td { background: rgba(237, 176, 72, 0.03); }

/* ─────────────────── DEBUG PANELS ─────────────────── */

pre {
  max-height: 440px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #050708;
  color: #c8d8dc;
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.event-log {
  display: grid;
  gap: 0;
  color: #c8d8dc;
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}
.event-log div {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  transition: background var(--transition);
}
.event-log div:hover { background: rgba(255,255,255,0.015); }
.event-log b { color: var(--cyan); min-width: 200px; }
.event-log time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.debug-panel { margin-top: 14px; }
.debug-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--cyan);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 0;
}
.debug-panel summary small { color: var(--muted); font-weight: 600; font-size: 11px; }
.debug-panel[open] summary { margin-bottom: 12px; }

/* ─────────────────── LIVE DOT ANIMATION ─────────────────── */

.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: middle;
  margin-right: 5px;
}
.live-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-dot 2s infinite; }
.live-dot.error  { background: var(--red); box-shadow: 0 0 6px var(--red); }
.live-dot.warn   { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.35; }
}

/* ─────────────────── TOAST ─────────────────── */

#toast-root {
  position: fixed;
  top: 80px; right: 18px;
  z-index: 9999;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px; max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.2s ease;
  pointer-events: all;
}
.toast.success { border-color: rgba(126,214,74,0.45); }
.toast.error   { border-color: rgba(240,96,96,0.45); }
.toast.warning { border-color: rgba(237,176,72,0.45); }
.toast-body { flex: 1; line-height: 1.4; }
.toast-title { font-weight: 700; margin-bottom: 2px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─────────────────── USER BADGE ─────────────────── */

.user-badge {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: default;
  flex-shrink: 0;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1db8ab 0%, #2fd6c8 100%);
  color: #050f0e;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { display: grid; gap: 1px; }
.user-info strong { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1; }
.user-info span { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.user-menu-btn {
  min-height: unset;
  height: 24px; width: 24px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  box-shadow: none;
  display: flex; align-items: center; justify-content: center;
}
.user-menu-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: none; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.dropdown-item {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--panel-2); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(240,96,96,0.07); }

.dropdown-sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

/* ─────────────────── CONFIG: USDT + ASSETS ROW ─────────────────── */

.cfg-quick-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding: 16px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.cfg-usdt-field > label,
.cfg-assets-field > label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.cfg-usdt-field > label em,
.cfg-assets-field > label em {
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

.cfg-usdt-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 42px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-2);
  transition: border-color var(--transition);
}
.cfg-usdt-input-wrap:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.cfg-usdt-input-wrap input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; font-weight: 700;
  font-family: "Roboto Mono", monospace;
  min-height: unset; padding: 0; box-shadow: none;
}
.cfg-usdt-input-wrap span {
  font-size: 11px; font-weight: 800;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}

.cfg-asset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─────────────────── CONFIG: ENTRY PARAMETERS ─────────────────── */

.cfg-entry-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.cfg-params-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
}

.cfg-param {
  display: grid;
  gap: 6px;
}
.cfg-param small {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

/* Toggle switch for fractal alignment */
.cfg-param-toggle { gap: 8px; }
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-track {
  position: relative;
  width: 40px; height: 22px;
  background: var(--line-2);
  border-radius: 11px;
  transition: background var(--transition);
  flex-shrink: 0;
}
input[type="checkbox"]:checked ~ .toggle-track,
.toggle-switch input:checked + .toggle-track {
  background: var(--cyan);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text);
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}
.toggle-label {
  font-size: 12px; font-weight: 800;
  font-family: "Roboto Mono", monospace;
  color: var(--muted);
  min-width: 28px;
}
input[type="checkbox"]:checked + .toggle-track + .toggle-label { color: var(--cyan); }

/* ─────────────────── TIMEFRAME CONFIGURATION ─────────────────── */

.cfg-tf-section { /* wrapper already styled via inline border-top */ }

.cfg-tf-body {
  display: grid;
  gap: 20px;
}

.cfg-tf-block { display: grid; gap: 10px; }

.cfg-tf-label span {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.cfg-tf-label small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.cfg-tf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Primary TF chip (single-select) ── */
.tf-chip {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  font-family: "Roboto Mono", monospace;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.tf-chip:hover { color: var(--text); border-color: #3a4a58; box-shadow: none; }
.tf-chip.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(47, 214, 200, 0.10);
  box-shadow: 0 0 10px rgba(47, 214, 200, 0.15);
}

/* ── Fractal TF check-chip (multi-select) ── */
.tf-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  font-family: "Roboto Mono", monospace;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  user-select: none;
}
.tf-check-chip input[type="checkbox"] {
  width: 13px; height: 13px;
  accent-color: var(--cyan);
  cursor: pointer;
  min-height: unset;
  padding: 0; border: 0; border-radius: 0; box-shadow: none;
}
.tf-check-chip:hover { color: var(--text); border-color: #3a4a58; }
.tf-check-chip.checked {
  border-color: rgba(47, 214, 200, 0.55);
  background: rgba(47, 214, 200, 0.07);
  color: var(--text);
}
/* dot marking which tf is the primary inside the fractal set */
.tf-check-chip.primary-mark {
  border-color: rgba(47, 214, 200, 0.8);
}
.tf-primary-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 5px var(--cyan);
  flex-shrink: 0;
}

/* ─────────────────── ASSET SELECTOR (legacy standalone) ─────────────────── */

.asset-selector-panel { margin-top: 14px; }

.asset-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  user-select: none;
}
.asset-checkbox:hover { border-color: #3a4a58; }
.asset-checkbox.checked {
  border-color: rgba(47,214,200,0.55);
  background: rgba(47,214,200,0.06);
}
.asset-checkbox input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--cyan);
  cursor: pointer;
  min-height: unset;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.asset-ticker {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
}
.asset-ticker small {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.asset-active-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 5px var(--cyan);
  flex-shrink: 0;
}

/* ─────────────────── API KEYS PANEL ─────────────────── */

.api-keys-panel { margin-top: 14px; border-color: rgba(237,176,72,0.2); }
.api-keys-form { max-width: 520px; }
.api-keys-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--green);
}

/* ─────────────────── ADMIN USERS PANEL ─────────────────── */

.admin-users-panel { margin-top: 14px; border-color: rgba(47,214,200,0.18); }
.admin-users-panel .panel-head h2 { color: var(--cyan); }

/* ─────────────────── IGM THEORY COLUMNS ─────────────────── */

.prob-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 64px;
  margin-bottom: 2px;
}
.prob-bar {
  height: 4px;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.prob-bar.up   { background: var(--green); }
.prob-bar.down { background: var(--red); }

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  font-family: "Roboto Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─────────────────── HEDGE BUTTON ─────────────────── */

.hedge-cell {
  display: grid;
  gap: 4px;
  min-width: 110px;
}

.hedge-btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--muted);
  letter-spacing: 0.03em;
  transition: all var(--transition);
  box-shadow: none;
  white-space: nowrap;
}
.hedge-btn:hover { color: var(--text); border-color: #3a4a58; box-shadow: none; }
.hedge-btn:disabled { opacity: 0.45; cursor: wait; }

/* WATCH state — amber */
.hedge-btn.watch {
  border-color: rgba(237,176,72,0.6);
  background: rgba(237,176,72,0.08);
  color: var(--amber);
}
.hedge-btn.watch:hover { background: rgba(237,176,72,0.16); box-shadow: 0 0 8px rgba(237,176,72,0.25); }

/* HEDGE state — red + slow pulse */
.hedge-btn.hedge {
  border-color: rgba(240,96,96,0.7);
  background: rgba(240,96,96,0.10);
  color: var(--red);
  animation: hedge-pulse 2s infinite;
}
@keyframes hedge-pulse {
  0%,100% { box-shadow: 0 0 6px rgba(240,96,96,0.25); }
  50%      { box-shadow: 0 0 14px rgba(240,96,96,0.55); }
}

/* CRITICAL state — red solid + fast pulse */
.hedge-btn.critical {
  border-color: var(--red);
  background: rgba(240,96,96,0.18);
  color: var(--text);
  animation: hedge-critical-pulse 1s infinite;
}
@keyframes hedge-critical-pulse {
  0%,100% { box-shadow: 0 0 10px rgba(240,96,96,0.45); }
  50%      { box-shadow: 0 0 22px rgba(240,96,96,0.80); }
}

.hedge-reason {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
  display: block;
  white-space: normal;
}

/* Row highlight when hedge is recommended */
.hedge-alert-row   td { background: rgba(240,96,96,0.025); }
.hedge-critical-row td { background: rgba(240,96,96,0.055); }

/* ─────────────────── RESPONSIVE ─────────────────── */

@media (max-width: 1400px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .config-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1100px) {
  .topbar, .actions { align-items: stretch; flex-direction: column; padding: 12px; }
  .metrics, .grid, .grid + .grid, .strategy-cards, .sim-metrics, .config-grid { grid-template-columns: 1fr; }
  .live-gates { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  main { padding: 12px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ─────────────────── DIRECTION BIAS BUTTONS ─────────────────── */
.bias-btn-group {
  display: flex;
  gap: 4px;
}
.bias-btn {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.bias-btn:hover { background: rgba(0,200,200,.08); color: var(--text); }
.bias-btn.active[data-bias="BOTH"]       { background: rgba(0,200,200,.15); border-color: var(--cyan-dim); color: var(--cyan); }
.bias-btn.active[data-bias="LONG_ONLY"]  { background: rgba(0,200,80,.15);  border-color: var(--green);    color: var(--green); }
.bias-btn.active[data-bias="SHORT_ONLY"] { background: rgba(240,96,96,.15); border-color: var(--red);      color: var(--red); }

/* ─────────────────── ARM BUTTON LOADING STATE ─────────────────── */
button[data-live-mode].loading {
  opacity: 0.65;
  cursor: wait;
  pointer-events: none;
}
