/* Terminal design system.
   One monospace family, a near-black ground, hairline borders, and colour
   reserved for meaning: orange is the brand and the active state, green and
   red are direction, everything else is a shade of grey. */

:root {
  --bg: #0a0a0a;
  --panel: #101010;
  --panel-alt: #141414;
  --border: #272727;
  --border-strong: #3a3a3a;
  --text: #e6e6e6;
  --text-dim: #8b8b8b;
  --text-faint: #5f5f5f;
  --accent: #e8a33d;
  --accent-dim: #8a6524;
  --up: #4ade80;
  --down: #f87171;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --row: 26px;
}

:root[data-theme="light"] {
  --bg: #fbfbf9;
  --panel: #ffffff;
  --panel-alt: #f4f4f2;
  --border: #dedede;
  --border-strong: #c4c4c4;
  --text: #1a1a1a;
  --text-dim: #5c5c5c;
  --text-faint: #8a8a8a;
  --accent: #b9761a;
  --accent-dim: #d9ab6a;
  --up: #16a34a;
  --down: #dc2626;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.masthead {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.brand-block { display: flex; align-items: baseline; gap: 14px; flex: 1 1 auto; min-width: 0; }
.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  white-space: nowrap;
}
.brand-sub {
  display: block;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 2px;
}
.asof { font-size: 12px; letter-spacing: 0.08em; color: var(--text-dim); white-space: nowrap; }
.masthead-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

select.control {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 6px;
}
.build-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 3px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  white-space: nowrap;
}
.build-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.updated { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 11px 14px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Layout ---------- */
main { padding: 14px 12px 60px; }
.section-title {
  font-size: 15px;
  letter-spacing: 0.12em;
  margin: 14px 2px 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.section-title .muted { color: var(--text-dim); font-weight: 400; font-size: 12px; letter-spacing: 0.08em; }

.grid { display: grid; gap: 10px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 12px 12px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Stat strip ---------- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 2px;
}
.stat {
  padding: 8px 12px 10px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.stat:last-child { border-right: none; }
.stat-label { font-size: 10px; letter-spacing: 0.1em; color: var(--text-dim); }
.stat-value { font-size: 19px; font-weight: 600; margin-top: 1px; }
.stat-note { font-size: 11px; color: var(--text-dim); }

/* ---------- Period switch ---------- */
.period-switch { display: flex; gap: 2px; }
.period-switch button {
  appearance: none;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  cursor: pointer;
  border-radius: 2px;
}
.period-switch button:hover { color: var(--text); }
.period-switch button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-weight: 700;
}

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data th {
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 400;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { padding: 3px 6px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.035); white-space: nowrap; }
:root[data-theme="light"] table.data td { border-bottom-color: rgba(0,0,0,0.05); }
table.data tbody tr:hover { background: var(--panel-alt); }
table.data tr.emphasis td { border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); font-weight: 700; }
.sub { display: block; font-size: 10.5px; color: var(--text-dim); }

/* Specificity matters here. `table.data td` is 0-0-1-2 and a bare `.wrap-cell`
   is 0-0-1-0, so the plain class lost to the nowrap default and silently did
   nothing: every sub-sector name ("Technology Hardware, Storage & Peripherals")
   stayed on one line, the movers table grew 70px wider than its half-width
   card, and the page scrolled sideways. The selector has to out-rank the
   default it is meant to override. */
table.data td.wrap-cell { white-space: normal; }
/* A sector name is one long unbroken token often enough to matter. */
table.data td.wrap-cell { overflow-wrap: anywhere; }

/* Last line of defence: a table whose content genuinely cannot fit scrolls
   inside its own card instead of pushing the whole page sideways. Sideways
   scroll on a dashboard hides the right-hand column of every other panel. */
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-dim); }
.dim { color: var(--text-dim); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 300px; }
.chart.tall { height: 380px; }
.chart.short { height: 170px; }

/* ---------- Treemap ---------- */
.treemap { position: relative; width: 100%; height: 620px; overflow: hidden; border: 1px solid var(--border); }
.tm-group { position: absolute; border: 1px solid var(--border-strong); overflow: hidden; }
.tm-group-label {
  position: absolute; top: 0; left: 0; right: 0; height: 15px;
  font-size: 9.5px; letter-spacing: 0.1em; color: var(--text-dim);
  padding: 2px 4px; background: var(--bg); z-index: 2; pointer-events: none;
  white-space: nowrap; overflow: hidden;
}
.tm-tile { position: absolute; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: default; }
.tm-tile:hover { outline: 1px solid var(--text); outline-offset: -1px; z-index: 3; }
.tm-sym { font-weight: 700; line-height: 1.05; }
.tm-val { line-height: 1.05; opacity: 0.95; }

.tooltip {
  position: fixed;
  z-index: 50;
  background: #000;
  border: 1px solid var(--border-strong);
  padding: 7px 9px;
  font-size: 11.5px;
  pointer-events: none;
  max-width: 320px;
  display: none;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6);
}
:root[data-theme="light"] .tooltip { background: #fff; }
.tooltip .t-head { font-weight: 700; margin-bottom: 2px; }
.tooltip .t-meta { color: var(--text-dim); font-size: 10.5px; margin-bottom: 4px; }
.tooltip table { border-collapse: collapse; font-size: 11px; width: 100%; }
.tooltip td { padding: 0 0 0 14px; text-align: right; }
.tooltip td:first-child { padding: 0; text-align: left; color: var(--text-dim); }

/* ---------- Forms ---------- */
.field-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 10px; letter-spacing: 0.1em; color: var(--text-dim); }
.field input, .field select {
  background: var(--panel-alt);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 7px;
  border-radius: 2px;
  min-width: 90px;
}
.field input:focus, .field select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
button.action {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0a0a0a;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 5px 16px;
  border-radius: 2px;
  cursor: pointer;
}
button.action:hover { filter: brightness(1.1); }
.field-note { font-size: 11px; color: var(--text-dim); align-self: center; }

input.model {
  background: #171b26;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  padding: 2px 5px;
  width: 100%;
  border-radius: 1px;
}
:root[data-theme="light"] input.model { background: #eef1f7; }
input.model:focus { outline: 1px solid var(--accent); }

/* ---------- Notices ---------- */
.notice {
  border: 1px solid var(--accent-dim);
  border-left: 3px solid var(--accent);
  background: rgba(232, 163, 61, 0.06);
  padding: 8px 11px;
  font-size: 11.5px;
  color: var(--text-dim);
  margin: 8px 0;
}
.gap {
  border: 1px solid var(--down);
  border-left: 3px solid var(--down);
  background: rgba(248, 113, 113, 0.07);
  padding: 8px 11px;
  font-size: 11.5px;
  margin: 8px 0;
}
.note-text { font-size: 11px; color: var(--text-faint); margin-top: 8px; line-height: 1.5; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  margin-top: 26px;
  padding: 12px 16px 30px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.65;
}
footer .brandline { color: var(--text-dim); }
footer a { color: var(--text-dim); }

/* Links inside content inherit the terminal palette; the browser default is
   unreadable on a near-black ground. */
a { color: var(--accent); text-decoration: none; word-break: break-all; }
a:hover { text-decoration: underline; }
.src-ok { color: var(--up); }
.src-partial { color: var(--accent); }
.src-error { color: var(--down); }

.loading { padding: 40px 10px; color: var(--text-dim); font-size: 12px; }
.hidden { display: none !important; }
