/* Brad, Dark-first, flat, minimal */

:root {
  /* ---- Terrazzo brand palette (raw swatches) ---- */
  --terra-peach:  #edbd95;
  --terra-teal:   #374f4e;
  --terra-orange: #d1801e;
  --terra-sand:   #daccc4;
  --terra-gold:   #aa8552;

  /* ---- Surfaces: deep teal derived from the palette's dark ---- */
  --bg-primary: #182322;
  --bg-secondary: #1f2b2a;
  --bg-elevated: #273634;
  --bg-hover: #31423f;

  /* ---- Text: warm sand ---- */
  --text-primary: #f0e7dd;
  --text-secondary: #f0e7dda6;
  --text-tertiary: #f0e7dd66;

  /* ---- Strokes: warm, low alpha over the teal ---- */
  --stroke-primary: #e0d0c033;
  --stroke-secondary: #e0d0c01f;
  --stroke-subtle: #e0d0c014;

  /* ---- Accent: terrazzo orange (dark ink sits on it) ---- */
  --accent: #d1801e;
  --accent-dim: #d1801e33;
  --on-accent: #182322;

  /* ---- Status (validated CVD-safe on the dark surface) ---- */
  --green: #5aa871;
  --green-dim: #5aa87126;
  --red: #e0655a;
  --red-dim: #e0655a26;
  --yellow: #e0a94a;
  --yellow-dim: #e0a94a26;
  --blue: #6fa8a2;        /* repurposed: light teal for neutral highlights */

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  --radius: 6px;
  --radius-lg: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-title { margin: 0; line-height: 0; display: flex; align-items: center; }
.brand-logo {
  height: 24px;
  width: auto;      /* preserve aspect ratio, never stretch */
  display: block;
}

/* Header action group (Subscribe + hamburger). Shown only on mobile; on
   desktop the actions live in the nav bar below the title. */
.topbar-actions { display: none; }
.topbar-actions .nav-subscribe { margin-left: 0; }

.app-header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.app-header .subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  position: relative;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--stroke-subtle);
  padding-bottom: 8px;
}

/* Tabs container: inline row on desktop (dropdown panel on mobile). */
.nav-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

/* Hamburger toggle, hidden on desktop, shown on mobile. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 34px;
  padding: 0 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 2px;
}

/* Export-in-menu is desktop-hidden (the standalone .nav-export shows instead). */
.nav-export-mobile { display: none; }

.nav-tab {
  padding: 6px 11px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-tab.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--stroke-secondary);
}

/* Sweep selector */
.sweep-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sweep-selector label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sweep-selector select {
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.sweep-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

/* View header */
.view-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.view-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.view-header .meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
}

.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
}

.stat-card .value.green { color: var(--green); }
.stat-card .value.red { color: var(--red); }
.stat-card .value.blue { color: var(--accent); }
.stat-card .value.yellow { color: var(--yellow); }

.stat-card .label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--stroke-secondary);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.data-table thead th.right,
.data-table tbody td.right {
  text-align: right;
}

.data-table thead th.center,
.data-table tbody td.center {
  text-align: center;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--stroke-subtle);
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody td {
  padding: 8px 10px;
  white-space: nowrap;
}

.data-table tbody td.ticker-cell {
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--accent);
}

.data-table tbody td.ticker-cell:hover {
  text-decoration: underline;
}

/* Any clickable ticker (not just table cells, e.g. portfolio holding cards)
   reads as clickable: pointer cursor, accent colour, hover underline. */
.ticker-cell,
[data-ticker] {
  cursor: pointer;
}
.ticker-cell:hover,
[data-ticker]:hover {
  text-decoration: underline;
}
.holding-ticker .ticker-cell {
  color: var(--accent);
}

.data-table tbody td.company-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.data-table tbody td.sector-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-tertiary);
  font-size: 12px;
}

.data-table tbody td.score-cell {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Rank/score delta indicators */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.neutral { color: var(--text-tertiary); }

.delta .arrow {
  font-size: 10px;
  line-height: 1;
}

/* Action badges */
.action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.action-badge.STRONG_BUY {
  background: var(--green-dim);
  color: var(--green);
}

.action-badge.BUY {
  background: var(--green-dim);
  color: var(--green);
}

.action-badge.WATCH {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.action-badge.PASS {
  background: var(--red-dim);
  color: var(--red);
}

.new-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* Cards */
.card {
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  cursor: default;
}

.card-header.collapsible {
  cursor: pointer;
  user-select: none;
}

.card-header.collapsible:hover {
  background: var(--bg-hover);
}

.card-header .chevron {
  color: var(--text-tertiary);
  transition: transform 0.15s ease;
  font-size: 12px;
}

.card-header .chevron.open {
  transform: rotate(90deg);
}

.card-body {
  padding: 14px;
}

.card-body p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.card-body .component-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

/* Score bars */
.score-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar {
  flex: 1;
  height: 6px;
  background: var(--stroke-subtle);
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.score-bar-fill.high { background: var(--green); }
.score-bar-fill.mid { background: var(--accent); }
.score-bar-fill.low { background: var(--text-tertiary); }
.score-bar-fill.negative { background: var(--red); }

.score-bar-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* Alerts */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
  font-size: 13px;
  align-items: flex-start;
}

.alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-item .alert-text {
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-item .alert-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Two-column layout */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .split-grid {
    grid-template-columns: 1fr;
  }
}

/* Ticker detail header */
.ticker-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.ticker-header .ticker-symbol {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.ticker-header .ticker-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.ticker-header .ticker-sector {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Section divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--stroke-subtle);
  margin: 20px 0;
}

/* Chart container */
.chart-container {
  width: 100%;
  margin-bottom: 16px;
}

.chart-container svg {
  width: 100%;
  height: auto;
}

/* Loading / empty states */
.loading, .empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* Friendly error card (fetch/render failure) */
.error-state {
  text-align: center;
  padding: 60px 20px;
}
.error-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.error-sub {
  font-size: 14px;
  color: var(--text-tertiary);
  margin: 0 0 16px;
}

/* Honeypot field: off-screen so bots fill it but humans never see it (not
   display:none, since some bots skip fully-hidden fields). */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Expandable row */
.expandable-row {
  cursor: pointer;
}

.expandable-content {
  display: none;
  padding: 12px 10px;
  background: var(--bg-secondary);
}

.expandable-content.open {
  display: block;
}

/* Section heading */
h3.section-heading {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* Divider with label */
.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.divider-label::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--stroke-subtle);
}

/* Table horizontal scroll wrapper (mobile) */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Track Record page ===== */

.period-tickers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 24px;
  padding: 8px 0;
}

.period-ticker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 13px;
}

.period-ticker-item:hover {
  background: var(--bg-hover);
}

.period-ticker-item .delta.missing {
  color: var(--text-tertiary);
}

@media (max-width: 720px) {
  .period-tickers-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Methodology page ===== */

.methodology {
  width: 100%;
  max-width: none;
}

.method-section {
  margin-bottom: 32px;
}

.method-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.method-section p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
}

.method-note {
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  margin-bottom: 8px;
}

.method-section code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-subtle);
  border-radius: 3px;
  color: var(--accent);
}

.method-table .action-badge {
  font-size: 11px;
  white-space: nowrap;
}

/* Pipeline diagram */
.pipeline-steps {
  margin: 16px 0 24px;
}

.pipeline-step {
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 4px;
}

.pipeline-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pipeline-stage-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}

.pipeline-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.pipeline-range {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: auto;
}

.pipeline-step p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

.pipeline-arrow {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  padding: 2px 0;
}

/* Component cards grid */
.component-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.component-grid.stage3-grid {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 720px) {
  .component-grid,
  .component-grid.stage3-grid {
    grid-template-columns: 1fr;
  }
}

.component-card {
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-lg);
}

.component-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.component-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.component-range {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.component-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.component-citation {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
  font-style: italic;
  padding-left: 10px;
  border-left: 2px solid var(--stroke-secondary);
  margin-top: 6px;
  margin-bottom: 6px;
}

/* Bibliography */
.bib-section-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 16px;
  margin-bottom: 6px;
}

.citation-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.citation-list .citation {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 20px;
  text-indent: -20px;
  margin-bottom: 4px;
}

/* ===== Landing page (public tier) ===== */

.landing-hero {
  text-align: center;
  padding: 40px 0 32px;
}

.landing-hero h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.landing-tagline {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  max-width: 560px;
  margin: 0 auto 24px;
}

.landing-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-stats {
  margin-top: 8px;
}

.landing-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-primary);
}

.callout-icon {
  color: var(--green);
  font-size: 16px;
  font-weight: 700;
}

.landing-section {
  margin-bottom: 32px;
}

.landing-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.landing-section p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
}

.landing-tease {
  font-style: italic;
  color: var(--text-tertiary);
}

.landing-subscribe {
  text-align: center;
  padding: 32px 24px;
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
}

.landing-subscribe h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.landing-subscribe p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
  max-width: 480px;
  margin: 0 auto 20px;
}

/* CTA buttons */
.cta-btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.cta-btn.cta-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.cta-btn.cta-primary:hover {
  filter: brightness(1.15);
}

.cta-btn.cta-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.cta-btn.cta-secondary:hover {
  background: var(--accent-dim);
}

.cta-btn.cta-large {
  padding: 12px 32px;
  font-size: 15px;
}

/* Nav tab overflow for many tabs */
.nav {
  flex-wrap: wrap;
}

/* Right-aligned Subscribe button in the nav bar */
/* Desktop right-side action group (Export + Subscribe kept together). */
.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-subscribe {
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.nav-subscribe:hover { filter: brightness(1.15); }

/* Export PDF button, sits just to the right of Subscribe in the nav bar */
.nav-export {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nav-export:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--stroke-primary);
}
.nav-export:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Landing narrative (Brad story) ===== */

/* Make the dynamic alpha headline native to the dark theme (overrides the
   earlier light-box definition). */
.landing-hero .landing-headline {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
  max-width: 620px;
  margin: 0 auto 24px;
  text-align: center;
}
.landing-hero .landing-headline strong { color: var(--text-primary); }

/* How-a-sweep-works stepped list */
.sweep-steps {
  list-style: none;
  counter-reset: sweep;
  margin: 4px 0 16px;
  padding: 0;
}
.sweep-steps li {
  counter-increment: sweep;
  position: relative;
  padding: 10px 0 10px 40px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  border-bottom: 1px solid var(--stroke-subtle);
}
.sweep-steps li:last-child { border-bottom: none; }
.sweep-steps li::before {
  content: counter(sweep);
  position: absolute;
  left: 0;
  top: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.sweep-steps li strong { color: var(--text-primary); }
.sweep-rule {
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-secondary);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}
.sweep-rule strong { color: var(--text-primary); }

/* Numbers, translated */
.landing-numbers .number-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--stroke-subtle);
}
.landing-numbers .number-row:last-child { border-bottom: none; }
.number-claim {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 4px;
}
.number-meaning {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.tx-label {
  color: var(--accent);
  font-weight: 600;
}

/* Explore grid */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 8px 0 12px;
}
.explore-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: var(--font-sans);
}
.explore-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.explore-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.explore-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.explore-note {
  font-style: italic;
  color: var(--text-tertiary);
}

/* Feedback block */
.landing-feedback {
  padding: 20px 0 4px;
}

/* ===== Subscribe form ===== */
.subscribe-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 440px;
  margin: 0 auto 12px;
}
.subscribe-input {
  flex: 1 1 240px;
  min-width: 200px;
  padding: 11px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-primary);
  /* 16px stops iOS Safari from zooming the page on focus; appearance:none stops
     it from rendering an oversized native input. */
  font-size: 16px;
  line-height: 1.25;
  font-family: var(--font-sans);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
.subscribe-input:focus {
  outline: none;
  border-color: var(--accent);
}
.subscribe-input::placeholder { color: var(--text-tertiary); }
.subscribe-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}
.subscribe-note-error { color: var(--red); }
.subscribe-success {
  color: var(--green);
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0;
}

/* Section divider on the landing page */
.landing-divider {
  border: none;
  border-top: 1px solid var(--stroke-subtle);
  margin: 22px 0;
}

/* Small landing CTA that points at the Contact page */
.landing-contact-cta .cta-btn { margin-top: 4px; }

/* ===== Contact form / page ===== */
.contact-page {
  max-width: 620px;
  margin: 24px auto 0;
}
.contact-heading {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
  text-align: center;
}
.contact-intro {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  margin: 0 auto 22px;
  max-width: 520px;
  text-align: center;
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.contact-actions { justify-content: center; }
.contact-form .cta-btn { min-width: 180px; }
.contact-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.contact-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 220px;
  min-width: 0;
}
.contact-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.contact-optional { font-weight: 400; color: var(--text-tertiary); }
.contact-category,
.contact-email,
.contact-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-primary);
  /* 16px stops iOS zoom-on-focus; appearance:none stops oversized native inputs. */
  font-size: 16px;
  font-family: var(--font-sans);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
/* Keep the native dropdown arrow on the category <select> (appearance:none hides it). */
.contact-category {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23f0e7dda6' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.contact-category { cursor: pointer; }
.contact-input {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}
.contact-category:focus,
.contact-email:focus,
.contact-input:focus {
  outline: none;
  border-color: var(--accent);
}
.contact-email::placeholder,
.contact-input::placeholder { color: var(--text-tertiary); }
.contact-actions { display: flex; }
.contact-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 8px 0 0;
}
.contact-note-error { color: var(--red); }
.contact-success {
  color: var(--green);
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0;
}

@media (max-width: 720px) {
  .subscribe-form { flex-direction: column; }
  .subscribe-form .cta-btn { width: 100%; }
  .contact-page { max-width: none; }
  .contact-heading { font-size: 20px; }
  .contact-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .contact-field { flex: 1 1 auto; }
  .contact-category,
  .contact-email { width: 100%; }
  .contact-actions .cta-btn { width: 100%; }
}

/* ===== Phase 5.1, Leaderboard filters ===== */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.filter-select,
.filter-search {
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
}

.filter-search {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 320px;
}

.filter-select:focus,
.filter-search:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-left: auto;
}

/* Score / max label */
.score-max {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 2px;
}

/* Stage pill */
.stage-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--stroke-secondary);
}

.stage-pill.stage-stage1 {
  color: var(--text-tertiary);
}

.stage-pill.stage-stage2 {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.stage-pill.stage-stage3 {
  color: var(--green);
  border-color: var(--green-dim);
}

/* ===== Phase 5.2, Ticker detail enhancements ===== */

.stage-progression {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.stage-progression .step {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.stage-progression .step-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-sans);
  font-weight: 600;
}

.stage-progression .step-value {
  font-weight: 600;
  color: var(--text-primary);
}

.stage-progression .step-value.positive { color: var(--green); }
.stage-progression .step-value.negative { color: var(--red); }
.stage-progression .step-value.neutral  { color: var(--text-secondary); }

.stage-progression .op {
  color: var(--text-tertiary);
  font-size: 14px;
}

.overlay-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 720px) {
  .overlay-grid {
    grid-template-columns: 1fr;
  }
}

.overlay-card {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-lg);
}

.overlay-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.overlay-card-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
}

.overlay-card-range {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.overlay-card-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.overlay-card-value.positive { color: var(--green); }
.overlay-card-value.negative { color: var(--red); }
.overlay-card-value.neutral  { color: var(--text-secondary); }

.overlay-card-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
  margin-top: 4px;
}

/* Flag / Beneish badges */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

/* Compact circular variants for inline use in dense tables (leaderboard
 * rank rows). The original padded-pill variants are still used standalone
 * via .badge-row above. */
.flag-badge,
.beneish-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-left: 3px;
  border-radius: 999px;
  font-size: 0.65em;
  font-weight: 700;
  font-family: var(--font-mono);
  vertical-align: middle;
  border: 1px solid transparent;
  line-height: 1;
}

.flag-badge {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-color: var(--yellow-dim);
}

.beneish-badge.green {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green-dim);
}

.beneish-badge.yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-color: var(--yellow-dim);
}

.beneish-badge.red {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red-dim);
}

/* Standalone padded variant used on the ticker detail page (.badge-row) */
.badge-row .flag-badge,
.badge-row .beneish-badge {
  width: auto;
  height: auto;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ===== Manual Research v2, confidence badge + sources disclosure ===== */

.confidence-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  margin-left: 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  vertical-align: middle;
}

.confidence-badge.green {
  background: var(--green-dim);
  color: var(--green);
}

.confidence-badge.yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.confidence-badge.red {
  background: var(--red-dim);
  color: var(--red);
}

.sources-disclosure summary::-webkit-details-marker {
  color: var(--text-tertiary);
}

.sources-disclosure ul {
  list-style: disc;
}

.sources-disclosure a {
  color: var(--accent);
  text-decoration: none;
}

.sources-disclosure a:hover {
  text-decoration: underline;
}

/* ===== Phase 7, Site disclaimer + author-holds badge ===== */

.app-footer.disclaimer {
  margin-top: 48px;
  padding: 20px 0 0;
  border-top: 1px solid var(--stroke-subtle);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-tertiary);
}

.app-footer.disclaimer p {
  margin: 0;
}

.held-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--accent-dim);
  color: var(--accent);
  vertical-align: middle;
}

/* ===== Phase 5.3, Driver chips ===== */

.driver-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.driver-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-subtle);
  letter-spacing: 0.2px;
}

.driver-chip.up    { color: var(--green); border-color: var(--green-dim); }
.driver-chip.down  { color: var(--red);   border-color: var(--red-dim); }
.driver-chip.flat  { color: var(--text-tertiary); }

/* ===== Phase 5.6, Mobile tap targets ===== */

@media (max-width: 720px) {
  .data-table tbody td {
    padding: 10px 10px;
  }
  .data-table tbody td.ticker-cell {
    min-height: 44px;
    padding: 12px 10px;
  }
  .nav-tab {
    min-height: 36px;
  }
}

/* ===== General mobile layout ===== */
@media (max-width: 720px) {
  .app { padding: 16px 14px 40px; }

  /* Title row never wraps: [Brad · subtitle] on the left, [Subscribe] [hamburger]
     on the right. The subtitle truncates before anything wraps. */
  .app-header { gap: 10px; flex-wrap: nowrap; }
  .brand { flex: 0 1 auto; overflow: hidden; }
  .app-header h1 { font-size: 20px; flex: 0 0 auto; }
  .brand-logo { height: 21px; }
  .app-header .subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .landing-hero { padding: 24px 0 20px; }
  .landing-hero h2 { font-size: 23px; }
  .landing-tagline { font-size: 14px; }

  /* Header actions: Subscribe (left) + hamburger (right). Compact so they
     always fit alongside the title without wrapping. */
  .topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .topbar-actions .nav-subscribe { padding: 5px 11px; font-size: 12px; }
  .nav-toggle { display: flex; }
  .nav-toggle span { transition: transform 0.15s ease, opacity 0.15s ease; }
  .nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* Desktop nav-bar actions are hidden on mobile (they live in the header). */
  .nav-desktop-only { display: none !important; }
  .nav-export-mobile { display: block; }

  /* The nav bar itself collapses to a zero-height positioning anchor for the
     dropdown (its contents are the hidden desktop actions + the panel). */
  .nav {
    flex-wrap: nowrap;
    gap: 0;
    margin-bottom: 8px;
    padding-bottom: 0;
    border-bottom: none;
    min-height: 0;
  }

  /* Dropdown: compact, right-aligned, fits the longest label (not full width). */
  .nav-menu {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 60;
    width: max-content;
    min-width: 150px;
    max-width: 82vw;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--stroke-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  }
  .nav-open .nav-menu { display: flex; }
  .nav-menu .nav-tab {
    width: 100%;
    text-align: left;
    white-space: nowrap;
    padding: 10px 14px;
    min-height: 40px;
    font-size: 14px;
    border-radius: var(--radius);
  }

  /* Card grids stack to a single comfortable column */
  .holdings-grid { grid-template-columns: 1fr; }
  .explore-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 12px; }

  /* Wide financial tables: smaller type so more fits before you must scroll,
     and keep the ticker (first) column pinned for context while scrolling. */
  .data-table { font-size: 12.5px; }
  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-primary);
  }
}

@media (max-width: 360px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .app {
    padding: 16px 12px 32px;
  }
}

/* ===== Phase 4.3, Portfolio view ===== */

.trade-action-buy,
.trade-action-sell {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.trade-action-buy {
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid var(--green-dim);
}

.trade-action-sell {
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid var(--red-dim);
}

.data-table tbody tr.holding-missing td {
  color: var(--text-tertiary);
}

.badge-muted {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.portfolio-schema-example {
  margin-top: 8px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.45;
  font-family: var(--font-mono);
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
  overflow-x: auto;
  max-width: 100%;
}

.portfolio-disclosure {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--stroke-subtle);
  font-size: 12px;
  color: var(--text-tertiary);
}

.empty-inline {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ===== PDF export toolbar + print/PDF capture ===== */

.view-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.view-toolbar .sweep-selector {
  margin-bottom: 0;
}

.pdf-export-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius);
  cursor: pointer;
}

.pdf-export-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--stroke-primary);
}

.pdf-export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pdf-only {
  display: none;
}

/* Full-viewport mask shown only while a PDF is generating, so the user sees a
   clean "Generating" state instead of the content briefly shifting. */
.pdf-exporting-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pdf-exporting-msg {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-secondary);
}

/* The export header/footer are injected with inline `visibility: hidden` so they
   reserve their height for html2pdf's page-break measurement while staying
   invisible on the live page; here we reveal them inside the render clone (which
   carries `body.pdf-export`). !important beats the inline hidden. */
body.pdf-export #pdf-export-header,
body.pdf-export #pdf-export-footer {
  visibility: visible !important;
}

body.pdf-export {
  /* Print theme. The page is white, so cards get a light-gray fill and clearly
     visible borders, otherwise white-on-white boxes vanish in the PDF. */
  --bg-primary: #ffffff;
  --bg-secondary: #f3f4f6;
  --bg-elevated: #e9ebef;
  --bg-hover: #f3f4f6;
  --text-primary: #101114;
  --text-secondary: #34373d;
  --text-tertiary: #5f636b;
  --stroke-primary: #a9aeb6;
  --stroke-secondary: #c4c9d0;
  --stroke-subtle: #d3d7dd;
}

/* Keep whole elements together across page breaks so charts, cards and table
   rows are never sliced in half. `break-after: avoid` on headings keeps a
   section title attached to the content that follows it. */
body.pdf-export .chart-container,
body.pdf-export .stat-card,
body.pdf-export .holding-card,
body.pdf-export .rules-card,
body.pdf-export .caveat-banner,
body.pdf-export .rebalance-row,
body.pdf-export .period-card,
body.pdf-export .stat-card-pair,
body.pdf-export tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

body.pdf-export .section-heading,
body.pdf-export .view-header,
body.pdf-export h2,
body.pdf-export h3 {
  break-after: avoid;
  page-break-after: avoid;
}

body.pdf-export .nav,
body.pdf-export .view-toolbar,
body.pdf-export .sweep-selector,
body.pdf-export .filter-bar,
body.pdf-export .app-footer {
  display: none !important;
}

body.pdf-export .table-scroll-wrapper {
  overflow: visible !important;
}

body.pdf-export #view svg text {
  fill: #333333 !important;
}

body.pdf-export .pdf-only {
  display: block !important;
}

.pdf-export-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--stroke-primary);
}

.pdf-export-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.pdf-export-meta,
.pdf-export-disclaimer {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.pdf-export-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--stroke-primary);
  font-size: 11px;
  color: var(--text-secondary);
}

@media print {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-elevated: #fafafa;
    --bg-hover: #ffffff;
    --text-primary: #111111;
    --text-secondary: #444444;
    --text-tertiary: #777777;
    --stroke-primary: #d0d0d0;
    --stroke-secondary: #e2e2e2;
    --stroke-subtle: #ececec;
  }

  html,
  body {
    background: #ffffff !important;
    color: #111111 !important;
  }

  .nav,
  .view-toolbar,
  .filter-bar,
  .app-footer {
    display: none !important;
  }

  .table-scroll-wrapper {
    overflow: visible !important;
  }

  #view svg text {
    fill: #333333 !important;
  }

  .app {
    max-width: none;
    padding: 12px;
  }
}

/* ============================================================
   Edge methodology UI additions
   ============================================================ */

.caveat-banner {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-left: 4px solid var(--yellow);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 6px;
  margin: 12px 0 16px;
  font-size: 0.9em;
  line-height: 1.45;
}
.caveat-banner strong { color: var(--text-primary); }

.stat-card-pair {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stat-card-pair .value { line-height: 1.1; }
.stat-card-pair .value-secondary {
  font-size: 0.95em;
  font-weight: 600;
  opacity: 0.78;
  margin-top: 1px;
}
.stat-card-pair .label-sub {
  font-size: 0.72em;
  opacity: 0.6;
  margin-top: 2px;
  text-transform: none;
  letter-spacing: 0;
}
.warn-inline { color: var(--yellow); font-weight: 600; }

.section-sub {
  font-size: 0.7em;
  font-weight: normal;
  opacity: 0.6;
  margin-left: 6px;
}

.delisted-flag {
  display: inline-block;
  background: var(--red);
  color: var(--bg-primary);
  font-size: 0.7em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
}

.period-ticker-item.delisted .ticker-cell {
  text-decoration: line-through;
  opacity: 0.7;
}
.period-delisted-note {
  margin-top: 10px;
  font-size: 0.82em;
  color: var(--text-secondary);
  background: var(--red-dim);
  border: 1px solid var(--red-dim);
  border-radius: 4px;
  padding: 8px 12px;
}

.since-sweep-callout {
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-secondary);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 8px 0 16px;
  font-size: 0.9em;
  line-height: 1.45;
  color: var(--text-primary);
}
.since-sweep-callout .since-headline {
  font-size: 1.05em;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.since-sweep-callout .since-delisted {
  font-size: 0.85em;
  margin-top: 4px;
  color: var(--text-secondary);
}
.since-sweep-callout .since-disclaimer {
  font-size: 0.82em;
  margin-top: 6px;
  color: var(--text-secondary);
}
.since-sweep-callout .since-stillheld {
  font-size: 0.85em;
  margin-top: 4px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Annualized-hidden note in Track Record */
.annualized-note {
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-secondary);
  border-left: 4px solid var(--stroke-primary);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 8px 0 16px;
  font-size: 0.88em;
  line-height: 1.45;
  color: var(--text-secondary);
}

.view-mode-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--stroke-subtle);
  border-radius: 6px;
  padding: 3px;
  margin-left: 12px;
}
.view-mode-toggle button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
}
.view-mode-toggle button.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.stage-delta-cell {
  font-variant-numeric: tabular-nums;
}
.stage-delta-up   { color: var(--green); font-weight: 600; }
.stage-delta-down { color: var(--red); font-weight: 600; }
.stage-delta-zero { color: var(--text-tertiary); }

.landing-headline {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 14px 0 6px;
  font-size: 1.02em;
  line-height: 1.5;
}
.landing-headline strong { color: var(--text-primary); }
.landing-caveat {
  font-size: 0.85em;
  color: var(--text-tertiary);
  margin: 6px 0 14px;
  line-height: 1.45;
  font-style: italic;
}

.edge-bullet-list {
  margin: 6px 0 14px 0;
  padding-left: 22px;
  line-height: 1.55;
}
.edge-bullet-list li { margin-bottom: 6px; }
.edge-bullet-list code {
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}

/* ---- Track Record: rank-rebalanced model ---- */
.rules-card {
  margin: 12px 0 18px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.92em;
  line-height: 1.55;
  color: var(--text-secondary);
}
.callout-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}
.callout {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
}
.callout-label {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}
.callout-value {
  font-family: var(--font-mono);
  font-size: 1.5em;
  margin-top: 4px;
}
.callout-value.green { color: var(--green); }
.callout-value.red { color: var(--red); }
.callout-value.neutral { color: var(--text-secondary); }
.callout-sub {
  margin-top: 6px;
  font-size: 0.82em;
  color: var(--text-tertiary);
  line-height: 1.45;
}
.chart-legend-note {
  margin: -4px 0 16px;
  font-size: 0.85em;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.holdings-grid {
  display: grid;
  /* The 3-up perf row needs more horizontal room than the prior compact card. */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.holding-card.brand-new {
  /* New entrants get the orange accent so they read at a glance as
     "just entered" (informational, no P&L yet). */
  background: var(--accent-dim);
  border: 1px solid rgba(209, 128, 30, 0.4);
  border-left: 3px solid var(--accent);
}
.brand-new-label {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(209, 128, 30, 0.4);
  border-radius: 4px;
}
.holding-perf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--stroke-subtle);
}
.holding-perf .perf-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 0.82em;
  line-height: 1.2;
}
.holding-perf .perf-cell .delta {
  font-weight: 600;
}
.holding-perf .perf-sub {
  font-size: 0.78em;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.holding-card {
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
}
.holding-ticker {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05em;
}
.holding-meta {
  font-size: 0.78em;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.holdings-note {
  margin-top: 8px;
  font-size: 0.82em;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.pick-badge {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 6px;
  font-size: 0.68em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
}
.pick-badge.carried {
  background: rgba(111, 168, 162, 0.18);
  color: #a9d4ce;
  border: 1px solid rgba(111, 168, 162, 0.45);
}
.pick-badge.fresh {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
}
.period-sold-row {
  margin: 4px 0 10px;
  font-size: 0.88em;
  color: var(--text-secondary);
  line-height: 1.6;
}
.sold-tag {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  font-size: 0.85em;
  background: rgba(224, 101, 90, 0.12);
  color: #f0a89f;
  border-radius: 3px;
}

.period-noise-note {
  margin: 0 0 12px;
  color: var(--text-tertiary);
  font-size: 0.86em;
  line-height: 1.5;
}

.period-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.period-card {
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

.period-card-header {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 12px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.period-card-header:hover {
  background: var(--bg-hover);
}

.period-title {
  font-size: 0.98em;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.period-alpha {
  font-family: var(--font-mono);
  font-size: 1.05em;
  font-weight: 700;
}

.period-alpha.up { color: var(--green); }
.period-alpha.down { color: var(--red); }
.period-alpha.neutral { color: var(--text-secondary); }
.period-alpha .arrow { font-size: 0.8em; margin-left: 2px; }

.period-card-body {
  padding: 0 14px 12px;
}

.period-composition-line {
  color: var(--text-secondary);
  font-size: 0.88em;
  margin-bottom: 6px;
}

.period-pill-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 4px;
}

.period-pill-label {
  font-size: 0.8em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.period-pill-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.period-pill-empty {
  color: var(--text-tertiary);
  font-size: 0.82em;
}

.ticker-pill {
  border: 1px solid var(--stroke-secondary);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8em;
  font-family: var(--font-mono);
  cursor: pointer;
}

.ticker-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ticker-pill.carried {
  color: var(--text-secondary);
}

.ticker-pill.entered {
  color: #86c898;
  border-color: rgba(90, 168, 113, 0.25);
  background: rgba(90, 168, 113, 0.12);
}

.ticker-pill.exited {
  color: #f0a89f;
  text-decoration: line-through;
  border-color: rgba(224, 101, 90, 0.25);
  background: rgba(224, 101, 90, 0.12);
}

.period-returns-line {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--stroke-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.82em;
  color: var(--text-tertiary);
}

.period-cost-line {
  margin-top: 4px;
  font-size: 0.76em;
  color: var(--text-tertiary);
}

.period-card-detail {
  display: none;
  margin-top: 10px;
}

.period-card.open .period-card-detail {
  display: block;
}

.period-detail-row.sold {
  background: rgba(224, 101, 90, 0.08);
}

.period-detail-row.delisted {
  background: rgba(224, 101, 90, 0.12);
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.76em;
  font-weight: 600;
  border: 1px solid var(--stroke-secondary);
}

.status-pill.carried {
  color: var(--text-secondary);
}

.status-pill.entered {
  color: #86c898;
  border-color: rgba(90, 168, 113, 0.25);
  background: rgba(90, 168, 113, 0.12);
}

.status-pill.sold {
  color: #f0a89f;
  border-color: rgba(224, 101, 90, 0.25);
  background: rgba(224, 101, 90, 0.12);
}

/* ---- Signal Quality view ---- */
.signal-quality-banner {
  margin: 10px 0 16px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.signal-quality-banner h3 {
  font-size: 1em;
  margin-bottom: 6px;
}

.signal-quality-banner p {
  color: var(--text-secondary);
  font-size: 0.9em;
  line-height: 1.55;
}

.signal-quality-banner a {
  color: var(--accent);
}

.sq-section {
  margin-bottom: 18px;
}

.sq-kpi-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.sq-kpi {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke-subtle);
  background: var(--bg-secondary);
}

.sq-kpi.up .sq-kpi-value { color: var(--green); }
.sq-kpi.down .sq-kpi-value { color: var(--red); }
.sq-kpi.neutral .sq-kpi-value { color: var(--text-secondary); }

.sq-kpi-label {
  color: var(--text-tertiary);
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sq-kpi-value {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 1.2em;
  font-weight: 600;
}

.sq-sample-note,
.sq-muted-text {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 0.84em;
  line-height: 1.5;
}

.sq-kpi-sub {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 0.72em;
  letter-spacing: 0.02em;
}

.sq-kpi-value.sq-kpi-empty {
  color: var(--text-tertiary);
  font-weight: 500;
}

/* An unmatured horizon in the dropout table, a dash, but visibly "pending"
   rather than a zero/missing value. */
td.sq-not-matured {
  color: var(--text-tertiary);
  opacity: 0.55;
}

.component-sort {
  border: none;
  background: transparent;
  color: inherit;
  font-size: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.component-sort:hover {
  color: var(--accent);
}

.verdict-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.76em;
  font-weight: 600;
  border: 1px solid var(--stroke-secondary);
}

.verdict-chip.strong { color: #86c898; border-color: rgba(90, 168, 113, 0.25); background: rgba(90, 168, 113, 0.12); }
.verdict-chip.solid { color: #a7d8b8; border-color: rgba(90, 168, 113, 0.25); background: rgba(90, 168, 113, 0.12); }
.verdict-chip.marginal { color: #ecc978; border-color: rgba(224, 169, 74, 0.25); background: rgba(224, 169, 74, 0.12); }
.verdict-chip.noedge { color: var(--text-secondary); background: var(--bg-elevated); }
.verdict-chip.anti { color: #f0a89f; border-color: rgba(224, 101, 90, 0.25); background: rgba(224, 101, 90, 0.12); }

.alpha-card-3-up {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.dropout-toggle {
  margin-top: 10px;
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 6px 10px;
  cursor: pointer;
}

.dropout-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dropouts-table-wrap {
  display: none;
  margin-top: 8px;
}

.dropouts-table-wrap.open {
  display: block;
}

.persistence-bignum {
  font-family: var(--font-mono);
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 8px;
}

/* ---- Portfolio view, rebalance summary + period details expander ---- */
.rebalance-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 18px;
}
.rebalance-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
}
.rebalance-label {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-secondary);
}
.rebalance-tickers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-family: var(--font-mono);
}
.rebalance-tickers .pick-badge {
  cursor: pointer;
  margin-left: 0;
}
.rebalance-tickers .pick-badge.sold {
  background: rgba(224, 101, 90, 0.15);
  color: #f0a89f;
}
.rebalance-empty {
  font-size: 0.85em;
  color: var(--text-tertiary);
  font-style: italic;
}
.holding-card.delisted {
  opacity: 0.6;
}
.period-details {
  margin: 14px 0 18px;
}
.period-details > summary {
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius);
  list-style: none;
  user-select: none;
}
.period-details > summary::-webkit-details-marker {
  display: none;
}
.period-details > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--text-tertiary);
  transition: transform 0.15s ease;
}
.period-details[open] > summary::before {
  transform: rotate(90deg);
}
.period-details > summary .section-sub {
  margin-left: 8px;
}
.period-detail-caveat {
  margin: 12px 0 14px;
  padding: 10px 14px;
  font-size: 0.85em;
  color: var(--text-secondary);
  background: var(--bg-tertiary, var(--bg-secondary));
  border-left: 3px solid var(--text-tertiary);
  border-radius: 4px;
  line-height: 1.5;
}

/* ---- Ticker MFE/MAE diagnostic block ---- */
.mfe-mae-block {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--stroke-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.mfe-mae-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.mfe-mae-title {
  font-weight: 600;
  font-size: 0.95em;
}
.mfe-mae-sub {
  font-size: 0.78em;
  color: var(--text-tertiary);
}
.mfe-mae-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.mfe-mae-cell {
  padding: 8px 10px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  border: 1px solid var(--stroke-subtle);
}
.mfe-mae-cell .label {
  font-size: 0.74em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}
.mfe-mae-cell .value {
  font-family: var(--font-mono);
  font-size: 1.05em;
  margin-top: 3px;
}
.mfe-mae-cell .value.up { color: var(--green); }
.mfe-mae-cell .value.down { color: var(--red); }
.mfe-mae-cell .meta {
  font-size: 0.72em;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.mfe-mae-disclaimer {
  margin-top: 10px;
  font-size: 0.78em;
  color: var(--text-tertiary);
  line-height: 1.5;
  font-style: italic;
}

.mfe-mae-justentered {
  margin-top: 12px;
  font-size: 0.86em;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ---- Leaderboard portfolio-state badges ---- */
.portfolio-state-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.68em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.portfolio-state-badge.carried {
  background: rgba(111, 168, 162, 0.15);
  color: #8fc0ba;
}
.portfolio-state-badge.entered {
  background: rgba(90, 168, 113, 0.15);
  color: #86c898;
}
.portfolio-state-badge.exited {
  background: rgba(224, 101, 90, 0.12);
  color: #f0a89f;
}

/* ── Candidate Pool view ───────────────────────────────────────────── */
.view-sub {
  color: var(--text-tertiary);
  font-size: 13px;
  margin: 2px 0 0;
}
.pool-intro .card-body { padding: 12px 14px; }
.pool-framing {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 8px;
}
.pool-spread {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: var(--yellow-dim);
  border-left: 2px solid var(--yellow);
  border-radius: var(--radius);
}
.pool-sectors { font-size: 12px; color: var(--text-tertiary); }
.pool-sectors-label { margin-right: 4px; }
.pool-sector-chip { margin-right: 8px; white-space: nowrap; }

.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.pool-card {
  margin-bottom: 0;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.pool-card:hover,
.pool-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
  outline: none;
}
.pool-card-header { cursor: pointer; }
.pool-ticker { display: flex; align-items: center; gap: 6px; }
.pool-symbol { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.pool-score { font-family: var(--font-mono); font-size: 14px; color: var(--text-secondary); }
.pool-company {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pool-sector { display: inline-block; margin-bottom: 8px; }
.pool-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.pool-flags-clear { color: var(--text-tertiary); font-size: 11px; }
.pool-flag {
  font-size: 10.5px;
  line-height: 1.4;
  padding: 2px 6px;
  border-radius: var(--radius);
  white-space: normal;
}
.pool-flag.caution { background: var(--yellow-dim); color: var(--yellow); }
.pool-flag.context { background: var(--stroke-subtle); color: var(--text-tertiary); }
.pool-flag.held { background: var(--accent-dim); color: var(--accent); }
