/* Autonomous Traders dashboard, dark by default.
   Palette: accent yellow #ecad0a, blue #209dd7, purple #753991, elegant greys.
   No gradients in the chrome; the only gradient is the soft fill under each chart. */

:root {
  --yellow: #ecad0a;
  --blue: #209dd7;
  --purple: #753991;

  --trend-up: #3fbf7f;
  --trend-down: #e05560;
  --flash-up: #6fe8a8;
  --flash-down: #ff7b86;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-raised: #171a21;
  --bg-sunk: #0a0c10;
  --border: #2a2f38;
  --grid: #232831;
  --fg: #e6e8ec;
  --fg-muted: #8a93a1;
  --fg-dim: #5d6672;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-raised: #ffffff;
  --bg-sunk: #edf0f3;
  --border: #dadfe5;
  --grid: #e8ecf1;
  --fg: #1a1d22;
  --fg-muted: #5b6470;
  --fg-dim: #8a93a1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
}

body {
  display: grid;
  grid-template-columns: 220px 1fr;
  /* Lock the body to the viewport so each panel row (1fr) has a concrete size for
     uPlot's canvas to fill. Without this, 1fr falls back to content height and the
     chart collapses to its minimum. */
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  color: var(--yellow);
}

.brand-sub {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--fg-dim);
}

.market {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.market-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
}

.market-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}

.market-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fg-muted);
}
.market-badge[data-source="simulator"] .market-dot { background: var(--blue); }
.market-badge[data-source="massive"] .market-dot { background: var(--trend-up); }

.market-status {
  font-size: 11px;
  color: var(--fg-muted);
}

.returns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.returns-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
}
.returns-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.returns-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.returns-name {
  font-size: 13px;
  color: var(--fg);
}
.returns-pct {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
}
.returns-pct[data-trend="up"] { color: var(--trend-up); }
.returns-pct[data-trend="down"] { color: var(--trend-down); }

.sidebar-spacer { flex: 1; }

.theme-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}
.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
}

.theme-icon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }

/* ---- Panels ---- */

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.panel {
  display: grid;
  grid-template-rows: auto 2fr auto 1fr;
  gap: 10px;
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 0;
  overflow: hidden;
  transition: border-color 200ms, box-shadow 200ms;
}

/* Live leader: the trader with the highest portfolio value right now. */
.panel[data-leader="true"] {
  border-color: var(--yellow);
  box-shadow: 0 0 0 1px var(--yellow), 0 0 20px color-mix(in srgb, var(--yellow) 22%, transparent);
}

.panel-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.panel-name {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg);
}

.panel-sub {
  font-size: 11px;
  color: var(--fg-muted);
}

.panel-value {
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.15;
  margin-top: 4px;
}
.panel-value[data-trend="up"] { color: var(--trend-up); }
.panel-value[data-trend="down"] { color: var(--trend-down); }

.panel-pnl {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
}
.panel-pnl[data-trend="up"] { color: var(--trend-up); }
.panel-pnl[data-trend="down"] { color: var(--trend-down); }

.panel-strategy {
  margin-top: 6px;
  max-width: 94%;
  font-size: 11px;
  line-height: 1.4;
  color: var(--fg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: default;
}
.panel-strategy.empty {
  color: var(--fg-dim);
  font-style: italic;
}

.panel-chart {
  min-height: 120px;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ---- Heatmap ---- */

.heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 44px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  overflow: hidden;
}
.heatmap[data-empty="true"]::before {
  content: "No holdings";
  display: grid;
  place-items: center;
  width: 100%;
  color: var(--fg-dim);
  font-size: 12px;
}

.heatmap-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 8px;
  min-width: 56px;
  flex-basis: 0;
  border-radius: 4px;
  background: color-mix(in srgb, var(--trend-up) 20%, var(--bg-sunk));
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  transition: background 180ms;
}
.heatmap-tile[data-pnl="down"] {
  background: color-mix(in srgb, var(--trend-down) 20%, var(--bg-sunk));
}

.heatmap-ticker {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.heatmap-value {
  font-size: 11px;
  color: var(--fg-muted);
}

.heatmap-tile.flash-up { animation: flash-up 600ms ease-out; }
.heatmap-tile.flash-down { animation: flash-down 600ms ease-out; }

@keyframes flash-up {
  0%   { background: var(--flash-up); }
  100% { background: color-mix(in srgb, var(--trend-up) 20%, var(--bg-sunk)); }
}
@keyframes flash-down {
  0%   { background: var(--flash-down); }
  100% { background: color-mix(in srgb, var(--trend-down) 20%, var(--bg-sunk)); }
}

/* ---- Log ---- */

.log {
  height: 100%;
  overflow-y: auto;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.log-empty {
  color: var(--fg-dim);
  font-style: italic;
}

.log-row {
  display: flex;
  gap: 6px;
  padding: 1px 0;
  align-items: baseline;
  white-space: nowrap;
}
.log-time {
  flex: none;
  color: var(--fg-dim);
}
.log-type {
  flex: none;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.log-text {
  flex: 1;
  min-width: 0;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Bottom row: activity log + recent trades ---- */

.panel-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 0;
}
.panel-col {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  min-height: 0;
}
.panel-col-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
}

.txns {
  height: 100%;
  overflow-y: auto;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
}
.txn-empty {
  color: var(--fg-dim);
  font-style: italic;
}
.txn-row {
  display: flex;
  gap: 6px;
  padding: 1px 0;
  align-items: baseline;
  white-space: nowrap;
}
.txn-date {
  flex: none;
  color: var(--fg-dim);
}
.txn-side {
  flex: none;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.txn-side[data-side="buy"] { color: var(--trend-up); }
.txn-side[data-side="sell"] { color: var(--trend-down); }
.txn-detail {
  flex: 1;
  min-width: 0;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
