/* Neutral zinc chrome throughout; the chart is the only colorful thing. */
:root {
  /* Workspace-style palette: near-black chrome, teal up / red-pink down as
     the only accent colors, both reserved for market data. */
  --bg: #0d0e10; --panel: #151619; --edge: #26282c;
  --text: #e6e8ea; --dim: #8b8e94; --up: #21b3a4; --down: #f0426c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
header {
  display: flex; flex-direction: column;
  background: var(--panel); border-bottom: 1px solid var(--edge);
}
#topline {
  display: flex; align-items: center; gap: 22px;
  padding: 7px 14px 0 14px;
}
#controls {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 8px 14px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .12em; font-size: 12px; color: var(--dim); }
.brand-mark {
  color: #0d0e10; background: var(--up); border-radius: 3px;
  padding: 1px 5px; font-weight: 800; letter-spacing: .04em;
}
select, input, button {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--edge); border-radius: 3px; padding: 5px 8px;
  font: inherit;
}
button { cursor: pointer; }
input#symbol { width: 200px; }
nav#timeframes { display: flex; gap: 2px; }
nav#timeframes button { border-radius: 4px; padding: 4px 8px; color: var(--dim); border-color: transparent; }
nav#timeframes button.active { color: var(--text); background: var(--edge); }
#status { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }
#ind-active {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--edge);
}
#ind-active:not(:empty) { padding: 6px 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--edge); border-radius: 12px; padding: 2px 4px 2px 10px;
  color: var(--text); font-size: 12px;
}
.chip button {
  border: none; background: transparent; color: var(--dim);
  padding: 0 6px; font-size: 13px; line-height: 1;
}
.chip button:hover { color: var(--down); }
#keybar {
  padding: 6px 12px; background: #232327; border-bottom: 1px solid var(--edge);
  color: var(--dim); display: flex; gap: 8px; align-items: center;
}
#keybar a { color: var(--text); }
main { flex: 1; display: flex; min-height: 0; }
aside#watchlist {
  width: 230px; overflow-y: auto; background: var(--panel);
  border-right: 1px solid var(--edge); padding: 4px 0;
}
.wrow {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 12px; cursor: pointer; border-left: 2px solid transparent;
}
.wrow:hover { background: var(--edge); }
.wrow.active { border-left-color: var(--up); background: #1b1d20; }
.wsym { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wprice { font-variant-numeric: tabular-nums; color: var(--dim); }
.wprice.up { color: var(--up); } .wprice.down { color: var(--down); }
section#charts { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chart-wrap { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; }
#legend {
  position: absolute; top: 8px; left: 10px; z-index: 5;
  color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums;
  pointer-events: none; text-shadow: 0 1px 2px #000;
}
#legend b { color: var(--text); font-weight: 600; }
#panes { display: flex; flex-direction: column; }
.pane { height: 140px; border-top: 1px solid var(--edge); position: relative; }
.pane .pane-label {
  position: absolute; top: 4px; left: 10px; z-index: 5;
  color: var(--dim); font-size: 11px; pointer-events: none;
}
#editor {
  position: fixed; inset: 0; z-index: 50; display: flex;
  background: rgba(0, 0, 0, .55);
}
#ed-side {
  width: 240px; background: var(--panel); border-right: 1px solid var(--edge);
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  margin-left: auto;
}
#ed-main {
  width: min(680px, 60vw); background: var(--bg);
  display: flex; flex-direction: column; padding: 10px; gap: 8px;
}
#ed-bar { display: flex; gap: 8px; }
#ed-bar input { flex: 1; font-family: ui-monospace, monospace; }
#ed-src {
  flex: 1; resize: none; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #141416; color: var(--text); border: 1px solid var(--edge);
  border-radius: 6px; padding: 10px; white-space: pre; overflow: auto;
}
#ed-err {
  max-height: 130px; overflow: auto; color: var(--down);
  background: #1c1416; border: 1px solid #3a2326; border-radius: 6px;
  padding: 8px; font: 11px/1.5 ui-monospace, monospace; white-space: pre-wrap;
}
.ed-item {
  padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--dim);
  display: flex; justify-content: space-between; gap: 6px;
}
.ed-item:hover, .ed-item.active { background: var(--edge); color: var(--text); }
.ed-item .ed-broken { color: var(--down); }
#backtest {
  height: 46vh; display: flex; border-top: 2px solid var(--edge);
  background: var(--panel);
}
#bt-editor { display: flex; flex-direction: column; width: 46%; padding: 8px; gap: 6px; }
#bt-bar { display: flex; align-items: center; gap: 8px; }
.bt-title { font-weight: 600; margin-right: auto; }
#bt-run { background: #10665c; border-color: #1a7a6e; color: #d6f5f0; }
#bt-run:hover { background: #1a7a6e; }
#bt-src {
  flex: 1; resize: none; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #141416; color: var(--text); border: 1px solid var(--edge);
  border-radius: 6px; padding: 10px; white-space: pre; overflow: auto;
}
#bt-err {
  max-height: 90px; overflow: auto; color: var(--down);
  background: #1c1416; border: 1px solid #3a2326; border-radius: 6px;
  padding: 8px; font: 11px/1.5 ui-monospace, monospace; white-space: pre-wrap;
}
#bt-results { flex: 1; display: flex; flex-direction: column; padding: 8px; gap: 6px; min-width: 0; }
#bt-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat {
  background: var(--bg); border: 1px solid var(--edge); border-radius: 6px;
  padding: 5px 10px; min-width: 92px;
}
.stat .k { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .03em; }
.stat .v { font-variant-numeric: tabular-nums; font-size: 14px; }
.stat .v.pos { color: var(--up); } .stat .v.neg { color: var(--down); }
#bt-equity-label { color: var(--dim); font-size: 11px; }
#bt-equity { flex: 1; min-height: 0; }
.hidden { display: none !important; }

/* MY DATA: a full section of the terminal */
#mydata {
  flex: 1; display: flex; align-items: flex-start; padding: 34px;
  min-height: 0; overflow-y: auto; background: var(--bg);
}
/* the add form is an isolated box, Workspace-card style */
#md-form {
  display: flex; flex-direction: column; gap: 10px; width: 430px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 4px;
  padding: 18px;
}
#md-drop {
  border: 1px dashed #34373c; border-radius: 4px; padding: 26px 12px;
  text-align: center; color: var(--dim); font-size: 12px; line-height: 1.7;
}
#md-drop span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
#md-list-wrap { flex: 1; min-width: 0; max-width: 720px; }
.md-title { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.md-help { font-size: 11px; color: var(--dim); margin: 0; line-height: 1.5; }
.md-row { display: flex; gap: 8px; }
#md-err { color: #fca5a5; font-size: 11px; white-space: pre-wrap; margin: 0; }
#md-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.md-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #232327; border-radius: 4px; padding: 6px 8px; font-size: 12px;
}
.md-meta { display: flex; flex-direction: column; }
.md-meta span { color: var(--dim); font-size: 10px; }
.md-empty { color: var(--dim); font-size: 12px; }

/* backtest run options + quant results */
#bt-options {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  font-size: 11px; color: var(--dim);
}
#bt-options label { display: inline-flex; align-items: center; gap: 4px; }
#bt-options input[type="date"] { width: 118px; }
#bt-options input[type="number"] { width: 64px; }
#bt-wf-params { width: 170px; font-family: ui-monospace, monospace; }
#bt-mc-opts, #bt-wf-opts { display: inline-flex; gap: 10px; }
#bt-quant { overflow-x: auto; }
.qt { border-collapse: collapse; font-size: 12px; width: 100%; }
.qt th, .qt td { padding: 4px 8px; text-align: right; border-bottom: 1px solid #2e2e33; }
.qt th:first-child, .qt td:first-child { text-align: left; }
.qt th { color: var(--dim); font-weight: 500; font-size: 10px; text-transform: uppercase; }
.qt-note { color: var(--dim); font-size: 10px; margin-top: 4px; }

/* Workspace-style horizontal section menu */
#rail { display: flex; gap: 4px; }
.rail-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--dim); font-size: 11px; font-weight: 600;
  letter-spacing: .09em; padding: 4px 10px 8px 10px;
}
.rail-btn:hover { color: var(--text); }
.rail-btn.active { color: var(--text); border-bottom-color: var(--up); }

/* data manager v2 */
.md-folder { color: var(--dim); font-size: 11px; letter-spacing: .04em; margin: 6px 0 2px; }
.md-kind { font-size: 9px; letter-spacing: .06em; border-radius: 2px; padding: 1px 4px; margin-right: 4px; }
.md-kind.series { background: #23324a; color: #9ec5ff; }
.md-kind.ohlcv { background: #123a34; color: #7fe0d2; }
.md-use { display: block; color: var(--dim); font-size: 10px; margin-top: 2px; }
.md-actions { display: flex; gap: 4px; }
.md-actions button { padding: 2px 7px; font-size: 11px; }
#md-preview { background: #101114; border: 1px solid var(--edge); border-radius: 3px; padding: 8px; font-size: 11px; color: var(--dim); line-height: 1.5; }
#md-preview b, #md-preview code { color: var(--text); }
#bt-datasets .bt-check { margin-right: 6px; }

.wrow .md-kind { margin-right: 6px; }
.wrow .md-actions { visibility: hidden; }
.wrow:hover .md-actions { visibility: visible; }

/* VSCode-explorer-style library tree */
.tree-head { padding: 8px 12px 4px; color: var(--dim); font-size: 10px; letter-spacing: .08em; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  cursor: pointer; font-size: 12px; color: var(--text); user-select: none;
}
.tree-row:hover { background: var(--edge); }
.tree-folder { color: #c8cad0; }
.tree-chevron { width: 10px; color: var(--dim); font-size: 10px; }
.tree-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-row .md-actions { visibility: hidden; }
.tree-row:hover .md-actions { visibility: visible; }
