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

:root {
  --bg:        #080c14;
  --bg2:       #0d1117;
  --bg3:       #0a0f1a;
  --border:    #1a2332;
  --border2:   #0f172a;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --text4:     #475569;
  --text5:     #334155;
  --green:     #22c55e;
  --red:       #f87171;
  --blue:      #60a5fa;
  --purple:    #a78bfa;
  --orange:    #f97316;
  --yellow:    #facc15;
  --nav-h:     52px;
  --stat-h:    57px;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
}

/* ── NAV ── */
nav {
  height: var(--nav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  letter-spacing: -0.03em;
  margin-right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex-shrink: 0;
}
.logo-dot.pulse { animation: pulse-anim 2s infinite; }
@keyframes pulse-anim { 0%,100%{opacity:1} 50%{opacity:0.35} }

.nav-item {
  padding: 6px 13px;
  border-radius: 6px;
  color: var(--text3);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.78rem;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-item:hover { color: var(--text); background: var(--border); }
.nav-item.active { color: var(--text); background: var(--border); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  background: #052e16;
  color: var(--green);
  border: 1px solid #15803d44;
}
.mode-badge.live {
  background: #1a0505;
  color: var(--red);
  border-color: #991b1b44;
}

.conn-badge {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text4);
  cursor: default;
  letter-spacing: 0.03em;
}
.conn-badge.connected { color: var(--green); }
.conn-badge.error     { color: var(--red); }

.kill-btn {
  background: #1a0505;
  color: var(--red);
  border: 1px solid #7f1d1d;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}
.kill-btn:hover { background: #450a0a; }

.clock {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
  min-width: 68px;
  text-align: right;
}

/* ── STAT BAR ── */
.stat-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: var(--stat-h);
  background: var(--border);
  gap: 1px;
  border-bottom: 1px solid var(--border);
}
.stat {
  background: var(--bg2);
  padding: 9px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-label {
  font-size: 0.6rem;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-val.green { color: var(--green); }
.stat-val.red   { color: var(--red); }
.stat-sub {
  font-size: 0.6rem;
  color: var(--text4);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.stat-sub.green { color: #4ade8099; }
.stat-sub.red   { color: #f8717199; }

.market-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text4);
}
.market-dot.open   { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse-anim 2s infinite; }
.market-dot.closed { background: var(--red); }
.market-dot.pre    { background: var(--yellow); }

/* ── MAIN 3-COL ── */
.main {
  display: grid;
  grid-template-columns: 254px 1fr 272px;
  height: calc(100vh - var(--nav-h) - var(--stat-h));
  overflow: hidden;
}

/* ── LEFT PANEL ── */
.left-panel {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-section {
  padding: 13px 13px 10px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.panel-section.flex-grow {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel-section.alerts-section {
  overflow-y: auto;
  max-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.panel-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text4);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.live-pill {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.03em;
}

/* Watchlist */
.watch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
  border-left: 2px solid transparent;
}
.watch-item:hover { background: #131d2e; }
.watch-item.active {
  background: #132235;
  border-left-color: var(--blue);
  padding-left: 6px;
}
.watch-sym  { font-weight: 700; color: var(--text); font-size: 0.8rem; }
.watch-name { font-size: 0.58rem; color: var(--text4); margin-top: 1px; }
.watch-right { text-align: right; }
.watch-price { font-weight: 600; color: var(--text); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.watch-chg  { font-size: 0.6rem; font-variant-numeric: tabular-nums; }
.watch-chg.up { color: var(--green); }
.watch-chg.dn { color: var(--red); }
.mini-bar { height: 2px; border-radius: 1px; margin-top: 3px; width: 60px; background: var(--border2); }
.mini-bar-fill { height: 100%; border-radius: 1px; transition: width 0.3s; }

/* Signal Feed */
.signal-item {
  display: flex;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border2);
}
.signal-item:last-child { border-bottom: none; }
.sig-badge {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  height: fit-content;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.sig-badge.buy  { background: #052e16; color: var(--green); border: 1px solid #15803d44; }
.sig-badge.sell { background: #1a0505; color: var(--red);   border: 1px solid #991b1b44; }
.sig-badge.hold { background: #1a1a05; color: var(--yellow);border: 1px solid #a1620744; }
.sig-body { flex: 1; min-width: 0; }
.sig-sym    { font-weight: 700; color: var(--text); font-size: 0.75rem; }
.sig-strat  { font-size: 0.6rem; color: var(--text3); margin-top: 2px; }
.sig-right  { text-align: right; flex-shrink: 0; }
.sig-conf   { font-size: 0.62rem; color: var(--text2); font-variant-numeric: tabular-nums; }
.conf-bar   { width: 42px; height: 3px; background: var(--border); border-radius: 2px; margin-top: 4px; }
.conf-fill  { height: 100%; border-radius: 2px; }

/* ── CENTER ── */
.center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg3);
}

.chart-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg3);
  min-height: 0;
}

#chartCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.chart-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
  background: linear-gradient(180deg, var(--bg3) 55%, transparent);
  pointer-events: none;
}
.chart-header * { pointer-events: auto; }
.chart-sym   { font-size: 1rem; font-weight: 800; color: #fff; }
.chart-price { font-size: 1.2rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.chart-chg   {
  font-size: 0.75rem;
  color: var(--green);
  background: #052e16;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid #15803d44;
  font-variant-numeric: tabular-nums;
}
.chart-chg.negative { color: var(--red); background: #1a0505; border-color: #991b1b44; }

.tf-row { margin-left: auto; display: flex; gap: 3px; }
.tf-btn {
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text4);
  cursor: pointer;
  background: var(--border2);
  border: 1px solid var(--border);
  transition: all 0.12s;
}
.tf-btn:hover { color: var(--text2); }
.tf-btn.active { color: var(--blue); background: #1e3a5f; border-color: #3b82f644; }

.ind-row {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 6px 16px 8px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(0deg, var(--bg3) 55%, transparent);
  z-index: 2;
  pointer-events: none;
}
.ind-chip { display: flex; align-items: center; gap: 4px; }
.ind-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ind-dot.ema20  { background: #60a5fa; }
.ind-dot.ema50  { background: #a78bfa; }
.ind-dot.vwap   { background: var(--orange); }
.ind-label { font-size: 0.6rem; color: var(--text4); }
.ind-val   { font-size: 0.66rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ind-val.blue   { color: var(--blue); }
.ind-val.purple { color: var(--purple); }
.ind-val.orange { color: var(--orange); }
.ind-val.yellow { color: var(--yellow); }
.ind-val.green  { color: var(--green); }
.ind-val.red    { color: var(--red); }
.ind-val.muted  { color: var(--text2); }

/* ── POSITIONS TABLE ── */
.positions-area {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  max-height: 200px;
}

.pos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pos-tabs { display: flex; gap: 4px; }
.pos-tab {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text4);
  padding: 4px 11px;
  border-radius: 5px;
  cursor: pointer;
  background: none;
  border: none;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.pos-tab:hover { color: var(--text2); background: var(--border); }
.pos-tab.active { color: var(--text); background: var(--border); }
.pos-count {
  font-size: 0.6rem;
  background: #1e3a5f;
  color: var(--blue);
  padding: 1px 6px;
  border-radius: 20px;
}
.close-all-btn {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--red);
  background: #1a0505;
  border: 1px solid #7f1d1d44;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
}

.table-wrap {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text5);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 6px 14px;
  text-align: left;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}
td {
  font-size: 0.7rem;
  color: var(--text2);
  padding: 7px 14px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
td.sym   { font-weight: 700; color: var(--text); }
td.green { color: var(--green); font-weight: 600; }
td.red   { color: var(--red);   font-weight: 600; }
.sl-bar  { height: 2px; background: var(--border); border-radius: 1px; margin-top: 4px; }
.sl-fill { height: 100%; border-radius: 1px; background: var(--green); }
.action-btn {
  background: #1a0505;
  color: var(--red);
  border: 1px solid #7f1d1d33;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 4px;
  cursor: pointer;
}
.empty-row { text-align: center; color: var(--text4); padding: 20px !important; }

/* ── RIGHT PANEL ── */
.right-panel {
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Risk Monitor */
.risk-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 10px;
}
.risk-row:last-child { margin-bottom: 0; }
.risk-label { font-size: 0.65rem; color: var(--text3); margin-bottom: 4px; }
.risk-progress {
  width: 160px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.risk-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.risk-val-text { font-size: 0.68rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* PnL Sparkline */
.sparkline { width: 100%; height: 52px; overflow: visible; display: block; }

/* Strategy Cards */
.strat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
  margin-bottom: 8px;
}
.strat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.strat-name { font-size: 0.73rem; font-weight: 700; color: var(--text); }
.toggle {
  width: 30px; height: 16px;
  background: var(--green);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
}
.toggle.off { background: var(--border); }
.toggle::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: white;
  top: 2px; left: 2px;
  transition: left 0.2s;
}
.toggle:not(.off)::after { left: 16px; }
.strat-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
}
.strat-stat {
  background: var(--bg2);
  border-radius: 5px;
  padding: 5px 6px;
  text-align: center;
}
.strat-stat-label { font-size: 0.53rem; color: var(--text4); text-transform: uppercase; letter-spacing: 0.05em; }
.strat-stat-val   { font-size: 0.76rem; font-weight: 700; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.strat-stat-val.green  { color: var(--green); }
.strat-stat-val.yellow { color: var(--yellow); }
.strat-stat-val.red    { color: var(--red); }

/* Alerts */
.alert-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--border2);
}
.alert-item:last-child { border-bottom: none; }
.alert-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.alert-text { font-size: 0.67rem; color: var(--text2); line-height: 1.4; }
.alert-time { font-size: 0.57rem; color: var(--text5); margin-top: 2px; }
