/* Shared styles for the portfolio tracker mockups */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --success-text: #006300;
  --critical-text: #b42f2f;

  /* categorical: SPY, QLD, SGOV - fixed by entity */
  --series-spy: #2a78d6;
  --series-qld: #eb6834;
  --series-sgov: #1baf7a;
  --series-muted: #c3c2b7;

  /* status */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  /* diverging arms for drift */
  --div-neg: #e34948;
  --div-pos: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --success-text: #0ca30c;
    --critical-text: #e66767;
    --series-spy: #3987e5;
    --series-qld: #d95926;
    --series-sgov: #199e70;
    --series-muted: #383835;
    --div-neg: #e66767;
    --div-pos: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --success-text: #0ca30c;
  --critical-text: #e66767;
  --series-spy: #3987e5;
  --series-qld: #d95926;
  --series-sgov: #199e70;
  --series-muted: #383835;
  --div-neg: #e66767;
  --div-pos: #3987e5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  background: var(--surface-1);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 18px; }
.brand small { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; }
.nav a {
  display: block; padding: 8px 10px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.theme-toggle {
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  border-radius: 8px; padding: 7px 10px; cursor: pointer; font: inherit; text-align: left;
}

main { padding: 24px 32px 48px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--text-secondary); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 6px 12px; font: inherit; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  border-radius: 8px; padding: 7px 14px; font: inherit; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 0;
}
.card h2 { font-size: 14px; margin: 0 0 2px; font-weight: 600; }
.card .sub { color: var(--text-muted); font-size: 12px; margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.stat-label { color: var(--text-secondary); font-size: 12px; }
.stat-value { font-size: 26px; font-weight: 650; margin: 2px 0; letter-spacing: -0.01em; }
.hero-value { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; }
.delta-up { color: var(--success-text); font-weight: 600; }
.delta-down { color: var(--critical-text); font-weight: 600; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }

/* status pill: icon + label, never color alone */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px 3px 8px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.pill.good .dot { background: var(--good); }
.pill.warn .dot { background: var(--warning); }
.pill.crit .dot { background: var(--critical); }

/* meter */
.meter { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* stacked allocation bar */
.stackbar { display: flex; gap: 2px; height: 14px; margin: 8px 0; }
.stackbar span { display: block; height: 100%; }
.stackbar span:first-child { border-radius: 4px 0 0 4px; }
.stackbar span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--grid); }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tr.group td { background: var(--surface-2); font-weight: 600; }

.tag {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border);
}
.ticker { font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* callout */
.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface-1); border-radius: 10px; padding: 12px 16px;
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
}
.callout strong { display: block; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .direct-label { fill: var(--text-secondary); font-size: 12px; font-weight: 600; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 150px;
  opacity: 0; transition: opacity .08s;
}
.tooltip .tt-title { color: var(--text-muted); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; }
.tooltip .tt-row span { color: var(--text-secondary); }

.table-toggle {
  border: 0; background: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px;
  text-decoration: underline; padding: 0;
}

/* form */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.field input, .field select {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}

.mockup-note {
  font-size: 12px; color: var(--text-muted); border: 1px dashed var(--border);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 16px;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .cols-4, .cols-3 { grid-template-columns: repeat(2, 1fr); }
  .cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  main { padding: 16px; }
}

/* ---------- markets ---------- */
.nav-section {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 14px 10px 4px;
}
.search {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; width: 260px;
}
.sidebar .search { width: 100%; margin-bottom: 6px; }
.tile-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.tile-name { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.tile-value { font-size: 20px; font-weight: 650; margin: 2px 0; }
a.row-link { color: inherit; text-decoration: none; }
a.row-link:hover .ticker { text-decoration: underline; }
.div-row { display: grid; grid-template-columns: 150px 1fr 64px; align-items: center; gap: 10px; padding: 5px 0; }
.div-track { position: relative; height: 14px; }
.div-track .zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--baseline); }
.div-track .bar { position: absolute; top: 2px; height: 10px; }
.div-track .bar.pos { left: 50%; border-radius: 0 4px 4px 0; background: var(--div-pos); }
.div-track .bar.neg { right: 50%; border-radius: 4px 0 0 4px; background: var(--div-neg); }
.div-row:hover .bar { filter: brightness(1.15); }
.range-track { position: relative; height: 6px; background: var(--surface-2); border-radius: 999px; margin: 8px 0 4px; }
.range-track .mark { position: absolute; top: -4px; width: 3px; height: 14px; border-radius: 2px; background: var(--text-primary); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.event-kind { font-size: 11px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 28px 28px 24px; }
.login-card .brand { padding: 0 0 18px; }
.login-card .field input { width: 100%; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-error {
  color: var(--critical-text); font-size: 13px; margin: 0 0 12px;
  border: 1px solid var(--critical); border-radius: 8px; padding: 8px 10px;
}
