/* ═══════════════════════════════════════════════════════
   Deep Value Screener — Professional Financial Dashboard
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2333;
  --bg-header: #010409;
  --border: #30363d;
  --border-light: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #0f3460;
  --accent-light: #1a4a7a;
  --green: #4ade80;
  --green-dim: #22543d;
  --red: #f87171;
  --red-dim: #7f1d1d;
  --yellow: #fbbf24;
  --yellow-dim: #78350f;
  --orange: #fb923c;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --cyan: #22d3ee;
  --warning: #e94560;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Top Bar ──────────────────────────────────────────── */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo a { color: var(--text-primary); text-decoration: none; }
.logo a:hover { color: var(--blue); }
.top-bar .spacer { flex: 1; }
.nav-link {
  color: var(--text-secondary); text-decoration: none; font-size: 0.85rem;
  padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-link:hover { color: var(--text-primary); border-color: var(--text-muted); }
.nav-link.active { color: var(--blue); border-color: var(--blue); background: rgba(96,165,250,0.08); }

.timestamp {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.index-tabs {
  display: flex;
  gap: 2px;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  letter-spacing: 0.05em;
}

.tab:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── Loading / Error States ───────────────────────────── */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  text-align: center;
  padding: 4rem 2rem;
}

.error-msg {
  color: var(--red);
  font-size: 1rem;
}

/* ── Pipeline Bar ─────────────────────────────────────── */

.pipeline-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.pipeline-arrow {
  color: var(--text-muted);
}

.pipeline-num {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Main Grid ────────────────────────────────────────── */

.dashboard {
  padding: 1rem 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  align-items: start;
}

.col-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.col-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 72px;
}

/* ── Cards ────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Data Tables ──────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  position: relative;
}

.data-table th.num {
  text-align: right;
}

.data-table th:hover {
  color: var(--text-secondary);
}

.data-table th.sorted-asc::after { content: ' \25B2'; font-size: 0.65rem; }
.data-table th.sorted-desc::after { content: ' \25BC'; font-size: 0.65rem; }

.data-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.data-table tbody tr {
  transition: background 0.1s;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  color: var(--text-primary);
}

/* ── Ticker Cell ──────────────────────────────────────── */

.ticker {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.sector-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Score Bar ────────────────────────────────────────── */

.score-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}

.score-bar {
  width: 50px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.score-num {
  font-family: var(--font-mono);
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ── Weight Bar (position table) ──────────────────────── */

.weight-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}

.weight-bar {
  width: 40px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.weight-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
}

/* ── Color Utilities ──────────────────────────────────── */

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text-secondary); }
.warning { color: var(--yellow); }

/* ── Risk Card ────────────────────────────────────────── */

.sharpe-display {
  text-align: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.sharpe-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.sharpe-value {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sharpe-good { color: var(--green); }
.sharpe-ok { color: var(--yellow); }
.sharpe-poor { color: var(--red); }

.risk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.risk-stat {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.risk-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.risk-stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
}

.risk-meta {
  margin-top: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Score Legend ──────────────────────────────────────── */

.score-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Value Trap Card ──────────────────────────────────── */

.trap-badge {
  background: var(--warning);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-family: var(--font-mono);
}

.trap-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.trap-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.3rem 0;
}

.trap-type-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.trap-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.trap-type-count {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Full-width collapsible trap card ─────────────────── */

.trap-card-full {
  margin-top: 1rem;
}

.trap-details-wrap {
  cursor: default;
}

.trap-summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.trap-summary::-webkit-details-marker { display: none; }
.trap-summary::marker { display: none; content: ""; }

.trap-summary .card-title::after {
  content: '\25B6';
  font-size: 0.65rem;
  margin-left: auto;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.trap-details-wrap[open] .trap-summary .card-title::after {
  transform: rotate(90deg);
}

.trap-explainer {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.trap-explainer p {
  margin-bottom: 0.5rem;
}

.trap-type-explainer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
  margin-top: 0.5rem;
}

.trap-type-explainer-grid div {
  font-size: 0.78rem;
  line-height: 1.5;
}

.trap-type-explainer-grid strong {
  color: var(--text-primary);
}

.trap-detail {
  margin-top: 0.75rem;
}

.trap-table .trap-type-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.trap-tag-momentum { background: var(--orange); color: #000; }
.trap-tag-altman_z { background: var(--red); color: #fff; }
.trap-tag-dividend_trap { background: var(--yellow); color: #000; }
.trap-tag-forward_pe_revision { background: var(--purple); color: #fff; }
.trap-tag-negative_equity { background: #f472b6; color: #fff; }
.trap-tag-legacy { background: var(--text-muted); color: var(--bg-primary); }

.trap-reason {
  max-width: 500px;
  white-space: normal;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ── Footer ───────────────────────────────────────────── */

.footer {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  border-top: 1px solid var(--border-light);
}

.glossary {
  margin-bottom: 1rem;
}

.glossary summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.4rem 2rem;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.glossary-grid strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-right: 0.3rem;
}

.glossary-section-title {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.6rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border-light);
}

.attribution {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Responsive ───────────────────────────────────────── */

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

  .col-right {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  html { font-size: 13px; }

  .top-bar {
    flex-wrap: nowrap;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .index-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .tab {
    flex: 1;
    text-align: center;
  }

  .dashboard {
    padding: 0.75rem;
  }

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

  .risk-grid {
    grid-template-columns: 1fr 1fr;
  }

  .trap-type-explainer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .logo { font-size: 0.95rem; }
  .tab { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
}

/* ── Guide Tab Divider ────────────────────────────────── */

.tab-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 0.4rem;
  align-self: center;
}

.tab-guide {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0;
}

/* ── Guide Panel ─────────────────────────────────────── */

.guide-panel {
  padding: 0 1.5rem 3rem;
  max-width: 1100px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease-out both;
}

.guide-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Hero */

.guide-hero {
  background: linear-gradient(135deg, var(--accent) 0%, #0a1628 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 1rem;
}

.guide-hero-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.guide-hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.6;
}

.guide-hero-visual {
  flex-shrink: 0;
}

.guide-formula-display {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  text-align: center;
}

.guide-formula-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.guide-formula {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.guide-formula sub {
  font-size: 0.6em;
  opacity: 0.7;
}

.guide-formula-op {
  color: var(--text-muted);
  font-weight: 400;
}

/* Sections */

.guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}

.guide-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-light);
}

.guide-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1rem;
}

/* Overview Cards */

.guide-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.guide-overview-card {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 1.2rem 1rem;
  text-align: center;
}

.guide-overview-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--blue);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.guide-overview-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.guide-overview-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Reference Tables */

.guide-table-wrap {
  overflow-x: auto;
}

.guide-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.guide-ref-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.guide-ref-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  line-height: 1.5;
  vertical-align: top;
}

.guide-ref-table code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--blue);
  font-weight: 600;
  background: var(--bg-primary);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.guide-ref-compact td:first-child {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Score Cards */

.guide-score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.guide-score-card {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  border-left: 3px solid;
}

.guide-score-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.guide-score-weight {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
}

.guide-score-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.guide-score-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-score-example {
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: rgba(96, 165, 250, 0.06);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-score-example strong {
  color: var(--text-primary);
}

/* Risk Grid */

.guide-risk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.guide-risk-item {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.guide-risk-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.guide-risk-explain code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  margin-bottom: 0.3rem;
}

.guide-risk-explain p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 0.3rem;
}

/* Trap Cards */

.guide-trap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.guide-trap-card {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
}

.guide-trap-header {
  margin-bottom: 0.6rem;
}

.guide-trap-trigger {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.guide-trap-why {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-trap-formula {
  margin-top: 0.5rem;
}

.guide-trap-formula code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

/* Tips */

.guide-tips-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guide-tip {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
}

.guide-tip-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
}

.guide-tip h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.guide-tip p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* References */

.guide-references {
  background: transparent;
  border: none;
  padding: 0;
}

.guide-ref-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.guide-ref-links a {
  font-size: 0.78rem;
  color: var(--blue);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  transition: all 0.15s;
}

.guide-ref-links a:hover {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

/* Guide Responsive */

@media (max-width: 768px) {
  .guide-hero {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }
  .guide-hero-subtitle { max-width: 100%; }
  .guide-overview-grid { grid-template-columns: 1fr 1fr; }
  .guide-score-grid { grid-template-columns: 1fr; }
  .guide-risk-grid { grid-template-columns: 1fr; }
  .guide-trap-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .guide-overview-grid { grid-template-columns: 1fr; }
  .guide-formula { font-size: 0.85rem; }
}

/* ── Animations ───────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.3s ease-out both;
}

.col-left .card:nth-child(1) { animation-delay: 0.05s; }
.col-left .card:nth-child(2) { animation-delay: 0.1s; }
.col-right .card:nth-child(1) { animation-delay: 0.08s; }
.col-right .card:nth-child(2) { animation-delay: 0.12s; }
.col-right .card:nth-child(3) { animation-delay: 0.16s; }

/* ── Enrichment: Detail Row & Cross-Links ── */
.ticker-link { color: var(--accent-light); text-decoration: none; font-weight: 700; font-family: var(--font-mono); font-size: 0.9rem; }
.ticker-link:hover { color: var(--green); text-decoration: underline; }
.dd-link-btn { display: inline-block; background: var(--accent-light); color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 0.6rem; font-weight: 700; text-decoration: none; margin-right: 4px; }
.dd-link-btn:hover { background: var(--green); }
.dv-expand-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; font-size: 0.65rem; padding: 2px 6px; border-radius: 3px; line-height: 1; }
.dv-expand-btn:hover { border-color: var(--text-secondary); color: var(--text-secondary); }
.dv-detail-cell { padding: 0 !important; background: var(--bg-card); border-bottom: 2px solid var(--accent-light); }
.dv-detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; padding: 0.8rem 1rem; }
.dv-detail-col { min-width: 0; }
.dv-detail-title { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.dv-mini-table { width: 100%; font-size: 0.78rem; border-collapse: collapse; }
.dv-mini-table td { padding: 0.15rem 0.3rem; border-bottom: 1px solid var(--border-light); }
.dv-mini-label { color: var(--text-secondary); white-space: nowrap; }
.dv-mini-table .num { text-align: right; font-family: var(--font-mono); color: var(--text-primary); }
.dv-dcf-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.6rem; }
.dv-dcf-row { display: flex; justify-content: space-between; font-size: 0.8rem; padding: 0.1rem 0; }
.dv-dcf-row span { color: var(--text-secondary); }
.dv-dcf-row strong { font-family: var(--font-mono); color: var(--text-primary); }
.dv-dcf-upside { text-align: center; font-weight: 700; font-size: 0.82rem; padding: 0.3rem 0 0.1rem; }
.dv-dcf-upside.positive { color: var(--green); }
.dv-dcf-upside.negative { color: var(--red); }
.dv-dcf-upside.neutral { color: var(--yellow); }
.dv-dcf-note { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.2rem; }
.dv-peers { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.dv-peer-chip { display: inline-block; padding: 0.15rem 0.45rem; border: 1px dashed var(--border); border-radius: 12px; font-size: 0.72rem; font-family: var(--font-mono); color: var(--text-secondary); text-decoration: none; }
.dv-peer-chip:hover { border-color: var(--accent-light); color: var(--accent-light); }
.dv-full-link { display: block; margin-top: 0.6rem; font-size: 0.75rem; color: var(--accent-light); text-decoration: none; }
.dv-full-link:hover { text-decoration: underline; }
/* ── Due Diligence Dashboard ── */
.dd-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.dd-header h2 { margin: 0; font-size: 1.3rem; color: var(--text-primary); }
.dd-progress { font-size: 0.78rem; color: var(--text-muted); }
.dd-subtitle { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1rem; }
.dd-tracker-table th { font-size: 0.68rem; }
.dd-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.68rem; font-weight: 600; }
.dd-pass { background: var(--green-dim); color: var(--green); }
.dd-caution { background: rgba(251,191,36,0.15); color: var(--yellow); }
.dd-fail { background: var(--red-dim); color: var(--red); }
.dd-pending { background: var(--border-light); color: var(--text-muted); }
.dd-actions { margin-bottom: 0.8rem; }
.dd-dismissed-row { opacity: 0.45; }
.dd-dismissed-header td { font-size: 0.72rem; color: var(--text-muted); padding: 0.6rem 0.5rem 0.3rem; border-top: 2px solid var(--border); font-style: italic; }
.dd-dismiss-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; padding: 0 4px; }
.dd-dismiss-btn:hover { color: var(--red); }
.dd-restore-btn { background: var(--border); color: var(--text-secondary); border: none; padding: 2px 8px; border-radius: 4px; font-size: 0.68rem; cursor: pointer; }
.dd-restore-btn:hover { background: var(--accent-light); color: #fff; }
.dd-run-btn { background: var(--accent-light); color: #fff; border: none; padding: 3px 10px; border-radius: 4px; font-size: 0.72rem; cursor: pointer; font-weight: 600; }
.dd-run-btn:hover { background: var(--accent); }
.dd-loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.dd-report { margin-top: 1.5rem; }
.dd-report-header { margin-bottom: 1rem; }
.dd-report-header h2 { font-size: 1.2rem; color: var(--text-primary); margin: 0; }
.dd-report-name { font-weight: 400; color: var(--text-secondary); font-size: 0.9rem; }
.dd-report-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.dd-ext-link { color: var(--accent-light); text-decoration: none; }
.dd-ext-link:hover { text-decoration: underline; }
.dd-step { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 6px; padding: 0.8rem; margin-bottom: 0.8rem; }
.dd-step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border-light); }
.dd-step-title { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.dd-step-verdict { font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 10px; }
.dd-v-pass { background: var(--green-dim); color: var(--green); }
.dd-v-caution { background: rgba(251,191,36,0.15); color: var(--yellow); }
.dd-v-fail { background: var(--red-dim); color: var(--red); }
.dd-check { padding: 0.3rem 0; border-bottom: 1px solid var(--border-light); }
.dd-check:last-child { border-bottom: none; }
.dd-check-row { display: flex; align-items: center; gap: 0.5rem; }
.dd-check-icon { font-size: 0.85rem; width: 1.2rem; text-align: center; flex-shrink: 0; }
.dd-check-pass .dd-check-icon { color: var(--green); }
.dd-check-caution .dd-check-icon { color: var(--yellow); }
.dd-check-fail .dd-check-icon { color: var(--red); }
.dd-check-info .dd-check-icon { color: var(--text-muted); }
.dd-check-title { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); min-width: 140px; }
.dd-check-detail { font-size: 0.78rem; color: var(--text-secondary); font-family: var(--font-mono); }
.dd-check-desc { font-size: 0.72rem; color: var(--text-muted); padding: 0.3rem 0 0 1.7rem; line-height: 1.4; }
.dd-educational { margin: 0.2rem 0 0 1.7rem; }
.dd-educational summary { font-size: 0.68rem; color: var(--accent-light); cursor: pointer; }
.dd-educational p { font-size: 0.72rem; color: var(--text-muted); margin: 0.3rem 0 0; line-height: 1.4; }
.dd-final-verdict { text-align: center; padding: 1rem; border-radius: 6px; margin-top: 1rem; }
.dd-verdict-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dd-verdict-text { font-size: 1.2rem; font-weight: 700; margin: 0.3rem 0; }
.dd-verdict-note { font-size: 0.68rem; color: var(--text-muted); font-style: italic; }

@media (max-width: 768px) {
  .dd-check-row { flex-wrap: wrap; }
  .dd-check-title { min-width: 100%; }
}

.dcf-penalty-tag { display: inline-block; font-size: 0.6rem; color: var(--orange); background: rgba(251,147,60,0.15); padding: 1px 4px; border-radius: 3px; margin-left: 4px; font-weight: 600; vertical-align: middle; }
.dv-conflict { margin-top: 0.5rem; padding: 0.4rem 0.5rem; background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); border-radius: 4px; font-size: 0.7rem; color: var(--yellow); line-height: 1.4; display: flex; gap: 0.3rem; align-items: flex-start; }
.dv-conflict-icon { font-size: 0.85rem; flex-shrink: 0; }
.dv-detail-loading { padding: 1rem; color: var(--text-muted); font-size: 0.8rem; text-align: center; }

@media (max-width: 900px) {
  .dv-detail-grid { grid-template-columns: 1fr; }
}
