:root {
  --bg: #0a0d12;
  --panel: #10141b;
  --panel-border: #1e2530;
  --text: #f5f7fa;
  --text-dim: #c3cad6;
  --text-faint: #98a4b3;
  --up: #4dd4ac;
  --down: #e2545a;
  --warn: #e8a33d;
  --neutral: #6b9bd6;
  --accent: #4dd4ac;
  --font-ui: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Author rules elsewhere in this file (display: flex/grid on elements that
   also get toggled via the `hidden` attribute) would otherwise beat the
   browser's built-in [hidden]{display:none} rule at equal specificity.
   This keeps hidden authoritative everywhere in the app. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

.app { max-width: 1400px; margin: 0 auto; padding: 0 24px 40px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 24px;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-family: var(--font-mono); font-weight: 600; font-size: 18px; letter-spacing: 0.5px; }
.brand-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  border: 1px solid var(--panel-border);
  padding: 3px 7px;
  border-radius: 3px;
  letter-spacing: 1px;
}

.ticker { text-align: right; }
.ticker-price {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  display: block;
  transition: color 0.3s ease;
}
.ticker-price.flash-up { color: var(--up); }
.ticker-price.flash-down { color: var(--down); }
.ticker-updated {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-faint);
}

/* ── Zone eyebrows: light section labels, no layout restructuring ───────── */
.zone-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  padding-bottom: 8px;
  margin: 28px 0 12px;
  border-bottom: 1px solid var(--panel-border);
}
.zone-eyebrow:first-of-type { margin-top: 0; }

/* ── Signal banner ─────────────────────────────────────────────────────── */
.signal-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  margin-bottom: 12px;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.signal-banner[data-signal="BUY"] { border-color: var(--up); background: #0f1f1a; }
.signal-banner[data-signal="SELL"] { border-color: var(--down); background: #241014; }
.signal-banner[data-signal="HOLD"] { border-color: var(--neutral); background: #101a26; }
.signal-banner[data-signal="LOADING"] { border-color: var(--warn); background: #1c1608; }

.signal-icon { font-size: 24px; flex-shrink: 0; line-height: 1; }

.signal-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 6px 14px;
  border-radius: 5px;
  background: var(--panel-border);
  color: var(--text);
  flex-shrink: 0;
}
.signal-banner[data-signal="BUY"] .signal-badge { background: var(--up); color: #06231b; }
.signal-banner[data-signal="SELL"] .signal-badge { background: var(--down); color: #2b0a0c; }
.signal-banner[data-signal="HOLD"] .signal-badge { background: var(--neutral); color: #071522; }
.signal-banner[data-signal="LOADING"] .signal-badge { background: var(--warn); color: #241a04; }

.signal-reason { font-size: 16px; color: var(--text); flex: 1; line-height: 1.4; }
.signal-countdown {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-faint);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Warm-up progress ──────────────────────────────────────────────────── */
.warmup-wrap { margin-bottom: 20px; }
.warmup-progress-track {
  background: var(--panel-border);
  border-radius: 7px;
  height: 14px;
  overflow: hidden;
}
.warmup-progress-bar {
  height: 100%;
  background: var(--warn);
  width: 0%;
  transition: width 0.4s ease;
}
.warmup-progress-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Reasoning breakdown ───────────────────────────────────────────────── */
.reasoning-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 36px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.reasoning-row { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.reasoning-label {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.reasoning-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.reasoning-value.rsi-overbought { color: var(--down); }
.reasoning-value.rsi-oversold { color: var(--up); }
.reasoning-value.rsi-neutral { color: var(--text); }

/* ── Suppressed-signal callout ─────────────────────────────────────────── */
.suppressed-callout {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #2a1f0a;
  border: 1px solid var(--warn);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.suppressed-icon { font-size: 20px; color: var(--warn); flex-shrink: 0; }
.suppressed-text { font-size: 15px; line-height: 1.4; }

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
}

.chart-panel { grid-row: span 2; }
.signal-log-panel { grid-column: 1 / -1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin: 0;
}
.source-tag { font-family: var(--font-mono); font-size: 14px; color: var(--text-faint); }

.chart { height: 480px; }

.stat-row { display: flex; gap: 16px; margin-bottom: 16px; }
.stat { flex: 1; }
.stat-label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  display: block;
}
.stat-value--sm { font-size: 17px; font-weight: 500; color: var(--text); }

/* ── Animated stat transitions (idea 13) - same flash idiom as the price
   ticker, plus a brief scale pulse so a change is unmistakable ─────────── */
.stat-value { transition: color 0.3s ease; }
.stat-value.flash-up { color: var(--up); animation: value-pulse 0.5s ease; }
.stat-value.flash-down { color: var(--down); animation: value-pulse 0.5s ease; }
@keyframes value-pulse {
  0% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ── Win/Loss stats strip (idea 9) + All Time / Since Restart toggle (idea 10) ─ */
.stats-strip {
  margin: 4px 0 20px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}
.stats-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.scope-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 3px;
}
.scope-btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.scope-btn:hover { color: var(--text-dim); }
.scope-btn.active { background: var(--panel-border); color: var(--text); }

.stats-chip-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stats-chip {
  flex: 1;
  min-width: 84px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 10px 12px;
  text-align: center;
}
.stats-chip-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}
.stats-chip-label {
  display: block;
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.trade-controls { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--panel-border); }
.field-label { display: block; font-size: 14px; color: var(--text-dim); margin-bottom: 6px; }
.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.field-input:focus { outline: none; border-color: var(--accent); }

.trade-buttons { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }
.btn--buy { background: var(--up); color: #06231b; }
.btn--sell { background: var(--down); color: #2b0a0c; }

.trade-msg { font-size: 14px; margin: 10px 0 0; min-height: 18px; color: var(--text-dim); }
.trade-msg.error { color: var(--down); }
.trade-msg.success { color: var(--up); }

/* ── Logs, with visibly obvious scrollbars ────────────────────────────── */
.log {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: var(--text-faint) var(--panel-border);
}
.log::-webkit-scrollbar { width: 14px; }
.log::-webkit-scrollbar-track { background: var(--panel-border); border-radius: 8px; }
.log::-webkit-scrollbar-thumb {
  background: var(--text-faint);
  border-radius: 8px;
  border: 3px solid var(--panel-border);
}
.log::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.log-empty { color: var(--text-faint); font-size: 14px; }
.log-entry {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--panel-border);
  font-family: var(--font-mono);
  font-size: 14px;
}
.log-entry:last-child { border-bottom: none; }
.log-side { font-weight: 600; text-transform: uppercase; }
.log-side.buy { color: var(--up); }
.log-side.sell { color: var(--down); }
.log-detail { color: var(--text-dim); }

/* ── Trade Log as readable cards (idea 8) ────────────────────────────────
   Replaces dense .log-entry rows for the Trade Log specifically - each
   trade gets its own card with a clear visual hierarchy (side + source,
   then the dollar headline, then the BTC/price/time detail). */
.log--cards { display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.trade-card {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--panel-border);
  border-radius: 7px;
  padding: 12px 14px;
}
.trade-card--buy { border-left-color: var(--up); }
.trade-card--sell { border-left-color: var(--down); }
.trade-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.trade-card-source {
  font-size: 13px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.trade-card-amount {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.trade-card-detail { font-size: 14px; color: var(--text-dim); margin-bottom: 4px; }
.trade-card-time { font-size: 13px; color: var(--text-faint); }

/* ── Connection indicator dot ─────────────────────────────────────────── */
.ticker-updated { display: inline-flex; align-items: center; gap: 7px; }
.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.conn-dot.online { background: var(--up); box-shadow: 0 0 6px var(--up); }
.conn-dot.offline {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
  animation: pulse-dot 1s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Equity mini-chart ─────────────────────────────────────────────────── */
.equity-wrap { margin: 4px 0 20px; }
.equity-chart {
  height: 90px;
  margin-top: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
}

/* ── Secondary panel row: strategy config / alerts / kill-switch ────────── */
.grid--secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.config-list { display: flex; flex-direction: column; gap: 10px; }
.config-row { display: flex; justify-content: space-between; font-size: 14px; }
.config-row .reasoning-label { font-size: 13px; }
.config-value { font-family: var(--font-mono); font-weight: 600; color: var(--text); }

.badge-inline {
  font-size: 13px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 6px 10px;
  margin: 0 0 14px;
}
.badge-inline--warn { color: var(--warn); border-color: var(--warn); }

.panel--disabled { opacity: 0.75; }
.kill-switch-mock { display: flex; flex-direction: column; gap: 10px; }
.kill-switch-mock .field-input:disabled {
  cursor: not-allowed;
  color: var(--text-faint);
}
.btn--disabled {
  background: var(--panel-border);
  color: var(--text-faint);
  cursor: not-allowed;
}
.btn--disabled:hover { opacity: 1; }

/* ── Exchange panel (idea 22+23) ─────────────────────────────────────── */
.exchange-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.exchange-name { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text); }
.badge-inline--live { color: var(--up); border-color: var(--up); }
.exchange-planned-label {
  font-size: 13px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}
.exchange-planned { display: flex; flex-direction: column; gap: 8px; }
.exchange-planned .badge-inline { margin: 0; }

/* ── Toast notifications ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  max-width: 380px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--neutral);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease;
}
.toast.buy { border-left-color: var(--up); }
.toast.sell { border-left-color: var(--down); }
.toast strong { display: block; margin-bottom: 3px; }
.toast.fade-out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ── Responsive breakpoints (idea 18) ────────────────────────────────────
   Three tiers: a light tablet tightening, the existing single-column
   collapse, and a phone tier that stacks controls and trims paddings so
   nothing overflows or requires horizontal scrolling on a narrow screen. */
@media (max-width: 1100px) {
  .app { padding: 0 18px 32px; }
  .chart { height: 380px; }
  .stats-chip-row { flex-wrap: wrap; }
  .stats-chip { min-width: 120px; }
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .chart-panel { grid-row: auto; }
  .reasoning-panel { grid-template-columns: 1fr 1fr; }
  .grid--secondary { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app { padding: 0 14px 28px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px 0; }
  .ticker { text-align: left; width: 100%; }
  .ticker-price { font-size: 24px; }

  .signal-banner { flex-wrap: wrap; row-gap: 8px; }
  .signal-reason { flex-basis: 100%; order: 3; }
  .signal-countdown { flex-basis: 100%; order: 4; }

  .reasoning-panel { flex-direction: column; gap: 10px; }
  .reasoning-panel { grid-template-columns: unset; }
  .reasoning-row { justify-content: space-between; width: 100%; }

  .stat-row { flex-direction: column; gap: 12px; }
  .trade-buttons { flex-direction: column; }
  .chart { height: 280px; }

  .stats-strip-head { flex-direction: column; align-items: flex-start; }
  .scope-toggle { width: 100%; }
  .scope-btn { flex: 1; text-align: center; }
  .stats-chip { min-width: 0; }

  .exchange-row { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Signal History rows (.log-entry) were squeezing badge + reason + time
     onto one cramped line at phone widths - stack them instead. */
  .log-entry { flex-direction: column; align-items: flex-start; gap: 4px; }
  .log-entry .log-detail { width: 100%; }

  .toast-container { left: 14px; right: 14px; max-width: none; bottom: 14px; }
}
