/* === :root === */
:root {
  --color-bg: #0d1117;
  --color-surface: #161b22;
  --color-border: #30363d;
  --color-accent: #00d4a0;
  --color-accent-hover: #00e6b0;
  --color-accent-light: rgba(0, 212, 160, 0.08);
  --color-tag-bg: #21262d;
  --color-card-hover: #1c2128;
  --color-text-primary: #eef3f7;
  --color-text-secondary: #cbdae6;
  --color-positive: #3fb950;
  --color-negative: #f85149;
  --color-warning: #ffa657;
  --color-purple: #bc8cff;
  /* Screener tier scale (v3.29.0): S dark green, A light green, B yellow,
     C light red; tier F uses --color-negative (dark red). S+ (v3.30.0, a
     perfect 100/100) uses purple so it stands apart from the green ramp. */
  --color-tier-splus: #bc8cff;
  --color-tier-s: #2ea043;
  --color-tier-a: #7ee787;
  --color-tier-b: #e3b341;
  --color-tier-c: #ffa198;
  --sidebar-width: 220px;
}

/* === Reset / base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.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;
}

/* === Layout === */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  flex: 1;
  align-items: start;
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.sidebar-brand a {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: 0;
  white-space: nowrap;
}

.sidebar-brand a span { color: var(--color-accent); }

.sidebar-brand a:hover { text-decoration: none; }

/* Mobile hamburger toggle: hidden on desktop, revealed under 1024px */
.nav-toggle, .nav-burger { display: none; }

.sidebar-nav { flex: 1; }

.sidebar-nav ul { list-style: none; }

.sidebar-nav > ul > li > a {
  display: block;
  padding: 7px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color 0.2s;
}

.sidebar-nav > ul > li > a:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

.sidebar-nav > ul > li > a.active {
  color: var(--color-accent);
  font-weight: 600;
  border-left: 3px solid var(--color-accent);
  padding-left: 17px;
}

.nav-section-label {
  display: block;
  padding: 12px 20px 4px;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.metric-links { list-style: none; }

.metric-links li a {
  display: block;
  padding: 4px 20px 4px 32px;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  transition: color 0.2s;
}

.metric-links li a:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

.metric-links li a.active {
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--color-border);
  font-size: 0.72rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* === Main content === */
.main-content {
  padding: 32px 28px;
}

.content-inner {
  max-width: 820px;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  text-align: center;
  padding: 28px 32px;
  font-size: 0.8rem;
}

.site-footer a {
  color: var(--color-accent);
}

/* === Typography === */
h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
  letter-spacing: -0.3px;
}

h2 {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 44px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

h2::before {
  content: '';
  display: block;
  width: 3px;
  height: 1.1em;
  background: var(--color-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 24px;
  margin-bottom: 6px;
}

p { margin-bottom: 14px; }

.lead {
  font-size: 1rem;
  color: var(--color-text-primary);
  line-height: 1.65;
  margin-bottom: 0;
}

.caption {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 6px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  /* overflow-y (not the "overflow" shorthand) so the table's square corners
     still clip to the rounded border without cancelling overflow-x: auto --
     the shorthand previously reset both axes to hidden, silently swallowing
     the intended horizontal scrollbar on any table wider than its container. */
  overflow-y: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

thead tr { background: var(--color-card-hover); }

thead th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

thead th.num { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }

tbody tr:hover { background: var(--color-accent-light); }

tbody tr:last-child { border-bottom: none; }

td {
  padding: 10px 14px;
  font-size: 0.9rem;
  white-space: normal;
}

td.num {
  text-align: right;
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.85rem;
  white-space: nowrap;
}

td.ticker-cell {
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
  white-space: nowrap;
}

.val-positive {
  color: var(--color-positive);
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.85rem;
  text-align: right;
  display: block;
}

.val-negative {
  color: var(--color-negative);
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.85rem;
  text-align: right;
  display: block;
}

.val-caution {
  color: var(--color-warning);
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.85rem;
  text-align: right;
  display: block;
}

.table-note {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
  margin-bottom: 0;
}

/* 52W Range bar */
.range-cell { min-width: 190px; }

.range-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.7rem;
}

.range-track {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  position: relative;
  min-width: 60px;
}

.range-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  left: var(--pos);
}

.range-lo { color: var(--color-text-secondary); }
.range-hi { color: var(--color-text-secondary); }

/* === Hero === */
.hero {
  padding: 44px 0 16px;
  border-bottom: 1px solid var(--color-border);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-tag-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.75rem;
  color: var(--color-positive);
  margin-bottom: 16px;
}

.hero-thesis {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}

.hero-thesis .highlight { color: var(--color-accent); }

.hero-sub {
  font-size: 1rem;
  color: var(--color-text-primary);
  max-width: 560px;
  margin-bottom: 0;
  line-height: 1.65;
}

/* Override h2::before for hero -- hero has no h2 */

/* === Sections === */
.section {
  padding: 40px 0;
  border-bottom: 1px solid var(--color-border);
}

.section:last-child { border-bottom: none; }

.section > h2 { margin-top: 0; }

/* === Metric Cards (index page) === */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-purple));
  opacity: 0;
  transition: opacity 0.2s;
}

.metric-card:hover {
  background: var(--color-card-hover);
  border-color: rgba(0, 212, 160, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 212, 160, 0.08);
}

.metric-card:hover::before { opacity: 1; }

.metric-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 6px;
}

.metric-card-def {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  line-height: 1.55;
}

.metric-card-link {
  font-size: 0.78rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* === Metric Blocks (metrics.html) === */
.metrics-intro {
  padding: 40px 0;
  border-bottom: 1px solid var(--color-border);
}

.metrics-intro h1 { margin-bottom: 10px; }

.metric-block {
  padding: 44px 0;
  border-bottom: 1px solid var(--color-border);
}

.metric-block:last-child { border-bottom: none; }

.metric-block > h2 {
  margin-top: 0;
  font-size: 1.5rem;
}

.metric-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: -4px;
  margin-bottom: 22px;
  padding-left: 11px; /* align with h2 text (past the bar) */
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  margin-top: 20px;
}

.metric-label:first-child { margin-top: 0; }

.how-to-read {
  background: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
  margin: 14px 0;
}

.how-to-read ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.how-to-read ul li {
  padding: 3px 0;
  font-size: 0.9rem;
}

.caveat-box {
  background: rgba(255, 166, 87, 0.08);
  border-left: 3px solid var(--color-warning);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin-top: 16px;
}

.caveat-box p {
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.caveat-box strong { color: var(--color-warning); }

.example-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  margin-top: 20px;
}

.example-table {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0 0;
}

.example-table .table-wrap {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
}

.example-table table { font-size: 0.85rem; }
.example-table thead th { font-size: 0.6rem; }

/* === Accordion (faq.html) === */
.faq-intro {
  padding: 40px 0 0;
}

.faq-intro h1 { margin-bottom: 10px; }

.accordion {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 28px;
}

.accordion-item { border-bottom: 1px solid var(--color-border); }
.accordion-item:last-child { border-bottom: none; }

.accordion-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 18px 20px;
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary);
  transition: background 0.15s;
}

.accordion-trigger:hover { background: var(--color-accent-light); }

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

.accordion-icon {
  font-size: 1.2rem;
  color: var(--color-accent);
  flex-shrink: 0;
  margin-left: 16px;
  line-height: 1;
  font-weight: 400;
  user-select: none;
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease-in-out;
}

.accordion-body.open { max-height: 6000px; }

.accordion-content {
  padding: 22px 20px;
  background: rgba(0, 212, 160, 0.04);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text-primary);
}

.accordion-content p { margin-bottom: 14px; }
.accordion-content p:last-child { margin-bottom: 0; }

.accordion-item.palantir-story .accordion-content {
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-primary);
}

.accordion-item.palantir-story .accordion-trigger { font-style: italic; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-good {
  background: rgba(63, 185, 80, 0.12);
  color: var(--color-positive);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-caution {
  background: rgba(255, 166, 87, 0.12);
  color: var(--color-warning);
  border: 1px solid rgba(255, 166, 87, 0.3);
}

.badge-negative {
  background: rgba(248, 81, 73, 0.12);
  color: var(--color-negative);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

/* neutral badge (no modifier class) */
.badge:not(.badge-good):not(.badge-caution):not(.badge-negative) {
  background: var(--color-tag-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* === FAQ Teaser === */
.faq-teaser {
  padding: 18px 20px;
  background: var(--color-accent-light);
  border-radius: 8px;
  border-left: 3px solid var(--color-accent);
  margin-top: 40px;
}

.faq-teaser p { margin: 0; font-size: 0.9375rem; }
.faq-teaser a { font-weight: 700; }

/* === Ticker tags (watchlist) === */
.ticker-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.ticker-tag {
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-tag-bg);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  transition: all 0.15s;
}

.ticker-tag:hover {
  border-color: rgba(0, 212, 160, 0.5);
  background: var(--color-accent-light);
}

/* === Setup Guides === */
.guide-intro {
  padding: 40px 0;
  border-bottom: 1px solid var(--color-border);
}

.guide-intro h1 { margin-bottom: 10px; }

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.guide-step {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  padding: 18px 22px;
}

.guide-step-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 10px;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  background: var(--color-accent-light);
  border: 1px solid rgba(0, 212, 160, 0.25);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
  flex-shrink: 0;
  margin-top: 2px;
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
}

.guide-step-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.45;
}

.guide-step-body {
  padding-left: 40px;
}

.guide-step-body p {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  margin-bottom: 10px;
  line-height: 1.6;
}

.guide-step-body p:last-child { margin-bottom: 0; }

.guide-step-body ul,
.guide-step-body ol {
  padding-left: 18px;
  margin-bottom: 10px;
}

.guide-step-body li {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  margin-bottom: 5px;
  line-height: 1.55;
}

.guide-step-body .how-to-read { margin-top: 12px; }
.guide-step-body .caveat-box { margin-top: 12px; }
.guide-step-body .table-wrap { margin-top: 12px; }

.ui-text {
  font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.78rem;
  color: var(--color-accent);
  background: var(--color-accent-light);
  border: 1px solid rgba(0, 212, 160, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.guide-note {
  background: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 24px;
  font-size: 0.875rem;
  color: var(--color-text-primary);
}

.guide-note p { margin-bottom: 0; }
.guide-note strong { color: var(--color-accent); }

.filter-strong { color: var(--color-positive); font-weight: 600; }
.filter-caution { color: var(--color-warning); font-weight: 600; }

/* === Responsive === */
@media (max-width: 1023px) {
  .site-layout {
    /* minmax(0, ...) preserved from the desktop rule (v3.34.8): a plain 1fr
       here reintroduces the implicit min-width:auto grid-item bug at exactly
       the narrow widths where overflowing content (e.g. the screener's
       universe-button row) needs the track to clip/wrap instead of growing. */
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: column;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(12px);
    background: rgba(22, 27, 34, 0.92);
  }

  .sidebar-brand {
    padding: 14px 16px;
    border-bottom: none;
    margin: 0;
  }

  /* Hamburger button, top-right of the bar */
  .nav-burger {
    display: block;
    position: absolute;
    top: 6px;
    right: 10px;
    padding: 8px 12px;
    font-size: 0;            /* hide any stray text node */
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-primary);
    user-select: none;
  }
  .nav-burger::before { content: "\2630"; font-size: 1.4rem; }       /* hamburger */
  .nav-toggle:checked ~ .nav-burger::before { content: "\2715"; }    /* close (x) */

  /* Nav collapses by default; revealed when the toggle is checked */
  .sidebar-nav {
    display: none;
    padding: 4px 0 8px;
    border-top: 1px solid var(--color-border);
  }
  .nav-toggle:checked ~ .sidebar-nav { display: block; }

  .sidebar-nav > ul { display: block; }

  .sidebar-nav > ul > li > a {
    display: block;
    padding: 11px 18px;
    font-size: 0.9rem;
  }

  .sidebar-nav > ul > li > a.active {
    border-left: 3px solid var(--color-accent);
    padding-left: 15px;
    color: var(--color-accent);
  }

  .nav-section-label,
  .metric-links,
  .sidebar-footer { display: none; }
}

@media (max-width: 767px) {
  .metric-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  .hero-thesis { font-size: 1.375rem; }
  .main-content { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .accordion-body { transition: none; }
  .metric-card { transition: none; }
  .metric-card:hover { transform: none; }
}
