:root {
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;       /* NAV line */
  --delta-good: #0ca30c;
  --delta-bad: #d03b3b;
  --buy: #0ca30c;
  --sell: #d03b3b;
  --accent: #3987e5;
}

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

body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.layout { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  width: 250px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.brand { font-size: 15px; font-weight: 700; padding: 4px 8px 14px; letter-spacing: .2px; }
.brand span { color: var(--text-muted); font-weight: 400; }
.acct {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.acct:hover { background: var(--surface-1); }
.acct.active { background: var(--surface-1); border-color: var(--border); }
.acct .a-label { font-weight: 600; }
.acct .a-sub { color: var(--text-muted); font-size: 12px; }
.btn {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger-ghost { color: var(--delta-bad); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- main ---- */
.main { flex: 1; padding: 22px 28px; min-width: 0; }
.main-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.main-head h1 { font-size: 19px; }
.main-head .sub { color: var(--text-muted); font-size: 13px; }
.main-head .spacer { flex: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 8px 14px; cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent; font-weight: 600; font-size: 13px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.tile .t-label { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.tile .t-value { font-size: 24px; font-weight: 700; }
.tile .t-delta { font-size: 12px; margin-top: 4px; }
.up { color: var(--delta-good); }
.down { color: var(--delta-bad); }

/* ---- cards / charts ---- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.card h2 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }
.card h2 .h-note { color: var(--text-muted); font-weight: 400; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; }
.tooltip {
  position: absolute; pointer-events: none; display: none;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 12px;
  color: var(--text-primary); white-space: nowrap; z-index: 5;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.tooltip .tt-l { color: var(--text-muted); }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th {
  text-align: right; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  padding: 6px 10px; border-bottom: 1px solid var(--baseline);
}
td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid); font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: none; }
td .sym { font-weight: 600; }
.side-buy { color: var(--buy); font-weight: 600; }
.side-sell { color: var(--sell); font-weight: 600; }
.muted { color: var(--text-muted); }

/* ---- forms / modal ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 20;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; width: 460px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 600; }
.field input, .field select {
  width: 100%; background: var(--page); color: var(--text-primary);
  border: 1px solid var(--baseline); border-radius: 7px;
  padding: 9px 11px; font-size: 13px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 10px; }
.form-row .field { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-error { color: var(--delta-bad); font-size: 12px; margin-top: 10px; display: none; }

.empty {
  color: var(--text-muted); text-align: center; padding: 60px 20px; font-size: 14px;
}
.pill {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 99px; padding: 2px 10px; font-size: 12px; margin: 2px 4px 2px 0;
  color: var(--text-secondary);
}
pre.code {
  background: var(--page); border: 1px solid var(--baseline); border-radius: 8px;
  padding: 14px; font-size: 12px; overflow-x: auto; color: var(--text-secondary);
  line-height: 1.55;
}
ol.steps { padding-left: 20px; color: var(--text-secondary); font-size: 13px; }
ol.steps li { margin-bottom: 6px; }
.note { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.controls-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.badge {
  display: inline-block; border-radius: 6px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
}
.badge.strong_buy { background: rgba(12,163,12,.18); color: var(--delta-good); }
.badge.buy { background: rgba(12,163,12,.10); color: var(--delta-good); }
.badge.neutral { background: var(--surface-2); color: var(--text-muted); }
.badge.reduce { background: rgba(208,59,59,.10); color: var(--delta-bad); }
.badge.exit { background: rgba(208,59,59,.18); color: var(--delta-bad); }
.btn.mini { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.src-demo { color: var(--text-muted); font-size: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--text-secondary); border: none;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.seg button.active { background: var(--surface-2); color: var(--text-primary); }
