:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;     /* balance / growth / gains */
  --series-2: #eb6834;     /* equity */
  --neg: #e34948;          /* losses, drawdown marks */
  --up: #006300;           /* positive money, as text */
  --down: #b42828;         /* negative money, as text */
  --good: #0ca30c;
  --warn: #fab219;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --neg: #e66767;
    --up: #2fbf2f;
    --down: #f07a7a;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --neg: #e66767;
  --up: #2fbf2f;
  --down: #f07a7a;
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.num, table td.r, table th.r { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
}
.login form {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 20px; color: var(--text-2); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--page);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; width: 100%; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.error { color: var(--down); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* ---------- Dashboard shell ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px 48px; }
header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 18px 0 14px;
}
header.top h1 { margin: 0; font-size: 20px; }
header.top .acct { color: var(--text-2); font-size: 14px; }
header.top .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.ok .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.live.stale .dot { background: var(--warn); }
.live.dead .dot { background: var(--critical); }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.icon-btn:hover { background: var(--surface-2); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--page); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h2 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.card .sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }

/* Hero + tiles */
.hero-row { display: grid; grid-template-columns: minmax(240px, 1fr) 3fr; gap: 14px; margin-bottom: 14px; }
.hero .label { color: var(--text-2); font-size: 14px; }
.hero .value { font-size: 52px; font-weight: 650; line-height: 1.1; margin: 6px 0 8px; letter-spacing: -0.02em; }
.hero .note { color: var(--muted); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.stack { display: grid; gap: 14px; margin-bottom: 14px; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .endlabel { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.legend i.box { height: 10px; width: 10px; border-radius: 2px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); padding: 8px 10px; font-size: 12px;
  min-width: 140px; white-space: nowrap;
}
.tooltip .t-head { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row i { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .t-row b { font-size: 13px; font-variant-numeric: tabular-nums; }
.tooltip .t-row span { color: var(--text-2); }
.range-btns { display: inline-flex; gap: 4px; }
.range-btns button { font-size: 12px; padding: 3px 8px; }

/* Stats list */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin: 0; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th.r, td.r { text-align: right; }
tbody tr:hover td { background: var(--surface-2); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; letter-spacing: 0.02em; }
.pill.buy { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--text); }
.pill.sell { background: color-mix(in srgb, var(--series-2) 18%, transparent); color: var(--text); }
.table-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.table-tools select { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--page); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.empty-row td { text-align: center; color: var(--muted); padding: 22px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); margin: 0 0 12px; overflow-x: auto; overflow-y: hidden; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

.banner { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.banner.info { border-left-color: var(--accent); }
.banner code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 900px) {
  .hero-row, .grid-2 { grid-template-columns: 1fr; }
  .hero .value { font-size: 44px; }
}
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile .value { font-size: 19px; }
}

/* When you make money */
.grid-2.flush { margin-bottom: 0; }
h3.mini { margin: 4px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.highlights { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.highlight { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.highlight .label { font-size: 12px; color: var(--text-2); }
.highlight .value { font-size: 16px; font-weight: 600; margin-top: 2px; }
.highlight .foot { font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin: 0; }
