/* research-trend v2 — dark-default quant dashboard, light mode supported.
   Palette per dataviz reference instance. */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222221;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5;  /* blue    — share / primary series */
  --s2: #008300;  /* green */
  --s3: #d55181;  /* magenta */
  --s4: #c98500;  /* yellow */
  --s5: #199e70;  /* aqua    — influx */
  --s6: #d95926;  /* orange  — star influx */
  --s7: #9085e9;  /* violet */
  --s8: #e66767;  /* red */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #0ca30c;
  --down: #e66767;
  --band: rgba(57, 135, 229, 0.16);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;
  --s2: #008300;
  --s3: #e87ba4;
  --s4: #eda100;
  --s5: #1baf7a;
  --s6: #eb6834;
  --s7: #4a3aa7;
  --s8: #e34948;
  --up: #006300;
  --down: #d03b3b;
  --band: rgba(42, 120, 214, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--s1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; cursor: pointer; }
.brand .dot { color: var(--s1); }
.searchwrap { position: relative; flex: 1; max-width: 520px; }
.searchwrap input {
  width: 100%; padding: 7px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; outline: none;
}
.searchwrap input:focus { border-color: var(--s1); }
.suggestbox {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden; display: none; max-height: 420px; overflow-y: auto;
}
.suggestbox.open { display: block; }
.sugg {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer;
}
.sugg:hover, .sugg.active { background: var(--surface-2); }
.sugg .nm { font-weight: 600; }
.sugg .acro { color: var(--muted); font-size: 12px; }
.sugg .meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sugg .qrow { color: var(--ink-2); font-style: italic; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  color: var(--ink-2); padding: 6px 10px; border-radius: 7px; font-weight: 500;
}
.nav a.active, .nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.themebtn {
  background: none; border: 1px solid var(--border); color: var(--ink-2);
  border-radius: 7px; padding: 5px 9px; cursor: pointer; font: inherit;
}

/* ---------------- layout ---------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 18px; }
.metastrip {
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline;
  color: var(--muted); font-size: 12.5px; margin-bottom: 14px;
}
.metastrip b { color: var(--ink-2); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--ink-2); font-weight: 600; }
.sub { color: var(--muted); font-size: 12.5px; }

/* ---------------- filter row ---------------- */
.filterrow {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0;
}
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 5px 12px;
  cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); font-weight: 600; }
.filterrow select {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px;
}
.spacer { flex: 1; }

/* ---------------- radar table ---------------- */
table.radar { width: 100%; border-collapse: collapse; }
table.radar th {
  text-align: left; color: var(--muted); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 6px 10px; border-bottom: 1px solid var(--baseline);
  white-space: nowrap;
}
table.radar td {
  padding: 9px 10px; border-bottom: 1px solid var(--grid);
  vertical-align: middle; font-variant-numeric: tabular-nums;
}
table.radar tr.trow { cursor: pointer; }
table.radar tr.trow:hover td { background: var(--surface-2); }
.tname { font-weight: 650; color: var(--ink); font-variant-numeric: normal; }
.tacro { color: var(--muted); font-weight: 400; }
.tsub { color: var(--muted); font-size: 11.5px; margin-top: 1px; font-variant-numeric: normal; }
.badge-new {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--page);
  background: var(--s7); border-radius: 4px; padding: 1px 5px; margin-left: 6px;
  vertical-align: 2px; letter-spacing: 0.03em;
}
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--up); }
.neg { color: var(--down); }
.pctbar { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pctbar .bar {
  flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2);
  overflow: hidden;
}
.pctbar .fill { height: 100%; border-radius: 3px; background: var(--s6); }
.pctbar .lbl { font-size: 12px; color: var(--ink-2); white-space: nowrap; width: 68px; }
.stagechip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px;
}
.stagechip.surging { border-color: var(--good); }
.stagechip.accumulating { border-color: var(--s1); }
.stagechip.crowded { border-color: var(--warning); }
.stagechip.cooling { opacity: 0.75; }
.sentinel { height: 40px; }
.loadmore { text-align: center; color: var(--muted); padding: 12px; }

/* ---------------- term page ---------------- */
.termhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.aliasline { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.catchip {
  display: inline-block; font-size: 11px; color: var(--ink-2);
  background: var(--surface-2); border-radius: 5px; padding: 1px 7px; margin-left: 6px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.tile .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.chartbox { min-height: 100px; }
.relchips { display: flex; flex-wrap: wrap; gap: 6px; }
.relchips .chip { font-size: 12.5px; padding: 4px 10px; }
.receipts { margin: 0; padding: 0; list-style: none; }
.receipts li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--grid); font-size: 13px;
}
.receipts li:last-child { border-bottom: none; }
.receipts .prior { color: var(--muted); font-variant-numeric: tabular-nums; }
.papers { margin: 0; padding: 0; list-style: none; }
.papers li { padding: 8px 0; border-bottom: 1px solid var(--grid); }
.papers li:last-child { border-bottom: none; }
.papers .pt { font-weight: 550; }
.papers .pm { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button {
  background: none; border: none; color: var(--muted); font: inherit; font-size: 13px;
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
}
.tabs button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.outcome-note { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.outcome-note b { color: var(--ink); }
.small-note { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
details.tblview { margin-top: 8px; color: var(--muted); font-size: 12.5px; }
details.tblview table { border-collapse: collapse; margin-top: 6px; width: 100%; }
details.tblview td, details.tblview th {
  padding: 3px 8px; border-bottom: 1px solid var(--grid); text-align: right;
  font-variant-numeric: tabular-nums;
}
details.tblview th:first-child, details.tblview td:first-child { text-align: left; }

/* ---------------- compare ---------------- */
.pillrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; font-size: 13px;
}
.pill .swatch { width: 10px; height: 10px; border-radius: 3px; }
.pill button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }

/* ---------------- methodology ---------------- */
.method p { color: var(--ink-2); max-width: 76ch; }
.method .grid2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .method .grid2 { grid-template-columns: 1fr; } }
kbd.term {
  background: var(--surface-2); border-radius: 4px; padding: 0 5px;
  font-family: inherit; font-size: 13px;
}

.center { text-align: center; color: var(--muted); padding: 30px 0; }
.err { color: var(--critical); }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 26px 0 40px; }
