/* PTM Fundamental Dashboard: shared styles. Colours are role tokens; dark mode is its own set of steps. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6e6c66;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --spark: #2a78d6;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --serious: #ec835a;
  --serious-ink: #a8431b;
  --critical: #d03b3b;
  --critical-ink: #b02a2a;
  --neutral-ink: #52514e;
  --radius: 10px;
  --header-h: 60px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --shadow-lg: 0 1px 2px rgba(11, 11, 11, 0.04), 0 16px 40px rgba(11, 11, 11, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* polarity (diverging): long = blue, short = red, neutral = grey */
  --pos: #2a78d6;
  --pos-ink: #1c5cab;
  --pos-wash: rgba(42, 120, 214, 0.1);
  --neg: #e34948;
  --neg-ink: #b02a2a;
  --neg-wash: rgba(227, 73, 72, 0.1);
  --neu: #898781;
  --neu-wash: rgba(137, 135, 129, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --hairline: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --spark: #5598e7;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --serious-ink: #ec835a;
    --critical-ink: #e66767;
    --neutral-ink: #c3c2b7;
    --shadow: none;
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --pos: #3987e5;
    --pos-ink: #86b6ef;
    --pos-wash: rgba(57, 135, 229, 0.16);
    --neg: #e66767;
    --neg-ink: #f08a8a;
    --neg-wash: rgba(230, 103, 103, 0.16);
    --neu-wash: rgba(137, 135, 129, 0.2);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --hairline: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --spark: #5598e7;
  --good-ink: #0ca30c;
  --warning-ink: #fab219;
  --serious-ink: #ec835a;
  --critical-ink: #e66767;
  --neutral-ink: #c3c2b7;
  --shadow: none;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --pos: #3987e5;
  --pos-ink: #86b6ef;
  --pos-wash: rgba(57, 135, 229, 0.16);
  --neg: #e66767;
  --neg-ink: #f08a8a;
  --neg-wash: rgba(230, 103, 103, 0.16);
  --neu-wash: rgba(137, 135, 129, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 8px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header: brand, grouped menu (nav.js), actions; one panel under 880px ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--hairline);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
  flex: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-ink) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
}

.brand small {
  color: var(--muted);
  font-weight: 450;
}

.nav {
  margin-right: auto;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link,
.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  padding: 7px 11px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.nav-link:hover,
.nav-trigger:hover,
.nav-trigger[aria-expanded="true"] {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-link[aria-current="page"],
.nav-group:has([aria-current="page"]) .nav-trigger {
  color: var(--ink);
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-trigger .chev {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.nav-trigger[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.nav-group {
  position: relative;
}

.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: -6px;
  width: 330px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 14px;
  box-shadow:
    0 12px 32px rgba(11, 11, 11, 0.12),
    0 2px 6px rgba(11, 11, 11, 0.06);
}

/* a bridge over the gap so the pointer can reach the menu */
.nav-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.nav-trigger[aria-expanded="true"] + .nav-menu {
  display: grid;
  animation: menu-in 0.14s ease-out;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.nav-menu-head {
  margin: 4px 10px 4px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-menu a {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--ink);
}

.nav-menu a b {
  font-size: 14.5px;
  font-weight: 600;
}

.nav-menu a span {
  font-size: 13px;
  color: var(--muted);
}

.nav-menu a:hover {
  background: var(--surface-2);
}

.nav-menu a[aria-current="page"] {
  background: var(--pos-wash);
}

.nav-menu a[aria-current="page"] b {
  color: var(--accent-ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover,
.icon-btn[aria-current="page"] {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-toggle {
  display: none;
}

.nav-toggle .i-close,
.nav-toggle[aria-expanded="true"] .i-open {
  display: none;
}

.nav-toggle[aria-expanded="true"] .i-close {
  display: inline;
}

@media (max-width: 1040px) {
  .brand-long {
    display: none;
  }
}

@media (max-width: 880px) {
  .nav-toggle {
    display: inline-flex;
  }

  .header-actions {
    margin-left: auto;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    box-shadow: 0 16px 32px rgba(11, 11, 11, 0.1);
    padding: 8px 16px 16px;
  }

  .site-header.is-open .nav {
    display: block;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .nav-link {
    display: flex;
    padding: 11px 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
  }

  .nav-link[aria-current="page"] {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .nav-group {
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    margin: 4px 0;
    padding: 4px 0;
  }

  .nav-trigger {
    display: none;
  }

  .nav-menu,
  .nav-trigger[aria-expanded="true"] + .nav-menu {
    display: grid;
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
    animation: none;
  }

  .nav-menu::before {
    display: none;
  }

  .nav-menu-head {
    margin: 8px 10px 2px;
  }
}

/* ---------- page ---------- */
main {
  flex: 1;
  padding: 28px 0 48px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lede {
  margin: 0 0 24px;
  color: var(--ink-2);
  max-width: 72ch;
}

h2 {
  font-size: 18px;
  margin: 36px 0 4px;
  letter-spacing: -0.01em;
}

.section-note {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 14px;
  max-width: 80ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* ---------- stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.tile {
  padding: 14px 16px;
}

.tile-label {
  color: var(--ink-2);
  font-size: 13px;
}

.tile-value {
  font-size: 30px;
  font-weight: 650;
  line-height: 1.2;
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.tile-value .of {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}

.tile-foot {
  margin-top: 6px;
  font-size: 13px;
}

/* ---------- status badges: icon + label, never colour alone ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 9px 5px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--neutral-ink);
  white-space: nowrap;
}

.badge .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: var(--muted);
  flex: none;
}

.badge.good {
  color: var(--good-ink);
}
.badge.good .dot {
  background: var(--good);
}
.badge.warning {
  color: var(--warning-ink);
}
.badge.warning .dot {
  background: var(--warning);
  color: #3d2a00;
}
.badge.serious {
  color: var(--serious-ink);
}
.badge.serious .dot {
  background: var(--serious);
  color: #3a1406;
}
.badge.critical {
  color: var(--critical-ink);
}
.badge.critical .dot {
  background: var(--critical);
}

/* ---------- manual data cards ---------- */
.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 12px;
  align-items: start;
}

.manual-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manual-card header {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.manual-card .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.manual-card h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.3;
}

.manual-card .file {
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.manual-card,
.issues li {
  overflow-wrap: anywhere;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--ink-2);
  margin: 0;
}

.facts b {
  color: var(--ink);
  font-weight: 600;
}

.tracked {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.tracked li {
  font-size: 13px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

.tracked .t-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.tracked .t-name {
  font-weight: 600;
  color: var(--ink);
}

.tracked .t-reason {
  color: var(--ink-2);
}

.tracked .t-next {
  color: var(--muted);
  font-size: 12.5px;
}

.issues {
  margin: 0;
  padding: 10px 12px 10px 28px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface-2);
}

.issues li + li {
  margin-top: 4px;
}

.issues.errors {
  border-left: 3px solid var(--critical);
}

details.warnings summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}

details.warnings .issues {
  margin-top: 8px;
  border-left: 3px solid var(--warning);
}

.card-actions {
  margin-top: auto;
  font-size: 13px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
}

.seg button {
  font: inherit;
  font-size: 13.5px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 32px;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--ring);
}

.search {
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
  flex: 1 1 220px;
  max-width: 320px;
  min-height: 38px;
}

/* ---------- series table ---------- */
.table-card {
  overflow: hidden;
}

table.series {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.series th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

table.series td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

table.series tr.group td {
  background: var(--surface-2);
  font-weight: 650;
  font-size: 13px;
  color: var(--ink-2);
  padding: 8px 14px;
}

table.series td.num,
table.series th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.s-label {
  font-weight: 600;
}

.s-meta {
  font-size: 12.5px;
  color: var(--muted);
}

.s-meta a {
  color: var(--muted);
}

.s-error {
  font-size: 12.5px;
  color: var(--serious-ink);
  margin-top: 2px;
}

.unit {
  color: var(--muted);
  font-size: 12px;
  margin-left: 3px;
}

.spark {
  display: block;
  width: 120px;
  height: 32px;
  overflow: visible;
}

.spark-cell {
  position: relative;
  width: 136px;
}

.tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--ring);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12.5px;
  line-height: 1.35;
  white-space: nowrap;
}

.tooltip strong {
  display: block;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-2);
}

.notice {
  padding: 14px 16px;
  border-left: 3px solid var(--warning);
}

/* ---------- shared panels ---------- */
.panel {
  padding: 18px 20px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- home (index.html, home.js) ---------- */
main.home {
  padding-top: 0;
}

.home-hero {
  position: relative;
  padding: 56px 0 52px;
  border-bottom: 1px solid var(--hairline);
  background:
    radial-gradient(55% 75% at 92% 0%, var(--pos-wash), transparent 70%),
    radial-gradient(45% 60% at 0% 100%, var(--neu-wash), transparent 75%);
  overflow: hidden;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--hairline) 1px, transparent 1px), linear-gradient(90deg, var(--hairline) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(70% 90% at 25% 10%, #000, transparent 75%);
  mask-image: radial-gradient(70% 90% at 25% 10%, #000, transparent 75%);
  opacity: 0.6;
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: 44px;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-2);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent);
  animation: live 2.4s ease-in-out infinite;
}

@keyframes live {
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 0%, transparent);
  }
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(34px, 4.6vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 750;
}

.hero-copy h1 .hl {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-ink) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lede {
  margin: 20px 0 0;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 56ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

.cta:hover {
  background: var(--surface-2);
}

.cta-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--page);
}

.cta-primary:hover {
  background: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.cta-note {
  font-weight: 450;
  opacity: 0.72;
}

.cta-note:empty {
  display: none;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 36px;
  margin: 36px 0 0;
}

.hero-facts div {
  display: flex;
  flex-direction: column-reverse;
}

.hero-facts dd {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-facts dt {
  font-size: 13px;
  color: var(--muted);
}

/* the bias card in the hero */
.bias-hero {
  padding: 22px 24px 20px;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}

.bh-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.bh-top h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.chip {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 999px;
}

.chip:empty {
  display: none;
}

.bh-state {
  margin: 10px 0 0;
  font-size: 54px;
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.bh-state.pos {
  color: var(--pos-ink);
}

.bh-state.neg {
  color: var(--neg-ink);
}

.bh-score {
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 14px;
}

.bh-score b {
  font-size: 20px;
  font-weight: 700;
}

.delta {
  color: var(--ink-2);
}

.delta.up {
  color: var(--pos-ink);
}

.delta.down {
  color: var(--neg-ink);
}

.bh-meter {
  position: relative;
  height: 40px;
  margin: 20px 0 2px;
}

.bh-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 8px;
}

.bh-track [class^="z-"] {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
}

.z-short {
  left: 0;
  background: var(--neg-wash);
}

.z-neutral {
  margin: 0 2px;
  background: var(--neu-wash);
}

.z-long {
  right: 0;
  background: var(--pos-wash);
}

.z-short.on {
  background: var(--neg);
}

.z-neutral.on {
  background: var(--neu);
}

.z-long.on {
  background: var(--pos);
}

.bh-mark {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ink);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(11, 11, 11, 0.25);
}

.bh-ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  font-size: 11.5px;
  color: var(--muted);
}

.bh-ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.bh-ticks span:first-child {
  transform: none;
}

.bh-ticks span:last-child {
  transform: translateX(-100%);
}

.bh-fig {
  margin: 12px 0 0;
}

.bh-trail {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.bh-fig figcaption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.bh-fig figcaption span:first-child,
.bh-fig figcaption span:last-child {
  white-space: nowrap;
}

.bh-fig figcaption span.muted {
  text-align: center;
}

.bh-foot {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.bh-link,
.more {
  display: inline-flex;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.bh-link {
  margin-top: 14px;
}

.bh-link:hover,
.more:hover {
  text-decoration: underline;
}

/* loading placeholders */
.skeleton,
.skeleton-card {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--hairline) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-card {
  height: 150px;
  border-radius: 14px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.sk-title {
  height: 54px;
  width: 62%;
  margin-top: 12px;
}

.sk-line {
  height: 14px;
  width: 42%;
  margin-top: 14px;
}

.sk-chart {
  height: 140px;
  margin-top: 20px;
}

/* sections */
.home-sec {
  margin-top: 44px;
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.sec-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.sec-head p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

.block-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.block-card {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 16px 18px;
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.block-card:hover {
  transform: translateY(-2px);
  border-color: var(--axis);
  box-shadow: var(--shadow-lg);
}

.bc-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
}

.bc-score {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.bc-score.pos {
  color: var(--pos-ink);
}

.bc-score.neg {
  color: var(--neg-ink);
}

.bc-bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
}

.bc-bar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--axis);
}

.bc-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: var(--neu);
}

.bc-fill.pos {
  background: var(--pos);
}

.bc-fill.neg {
  background: var(--neg);
}

.bc-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bc-dot,
.hc-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 10px;
  background: var(--neu-wash);
  color: var(--ink-2);
}

.bc-dot.pos,
.hc-icon.pos {
  background: var(--pos-wash);
  color: var(--pos-ink);
}

.bc-dot.neg,
.hc-icon.neg {
  background: var(--neg-wash);
  color: var(--neg-ink);
}

.bc-dot.none {
  background: transparent;
  border: 1px dashed var(--axis);
  color: var(--muted);
}

.bc-foot {
  font-size: 12.5px;
  color: var(--muted);
}

.home-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  font-size: 14px;
}

.ha-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--warning);
  color: #3d2a00;
  font-size: 12px;
  font-weight: 800;
}

.home-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  border-radius: 14px;
}

.home-card .more {
  margin-top: auto;
}

.hc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.hc-head h2 {
  margin: 0;
  font-size: 16px;
}

.hc-head .muted {
  font-size: 12.5px;
}

.hc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.hc-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
}

.hc-list li:first-child {
  padding-top: 2px;
  border-top: 0;
}

.hc-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}

.hc-main a {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.hc-main a:hover {
  text-decoration: underline;
}

.hc-title {
  font-size: 14px;
  font-weight: 600;
}

.hc-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.hc-feeds {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--pos-wash);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.hc-feeds.manual {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning-ink);
}

.hc-empty {
  font-size: 14px;
  color: var(--muted);
}

.hc-date {
  flex: none;
  display: grid;
  justify-items: center;
  width: 58px;
  padding: 4px 0 5px;
  border-radius: 9px;
  background: var(--surface-2);
  line-height: 1.15;
}

.hc-date b {
  font-size: 17px;
}

.hc-date span {
  white-space: nowrap;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.rg-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.rg-map {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 0 0 16px 16px;
}

.rg-map span:not(.rg-x):not(.rg-y) {
  display: grid;
  place-items: center;
  height: 46px;
  border-radius: 7px;
  font-size: 10.5px;
  background: var(--surface-2);
  color: var(--muted);
}

.rg-map span.on {
  background: var(--pos-wash);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.rg-y,
.rg-x {
  position: absolute;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.rg-y {
  left: 0;
  top: 0;
  bottom: 16px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.rg-x {
  left: 16px;
  right: 0;
  bottom: 0;
}

.rg-now {
  display: grid;
  gap: 2px;
}

.rg-now .muted {
  font-size: 12.5px;
}

.rg-now b {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.rg-level {
  font-size: 12.5px;
  color: var(--ink-2);
}

.rg-odds {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.rg-odds-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.rg-odds-head b {
  font-size: 15px;
  color: var(--ink);
}

.rg-meter {
  height: 8px;
  border-radius: 4px;
  background: var(--pos-wash);
  overflow: hidden;
}

.rg-meter span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.process {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-radius: 16px;
}

.step-n {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-ink);
}

.step h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.step p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.step p.step-stat {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.step p.step-stat:empty {
  display: none;
}

.step p.step-lessons {
  margin-top: auto;
  font-size: 12.5px;
  color: var(--muted);
}

.step-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-links a {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.step-links a:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 28px;
  padding: 14px 20px;
  border-radius: 14px;
}

.status-bar dl {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  margin: 0;
}

.status-bar dl div {
  display: grid;
  gap: 3px;
}

.status-bar dt {
  font-size: 12px;
  color: var(--muted);
}

.status-bar dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .block-row,
  .process {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .home-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .home-hero {
    padding: 32px 0;
  }

  .hero-lede {
    font-size: 16px;
  }

  .cta {
    flex: 1 1 auto;
    justify-content: center;
  }

  .hero-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .hero-facts dd {
    font-size: 22px;
  }

  .bias-hero {
    padding: 18px 18px 16px;
  }

  .bh-state {
    font-size: 44px;
  }

  .block-row {
    gap: 8px;
  }

  .block-card {
    padding: 14px;
  }

  .bc-score {
    font-size: 24px;
  }

  .process {
    grid-template-columns: minmax(0, 1fr);
  }

  .sec-head {
    flex-wrap: wrap;
  }
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-2);
}

.site-footer .wrap {
  padding-top: 18px;
  padding-bottom: 22px;
  display: grid;
  gap: 6px;
}

.disclaimer {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- phone width ---------- */
@media (max-width: 760px) {
  .wrap {
    padding: 0 16px;
  }

  main {
    padding-top: 20px;
  }

  .page-title {
    font-size: 24px;
  }

  .manual-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile-value {
    font-size: 24px;
  }

  .search {
    max-width: none;
    flex-basis: 100%;
  }

  /* the table becomes one card per series */
  table.series thead {
    display: none;
  }

  table.series,
  table.series tbody,
  table.series tr,
  table.series td {
    display: block;
    width: 100%;
  }

  table.series tr.row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--hairline);
  }

  table.series tr.row td {
    padding: 0;
    border: 0;
  }

  table.series td.c-series {
    grid-column: 1 / -1;
  }

  table.series td.c-status {
    grid-column: 1;
    grid-row: 3;
  }

  table.series td.c-spark {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: center;
  }

  table.series td.num {
    text-align: left;
  }

  table.series td.c-last {
    grid-column: 1;
  }

  table.series td.c-age {
    display: none;
  }

  table.series td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--muted);
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Macro Desk ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin: 0 0 16px;
}

.toolbar label {
  font-size: 13.5px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.select,
.btn {
  font: inherit;
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
}

.btn {
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

.bias-card {
  padding: 20px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px 28px;
  align-items: center;
}

.bias-label {
  font-size: 13px;
  color: var(--ink-2);
}

.bias-state {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 2px 0 4px;
}

.bias-state.pos {
  color: var(--pos-ink);
}
.bias-state.neg {
  color: var(--neg-ink);
}

.bias-sub {
  font-size: 13.5px;
  color: var(--ink-2);
}

.meter {
  position: relative;
  height: 46px;
}

.meter-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--neg-wash) 0 37.5%, var(--neu-wash) 37.5% 62.5%, var(--pos-wash) 62.5% 100%);
}

.meter-mark {
  position: absolute;
  top: 6px;
  width: 4px;
  height: 26px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--surface);
}

.meter-ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  font-size: 11.5px;
  color: var(--muted);
}

.meter-ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.blocks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.block-tile {
  padding: 12px 14px;
}

.block-tile .tile-value {
  font-size: 24px;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--neu-wash);
  color: var(--ink-2);
  white-space: nowrap;
}

.score.pos {
  background: var(--pos-wash);
  color: var(--pos-ink);
}
.score.neg {
  background: var(--neg-wash);
  color: var(--neg-ink);
}
.score.none {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--axis);
}

.notes-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.notes-list li {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13.5px;
  border-left: 3px solid var(--warning);
}

.notes-list.changes li {
  border-left-color: var(--accent);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.panel-title {
  margin: 0 0 10px;
  font-size: 15px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
  align-items: start;
}

.signal {
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.signal.awaiting {
  background: var(--surface-2);
}

.signal-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.signal-name {
  font-weight: 650;
  font-size: 14.5px;
  line-height: 1.3;
}

.signal-state {
  font-size: 13px;
  color: var(--ink-2);
}

.signal-reason {
  font-size: 13.5px;
  margin: 0;
  color: var(--ink);
}

.signal-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
}

.signal-flags {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--warning-ink);
}

.strip {
  display: flex;
  gap: 2px;
  height: 14px;
  align-items: stretch;
}

.strip span {
  flex: 1;
  border-radius: 2px;
  background: var(--neu-wash);
}

.strip span.pos {
  background: var(--pos);
}
.strip span.neg {
  background: var(--neg);
}
.strip span.zero {
  background: var(--axis);
}
.strip span.none {
  background: transparent;
  border: 1px solid var(--hairline);
}

.strip-caption {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.override {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}

.override .seg button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.overridden {
  box-shadow: inset 3px 0 0 var(--accent);
}

.chart-card {
  padding: 16px 18px 10px;
}

.chart {
  width: 100%;
  height: 240px;
  display: block;
  touch-action: pan-y;
}

.chart text {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 6px;
}

.key {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 5px;
}

@media (max-width: 760px) {
  .bias-card {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .bias-state {
    font-size: 28px;
  }

  .blocks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .chart {
    height: 200px;
  }
}

/* ---------- indicator pages ---------- */
.detail-link {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.detail-link:hover {
  text-decoration: underline;
}

.ind-head {
  padding: 18px 20px;
  display: grid;
  gap: 10px;
}

.ind-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.ind-title h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.metrics li {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}

.metrics b {
  font-variant-numeric: tabular-nums;
}

.guide h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}

.guide h3:first-child {
  margin-top: 0;
}

.guide ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}

.guide li + li {
  margin-top: 4px;
}

.ranges {
  margin: 20px 0 10px;
}

.panel-chart {
  padding: 14px 16px 10px;
  margin-bottom: 12px;
}

.panel-chart h3 {
  margin: 0 0 2px;
  font-size: 14.5px;
}

.panel-chart .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 6px;
}

.chart.small {
  height: 150px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 10px 14px;
}

.mini-grid h4 {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
}

.swatch-line {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  vertical-align: 3px;
  margin-right: 6px;
}

.score-strip {
  display: flex;
  height: 22px;
  gap: 1px;
}

.score-strip span {
  flex: 1;
  background: var(--neu-wash);
}

.score-strip span.pos {
  background: var(--pos);
}
.score-strip span.neg {
  background: var(--neg);
}
.score-strip span.zero {
  background: var(--axis);
}
.score-strip span.none {
  background: transparent;
}

:root {
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #8e58d6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #a27be6;
  }
}

:root[data-theme="dark"] {
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #a27be6;
}

.toolbar label {
  min-width: 0;
  max-width: 100%;
}

.select {
  max-width: 100%;
  min-width: 0;
}

/* ---------- Global page ---------- */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

table.data th {
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

table.data td {
  text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
}

table.data td.text {
  text-align: left;
  white-space: normal;
  min-width: 220px;
  color: var(--ink-2);
  font-size: 13px;
}

table.data tr:last-child td {
  border-bottom: 0;
}

table.data .sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

table.data .up {
  color: var(--pos-ink);
}

table.data .down {
  color: var(--neg-ink);
}

.reading {
  margin: 0 0 6px;
  font-size: 14.5px;
}

/* ---------- Calendar ---------- */
.window-card {
  margin-top: 12px;
  border-left: 4px solid var(--accent);
}

.plain-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 14px;
}

.plain-list li {
  margin: 3px 0;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-2);
}

.cal-month {
  margin: 18px 0 6px;
  font-size: 15px;
}

.cal-month:first-child {
  margin-top: 0;
}

.cal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cal-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}

.cal-row.in-window {
  background: var(--pos-wash);
}

.cal-row.past {
  opacity: 0.6;
}

.cal-row .sub,
.cal-date .sub {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.cal-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cal-links {
  margin-top: 3px;
  font-size: 13px;
}

.tag {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
}

.imp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hairline);
  flex: none;
}

.imp-high .imp-dot {
  background: var(--accent);
}

.imp-medium .imp-dot {
  background: var(--muted);
}

.cal-marker {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
}

@media (max-width: 520px) {
  .cal-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .cal-date .sub {
    display: inline;
    margin-left: 6px;
  }
}

/* ---------- Screener ---------- */
table.data th.sortable {
  cursor: pointer;
  user-select: none;
}

table.data th.sortable:hover {
  color: var(--ink);
}

table.data tr.muted-row td {
  opacity: 0.55;
}

table.screener-table td:first-child {
  min-width: 170px;
  max-width: 260px;
  white-space: normal;
}

table.screener-table td.text {
  min-width: 140px;
}

.tag-warn {
  background: var(--neg-wash);
  color: var(--neg-ink);
}

.tag + .tag {
  margin-left: 4px;
}

.tag-pos {
  background: var(--pos-wash);
  color: var(--pos-ink);
}

.tag-neg {
  background: var(--neg-wash);
  color: var(--neg-ink);
}

.wrap-seg {
  flex-wrap: wrap;
}

table.data td.text-left {
  text-align: left;
}

table.screener-table td.text {
  min-width: 260px;
}

/* ---------- Trade idea page and Ideas pipeline (Phase 3) ---------- */
.up {
  color: var(--pos-ink);
}

.down {
  color: var(--neg-ink);
}

.tile-value.small {
  font-size: 22px;
}

a.tile-link {
  color: inherit;
  text-decoration: none;
}

a.tile-link:hover {
  border-color: var(--accent);
}

.idea-section,
.idea-bar {
  margin-top: 12px;
}

.idea-bar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 13px;
}

a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.num-input {
  width: 7.5em;
}

.sub-title {
  font-size: 14.5px;
  margin: 18px 0 8px;
}

textarea.note {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}

textarea.note:focus,
.catalyst-row input:focus,
.assume-grid input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.small-note {
  font-size: 13px;
  margin: 0;
}

.callout {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--neg-wash);
  color: var(--neg-ink);
  font-size: 13.5px;
}

.checklist,
.publish,
.profile,
.macro-events {
  margin-top: 12px;
  font-size: 14px;
}

.checklist summary,
.publish summary,
.profile summary,
.macro-events summary {
  cursor: pointer;
}

.checklist ul,
.macro-events ul {
  margin: 8px 0;
}

.profile p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.steps {
  margin: 10px 0;
  padding-left: 22px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

table.data tr.highlight td {
  background: var(--surface-2);
}

table.quant td .sub,
table.targets-table td .sub {
  font-size: 12px;
}

table.targets-table td .tag {
  margin-left: 0;
  display: inline-block;
  margin-top: 3px;
}

.assume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 12px;
}

.assume-grid label {
  display: grid;
  gap: 3px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.assume-grid label.own span::after {
  content: " · yours";
  color: var(--accent-ink);
}

.assume-grid .num-input {
  width: 100%;
  box-sizing: border-box;
}

.catalysts {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.catalyst-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.catalyst-row .grow {
  flex: 1 1 220px;
}

.chart.price-chart {
  height: 320px;
}

.swatch-line.dashed {
  background: repeating-linear-gradient(90deg, var(--pos) 0 5px, transparent 5px 9px) !important;
}

.hist {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
}

.hist text,
.price-chart text {
  font-size: 11px;
  fill: var(--muted);
}

@media (max-width: 640px) {
  .chart.price-chart {
    height: 260px;
  }

  .tile-value.small {
    font-size: 19px;
  }
}

/* ---------- Portfolio Lab (Phase 4) ---------- */
.tick-input {
  width: 7em;
  text-transform: uppercase;
}

table.editor td .seg button {
  min-height: 28px;
  padding: 3px 10px;
}

table.corr td {
  text-align: center;
  min-width: 3.4em;
}

table.corr td.corr-out {
  font-weight: 700;
}

table.editor td .sub {
  max-width: 11em;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  table.editor td,
  table.editor th {
    padding: 6px;
  }

  .tick-input {
    width: 5.5em;
  }

  table.editor td .sub {
    max-width: 6.5em;
  }
}

/* ---------- Macro ideas (Phase 5) ---------- */
.linklike {
  font: inherit;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-ink);
  text-decoration: underline;
  cursor: pointer;
}

.china-check {
  display: grid;
  gap: 6px;
}

.china-check p {
  margin: 0;
}

table.screener-table td.text .tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
}

/* ---------- This week (weekly routine) ---------- */
.routine-head {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.routine-meter {
  height: 10px;
  border-radius: 5px;
  background: var(--neu-wash);
  overflow: hidden;
}

.routine-meter span {
  display: block;
  height: 100%;
  background: var(--good);
}

.routine-step {
  margin-bottom: 12px;
}

.routine-step.is-done {
  opacity: 0.65;
}

.routine-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.routine-step-head .check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.routine-step-head input {
  width: 20px;
  height: 20px;
}

.routine-items {
  margin: 0 0 12px;
}

/* ---------- How to use (guide) ---------- */
.guide-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.guide-toc {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  padding: 12px 10px;
  max-height: calc(100vh - var(--header-h) - 24px);
  overflow-y: auto;
  font-size: 13.5px;
}

.toc-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 4px;
}

.toc-list a {
  color: var(--ink-2);
  text-decoration: none;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--accent-ink);
  font-weight: 600;
}

.guide-toc-mobile {
  display: none;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.guide-sec {
  margin-bottom: 14px;
  scroll-margin-top: 12px;
  line-height: 1.55;
  font-size: 15px;
}

.guide-sec h2 {
  font-size: 20px;
  margin: 0 0 10px;
}

.guide-sec h3 {
  font-size: 16px;
  margin: 22px 0 8px;
}

.guide-sec p {
  margin: 0 0 10px;
}

.guide-points {
  margin: 0 0 10px;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.guide-steps li {
  line-height: 1.5;
}

.guide-callout {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.9;
}

table.data.guide-table td,
table.data.guide-table th {
  white-space: normal;
  text-align: left;
  vertical-align: top;
  min-width: 120px;
}

.shot {
  margin: 8px 0 14px;
}

.shot img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  display: block;
}

.shot figcaption {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* process flow: numbered cards with arrows between them */
.flow {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
  counter-reset: none;
}

.flow li {
  position: relative;
}

.flow li + li::before {
  content: "→";
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
}

.flow a,
.flow li > div {
  display: grid;
  gap: 4px;
  height: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.4;
}

.flow a:hover {
  border-color: var(--accent);
}

.flow span:not(.flow-n) {
  color: var(--ink-2);
}

.flow-n {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* live tools */
.widget {
  padding: 14px 16px;
  margin: 8px 0 14px;
  border-left: 3px solid var(--accent);
}

.w-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.w-field {
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.w-field input {
  width: 100%;
  box-sizing: border-box;
}

.w-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px 18px;
}

.w-slider {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-2);
}

.w-slider input {
  width: 100%;
  accent-color: var(--accent);
}

.w-result {
  margin-top: 12px;
}

.w-big {
  font-size: 16px;
  margin: 6px 0;
}

.w-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.w-cell {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}

.w-cell b {
  font-size: 18px;
}

.w-cell small {
  color: var(--muted);
}

.w-target {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 70px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}

.w-target small {
  display: block;
  color: var(--muted);
}

.w-target-v {
  font-size: 20px;
}

.w-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  text-align: center;
  font-size: 12.5px;
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
}

.w-band span {
  padding: 8px 2px;
}

.band-0 {
  background: var(--pos-wash);
  font-weight: 700;
}

.band-1 {
  background: var(--neu-wash);
}

.band-2 {
  background: var(--neg-wash);
}

.w-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.w-group h4 {
  margin: 0 0 6px;
  font-size: 13.5px;
}

.w-sig {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12.5px;
}

.w-sig-name {
  min-width: 0;
}

.seg.seg-small button {
  min-height: 26px;
  padding: 2px 7px;
  font-size: 12px;
}

.w-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.w-block {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}

.meter-mini {
  position: relative;
  height: 10px;
  margin: 10px 0 12px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--neg-wash) 0 37.5%, var(--neu-wash) 37.5% 62.5%, var(--pos-wash) 62.5% 100%);
}

.meter-mini span {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--ink);
  transition: left 0.2s;
}

.glossary {
  margin: 0;
  display: grid;
  gap: 2px;
}

.glossary dt {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.glossary dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.faq {
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.faq p {
  margin: 8px 0 0;
}

@media (max-width: 860px) {
  .guide-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide-toc {
    display: none;
  }

  .guide-toc-mobile {
    display: block;
  }

  .flow li + li::before {
    content: "↓";
    left: 50%;
    top: -19px;
    transform: translateX(-50%);
  }

  .flow {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Sectors ---------- */
.sec-block {
  margin-top: 18px;
}

.sec-h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

svg.rrg,
svg.bubbles {
  display: block;
  width: 100%;
  height: 420px;
  margin-top: 8px;
  font-size: 12px;
  fill: var(--ink-2);
  font-family: var(--font);
}

svg.bubbles {
  height: 380px;
}

.rrg-quad {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  fill: var(--muted);
}

.rrg-dot {
  cursor: pointer;
  transition: fill-opacity 0.15s;
}

.rrg-dot:hover,
.rrg-dot:focus {
  fill-opacity: 1;
  outline: none;
  stroke: var(--ink);
}

.rrg-label {
  font-size: 10px;
  font-weight: 700;
  fill: #fff;
  pointer-events: none;
}

.swatch-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

.sec-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.sec-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-margin-top: 12px;
}

.sec-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.sec-card-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.sec-etf {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-right: 8px;
}

.sec-rs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.sec-rs > div {
  display: flex;
  flex-direction: column;
}

.sec-big {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.sec-card .sub,
.cand-list .sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sec-card .facts {
  margin: 0;
}

.sec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-variant-numeric: tabular-nums;
}

.breadth {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
  margin-top: 4px;
}

.breadth .b-up {
  background: var(--pos);
}

.breadth .b-flat {
  background: var(--axis);
}

.breadth .b-down {
  background: var(--neg);
}

.sec-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.cand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 10px;
  align-items: start;
}

.cand-card {
  padding: 12px 16px;
  scroll-margin-top: 12px;
}

.cand-card summary {
  cursor: pointer;
}

.cand-card h4 {
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--ink-2);
}

.cand-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cand-list li {
  padding: 6px 0;
  border-top: 1px solid var(--hairline);
}

.cand-list .tag {
  margin-left: 6px;
}

.rrg-label.out {
  fill: var(--ink);
}

.sec-card-head .tag .swatch-dot {
  width: 8px;
  height: 8px;
  margin-right: 4px;
  vertical-align: 0;
}

@media (max-width: 640px) {
  svg.rrg {
    height: 340px;
  }

  svg.bubbles {
    height: 320px;
  }

  .cand-grid,
  .sec-cards {
    grid-template-columns: 1fr;
  }
}

/* ---------- Regime ---------- */
svg.regime-map {
  display: block;
  width: 100%;
  height: 420px;
  margin-top: 8px;
  font-size: 12px;
  fill: var(--ink-2);
  font-family: var(--font);
}

svg.regime-map .map-now {
  font-weight: 700;
  fill: var(--ink);
}

.regime-reason {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

svg.regime-strip {
  display: block;
  width: 100%;
  height: 64px;
  margin-top: 6px;
  font-size: 11.5px;
  fill: var(--ink-2);
  font-family: var(--font);
}

table.heat-table td.heat {
  text-align: center;
  min-width: 78px;
  font-variant-numeric: tabular-nums;
}

table.heat-table td.heat .sub {
  display: block;
}

table.heat-table th {
  text-align: center;
}

table.heat-table th.cur {
  color: var(--ink);
}

table.heat-table th .sub {
  display: block;
  font-weight: 700;
  color: var(--accent-ink);
}

table.heat-table .group-row td {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  color: var(--ink-2);
}

svg.curve-chart {
  display: block;
  width: 100%;
  height: 320px;
  margin-top: 8px;
  font-size: 12px;
  fill: var(--ink-2);
  font-family: var(--font);
}

.curve-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.curve-controls input[type="range"] {
  flex: 1 1 220px;
  accent-color: var(--accent);
}

.curve-controls .quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cmp-date {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

table.curve-table td,
table.curve-table th {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.curve-table .swatch-line.dashed {
  background: repeating-linear-gradient(90deg, var(--s2) 0 5px, transparent 5px 8px) !important;
}

@media (max-width: 640px) {
  svg.regime-map {
    height: 340px;
  }

  svg.curve-chart {
    height: 260px;
  }
}

/* Regime: direction vs level */
.lv-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 14px 28px;
  margin-top: 6px;
}

.lv-col .sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.lv-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.lv-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--hairline);
}

.lv-list .lv-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lv-list .lv-val .sub,
.lv-list .lv-name .sub {
  margin: 0;
  font-size: 12px;
}

.lv-warn {
  margin: 12px 0;
}

@media (max-width: 640px) {
  .lv-grid {
    grid-template-columns: 1fr;
  }
}
