:root {
  --bg: #08090d;
  --panel: #0f1117;
  --panel-2: #14171f;
  --border: #1a1d27;
  --border-soft: #22262f;
  --text: #e7e9ee;
  --muted: #7c8093;
  --muted-2: #565a6b;
  --green: #38d39f;
  --green-bg: rgba(56, 211, 159, 0.10);
  --red: #f25c5c;
  --red-bg: rgba(242, 92, 92, 0.10);
  --amber: #f5a623;
  --amber-bg: rgba(245, 166, 35, 0.10);
  --accent: #7aa2ff;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.02), 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* -------- Search page -------- */
.search-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
.search-logo {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.search-title {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  text-align: center;
}
.search-sub {
  color: var(--muted);
  margin: 0 0 32px;
  text-align: center;
  max-width: 480px;
}
.search-box {
  position: relative;
  width: 100%;
  max-width: 560px;
}
.search-input {
  width: 100%;
  padding: 16px 20px 16px 48px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 120ms, background 120ms;
}
.search-input:focus {
  border-color: var(--accent);
  background: var(--panel-2);
}
.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 10;
  display: none;
}
.search-results.open { display: block; }
.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  gap: 16px;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.active {
  background: var(--panel-2);
}
.search-result .sr-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.search-result .sr-ticker {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
}
.search-result .sr-exch {
  color: var(--muted-2);
  font-size: 12px;
  font-family: var(--mono);
}
.recent-row {
  margin-top: 28px;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.recent-label {
  color: var(--muted-2);
  font-size: 12px;
  font-family: var(--mono);
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.recent-chip {
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms;
}
.recent-chip:hover { border-color: var(--accent); }
.recent-clear {
  background: none;
  border: none;
  color: var(--muted-2);
  font-size: 12px;
  cursor: pointer;
  margin-left: auto;
}

/* -------- Report page shell -------- */
.report-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.page {
  margin-bottom: 32px;
}
.page-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

/* -------- Top bar -------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tb-main { display: flex; align-items: baseline; gap: 12px; flex: 1; min-width: 220px; }
.tb-ticker {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.02em;
}
.tb-name {
  font-size: 15px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.tb-exch {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  padding: 2px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  text-transform: uppercase;
}
.tb-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.tb-price-val {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 22px;
}
.tb-change { font-family: var(--mono); font-size: 13px; }
.tb-change.up { color: var(--green); }
.tb-change.down { color: var(--red); }
.tb-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms, border-color 120ms;
}
.btn:hover:not(:disabled) {
  background: #1a1f2b;
  border-color: var(--accent);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.spinning svg { animation: spin 1s linear infinite; }
.btn.busy { position: relative; pointer-events: none; opacity: 0.85; }
.btn.busy::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(122,162,255,0.10) 6px, rgba(122,162,255,0.10) 12px);
  border-radius: inherit;
  animation: stripe-move 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stripe-move { from { background-position: 0 0; } to { background-position: 24px 0; } }
.btn-icon { padding: 8px 10px; }
.btn-icon .btn-label { display: none; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 160px;
  z-index: 20;
  display: none;
  overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--panel-2); }

/* -------- Hero row (gauge + KPI strip) -------- */
.hero-row {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.gauge-card { text-align: center; }
.gauge-score {
  font-family: var(--mono);
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: -12px;
}
.gauge-score .of100 { font-size: 18px; color: var(--muted-2); font-weight: 400; }
.verdict-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.verdict-pill.strong_buy { background: var(--green-bg); color: var(--green); }
.verdict-pill.buy { background: var(--green-bg); color: var(--green); }
.verdict-pill.hold { background: var(--amber-bg); color: var(--amber); }
.verdict-pill.sell { background: var(--red-bg); color: var(--red); }
.verdict-pill.strong_sell { background: var(--red-bg); color: var(--red); }
.verdict-pill.na { background: rgba(124,128,147,0.10); color: var(--muted); }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kpi {
  background: var(--panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.kpi-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
}
.kpi-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* -------- Price chart -------- */
.chart-card { padding: 18px 18px 6px; }
.chart-wrap { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-legend {
  display: flex;
  gap: 16px;
  padding: 8px 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}
.legend-marker { display: inline-flex; align-items: center; gap: 4px; }

/* -------- Score breakdown bars -------- */
.breakdown-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.breakdown {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.breakdown-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.breakdown-label {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.breakdown-weight {
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--mono);
}
.breakdown-score {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 8px;
}
.bar-track {
  position: relative;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
}
.bar-fill.good { background: var(--green); }
.bar-fill.warn { background: var(--amber); }
.bar-fill.bad { background: var(--red); }
.bar-fill.na { background: var(--muted-2); }

/* -------- Metric grids -------- */
.section-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 24px 0 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric.good { border-left-color: var(--green); }
.metric.warn { border-left-color: var(--amber); }
.metric.bad { border-left-color: var(--red); }
.metric-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metric-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  margin-top: 2px;
}
.metric-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 6px;
}
.metric-score {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.metric-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}
.metric-tag.good { background: var(--green-bg); color: var(--green); }
.metric-tag.warn { background: var(--amber-bg); color: var(--amber); }
.metric-tag.bad { background: var(--red-bg); color: var(--red); }
.metric-tag.na { background: rgba(124,128,147,0.10); color: var(--muted); }

/* -------- Quarterly table -------- */
.q-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.q-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  min-width: 560px;
}
.q-table th, .q-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
}
.q-table th:first-child, .q-table td:first-child {
  text-align: left;
  color: var(--muted);
}
.q-table thead th {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.q-table tbody tr:last-child td { border-bottom: none; }
.q-table .pos { color: var(--green); }
.q-table .neg { color: var(--red); }

/* -------- Earnings card -------- */
.earnings-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.earnings-stat {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.earnings-stat-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.earnings-stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
}
.earnings-stat-row + .earnings-stat-row { margin-top: 4px; }
.earnings-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.beat-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
}
.beat-tag.beat { background: var(--green-bg); color: var(--green); }
.beat-tag.miss { background: var(--red-bg); color: var(--red); }
.beat-tag.na   { background: rgba(124,128,147,0.10); color: var(--muted); }

/* -------- Catalysts vs Risks -------- */
.cr-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.cr-col h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.cr-col.cats h3 { color: var(--green); }
.cr-col.risks h3 { color: var(--red); }
.cr-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cr-item {
  display: flex;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.cr-col.cats .cr-item { border-left-color: var(--green); }
.cr-col.risks .cr-item { border-left-color: var(--red); }
.cr-label { font-size: 13px; }
.cr-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* -------- Bottom line -------- */
.bottom-line {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.rating-bar {
  position: relative;
  height: 12px;
  background: linear-gradient(90deg, #f25c5c 0%, #f25c5c 20%, #f5a623 35%, #f5a623 50%, #5dbc8a 65%, #38d39f 80%, #38d39f 100%);
  border-radius: 6px;
  margin: 24px 0 14px;
}
.rating-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 20px;
  background: var(--text);
  transform: translateX(-2px);
  border-radius: 2px;
  box-shadow: 0 0 0 3px var(--bg);
}
.rating-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.bottom-verdict {
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.55;
}

/* -------- Loading / error -------- */
.center-msg {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  padding: 32px;
}
.center-msg .ticker-big {
  font-family: var(--mono);
  font-size: 32px;
  letter-spacing: 0.04em;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.error-box {
  border: 1px solid var(--red);
  background: var(--red-bg);
  color: var(--red);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  max-width: 480px;
  font-family: var(--mono);
}

/* -------- Investment Lens picker -------- */
.lens-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.lens-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-right: 6px;
}
.lens-pill {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.lens-pill:hover { color: var(--text); border-color: var(--accent); }
.lens-pill.active {
  background: rgba(122,162,255,0.10);
  border-color: var(--accent);
  color: var(--accent);
}
.lens-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lens badge inside verdict pill */
.verdict-lens {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: 1px;
}

/* Income lens — highlight the dividend KPI cell */
body.lens-income .kpi-dividend {
  background: var(--amber-bg);
  position: relative;
}
body.lens-income .kpi-dividend::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--amber);
}

/* -------- Valuation context strip (under each valuation card) -------- */
.metric-context {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mc-pct-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.mc-pct-bar {
  flex: 1;
  position: relative;
  height: 4px;
  background: var(--panel-2);
  border-radius: 2px;
  min-width: 60px;
}
.mc-pct-marker {
  position: absolute;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  transform: translateX(-4px);
  box-shadow: 0 0 0 2px var(--panel);
}
.mc-pct-text {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  white-space: nowrap;
}
.mc-sector {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
}
.mc-sector-label { color: var(--muted-2); }
.mc-sector-delta {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}
.mc-sector-delta.cheap { background: var(--green-bg); color: var(--green); }
.mc-sector-delta.rich  { background: var(--red-bg);   color: var(--red); }
.mc-sector-delta.fair  { background: rgba(124,128,147,0.10); color: var(--muted); }

/* -------- Smart Money card -------- */
.smart-money-card { padding: 16px 20px; }
.sm-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 14px;
  flex-wrap: wrap;
}
.sm-net { display: flex; flex-direction: column; gap: 4px; }
.sm-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.sm-net-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
}
.sm-net-val.buy  { color: var(--green); }
.sm-net-val.sell { color: var(--red); }
.sm-net-val.flat { color: var(--muted); }
.sm-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.sm-ownership-wrap { margin-bottom: 16px; }
.sm-ownership-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 6px;
}
.sm-ownership-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--panel-2);
}
.sm-own-seg { height: 100%; transition: width 200ms; }
.sm-own-insider { background: var(--accent); }
.sm-own-inst    { background: var(--green); }
.sm-own-retail  { background: var(--muted-2); }
.sm-ownership-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.sm-ownership-legend .sm-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

.sm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.sm-col-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 8px;
}
.sm-top-list, .sm-tx-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sm-top-item, .sm-tx-item {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
}
.sm-top-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.sm-top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-top-pct  { font-weight: 500; }
.sm-top-change { font-size: 11px; }
.sm-top-change.up   { color: var(--green); }
.sm-top-change.down { color: var(--red); }

.sm-tx-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 10px;
  align-items: baseline;
}
.sm-tx-date { color: var(--muted-2); font-size: 11px; }
.sm-tx-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.sm-tx-value { font-weight: 500; }
.sm-tx-value.buy { color: var(--green); }
.sm-tx-value.sell { color: var(--red); }
.sm-tx-role { grid-column: 2; color: var(--muted-2); font-size: 10.5px; }

@media (max-width: 700px) {
  .sm-grid { grid-template-columns: 1fr; }
  .sm-head { flex-direction: column; align-items: flex-start; }
  .sm-meta { text-align: left; }
}

/* -------- Analyst targets card -------- */
.analyst-card { padding: 18px 20px; }
.analyst-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.analyst-pill {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}
.analyst-pill.buy, .analyst-pill.strong_buy { background: var(--green-bg); color: var(--green); border-color: transparent; }
.analyst-pill.hold { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.analyst-pill.sell, .analyst-pill.strong_sell, .analyst-pill.underperform { background: var(--red-bg); color: var(--red); border-color: transparent; }

.targets-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.target-cell {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}
.target-cell.target-mid {
  border-color: var(--accent);
  background: rgba(122,162,255,0.08);
}
.target-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.target-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 2px;
}
.target-implied {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.target-implied.up { color: var(--green); }
.target-implied.down { color: var(--red); }

.targets-bar-wrap { margin-bottom: 10px; }
.targets-bar {
  position: relative;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  margin-top: 6px;
}
.targets-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--red), var(--amber) 50%, var(--green));
  border-radius: 3px;
}
.targets-bar-axis {
  display: flex;
  justify-content: space-between;
  position: relative;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.targets-bar-current {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  background: var(--panel);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-soft);
  top: -22px;
  white-space: nowrap;
}
.targets-bar-current::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--border-soft);
}
.analyst-note {
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--mono);
  margin-top: 4px;
  line-height: 1.5;
}

/* -------- Stale banner -------- */
.stale-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 14px;
}
.stale-banner svg { flex-shrink: 0; }
.stale-banner strong { color: var(--amber); font-weight: 600; }

/* -------- About card -------- */
.about-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 16px;
}
.about-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.about-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
}
.about-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.about-text {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
}
.about-link {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}

/* -------- Footer / fetched-at -------- */
.fetched-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity 200ms;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* -------- Responsive -------- */
@media (max-width: 900px) {
  .hero-row { grid-template-columns: 1fr; }
  .breakdown-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .cr-row { grid-template-columns: 1fr; }
  .earnings-card { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .report-shell { padding: 14px; }
  .topbar { padding: 14px; gap: 14px; }
  .tb-name { display: none; }
  .tb-ticker { font-size: 20px; }
  .tb-price-val { font-size: 18px; }
  .metric-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .search-title { font-size: 24px; }
  .gauge-score { font-size: 40px; }
  .targets-row { grid-template-columns: 1fr; gap: 8px; }
  .target-val { font-size: 18px; }
}

/* Hide interactive chrome during share/export captures */
.exporting .topbar .tb-actions,
.exporting .fetched-row,
.exporting .dropdown-menu,
.exporting #how-modal { display: none !important; }

/* -------- Modal (How methodology) -------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(720px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: modal-in 180ms ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
.modal-body {
  padding: 18px 24px 24px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
.modal-body h3 {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 10px;
}
.modal-body p { margin: 8px 0; }
.modal-body .how-lead { color: var(--text); }
.modal-body .how-note { color: var(--muted); font-size: 12.5px; }
.modal-body .how-weights, .modal-body .how-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-body .how-weights li { display: flex; align-items: center; gap: 10px; }
.modal-body .how-list li { color: var(--muted); }
.modal-body .how-list strong, .modal-body .how-list em { color: var(--text); }
.modal-body strong { color: var(--text); }
.how-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 56px;
  text-align: center;
}
.how-tag.good { background: var(--green-bg); color: var(--green); }
.how-tag.warn { background: var(--amber-bg); color: var(--amber); }
.how-tag.bad  { background: var(--red-bg);   color: var(--red); }
.how-tag.na   { background: rgba(124,128,147,0.10); color: var(--muted); }

.how-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 4px 0 4px;
}
.how-table th, .how-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.how-table th {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.how-table td:first-child {
  font-family: var(--mono);
  white-space: nowrap;
  color: var(--text);
  padding-right: 16px;
}
.how-table td:last-child {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.how-table tr:last-child td { border-bottom: none; }

@media (max-width: 600px) {
  .modal { padding: 12px; }
  .modal-body { padding: 14px 16px 20px; font-size: 13px; }
  .modal-head h2 { font-size: 15px; }
  .how-table td:first-child { white-space: normal; }
}

/* -------- Print / PDF rendering --------
 * Playwright renders at A4 width (~794 CSS px), which is below several mobile
 * breakpoints. We explicitly force the desktop grid layouts back on so the
 * report stays dense and 2-column where it should be. Page margin is empty
 * — Playwright's headerTemplate/footerTemplate fill the margin area with the
 * stockcue.app branding and page numbers.
 */
@page { size: A4; }
@media print {
  html, body {
    background: var(--bg) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.printing .topbar .tb-actions,
  body.printing .fetched-row,
  body.printing .page-tag,
  body.printing #how-modal,
  body.printing .dropdown,
  body.printing .toast,
  body.printing #lens-row { display: none !important; }

  body.printing { font-size: 10.5px; }
  body.printing .report-shell { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
  body.printing .page { margin-bottom: 0 !important; }
  body.printing #page2 { page-break-before: auto; }

  /* ---- Force desktop multi-column layouts at A4 print width ---- */
  body.printing .hero-row        { grid-template-columns: 240px 1fr !important; gap: 8px !important; margin-bottom: 8px !important; }
  body.printing .kpi-strip       { grid-template-columns: repeat(3, 1fr) !important; }
  body.printing .breakdown-row   { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; margin-bottom: 8px !important; }
  body.printing .metric-grid     { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }
  body.printing .cr-row          { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  body.printing .earnings-card   { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  body.printing .sm-grid         { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  body.printing .targets-row     { grid-template-columns: repeat(3, 1fr) !important; gap: 6px !important; }

  /* Avoid splitting individual blocks across pages */
  body.printing .card,
  body.printing .metric,
  body.printing .breakdown,
  body.printing .analyst-card,
  body.printing .smart-money-card,
  body.printing .bottom-line,
  body.printing .about-card,
  body.printing .q-table-wrap,
  body.printing .stale-banner,
  body.printing .kpi-strip,
  body.printing .cr-item,
  body.printing .target-cell,
  body.printing .gauge-card,
  body.printing .breakdown-row,
  body.printing .targets-row,
  body.printing .hero-row,
  body.printing .sm-top-item,
  body.printing .sm-tx-item { break-inside: avoid; page-break-inside: avoid; }

  /* ---- Title row (topbar) ---- */
  body.printing .topbar { padding: 8px 10px; margin-bottom: 6px; gap: 10px; page-break-after: avoid; }
  body.printing .tb-ticker { font-size: 22px; letter-spacing: 0.02em; }
  body.printing .tb-name { font-size: 11.5px; max-width: 260px; }
  body.printing .tb-price-val { font-size: 17px; }
  body.printing .tb-change { font-size: 11px; }
  body.printing .tb-exch { font-size: 9.5px; padding: 1px 6px; }
  body.printing .section-title {
    margin: 8px 0 5px;
    font-size: 9.5px;
    letter-spacing: 0.10em;
    /* Never orphan a section heading from its content across a page break */
    page-break-after: avoid;
    break-after: avoid;
  }

  /* ---- Cards generally ---- */
  body.printing .card { padding: 9px 12px; }
  body.printing .card-title { margin-bottom: 6px; font-size: 9px; }

  /* ---- Hero: gauge (narrow) + KPIs (wide), side by side ---- */
  body.printing .gauge-card { padding: 8px 10px 10px; }
  body.printing .gauge-card .card-title { display: none; }
  body.printing .gauge-score { font-size: 26px; margin-top: -10px; }
  body.printing .gauge-score .of100 { font-size: 11px; }
  body.printing .verdict-pill { padding: 3px 9px; font-size: 9.5px; margin-top: 4px; }
  body.printing .verdict-lens { font-size: 7.5px; }
  body.printing .kpi { padding: 8px 10px; }
  body.printing .kpi-value { font-size: 13.5px; }
  body.printing .kpi-label { font-size: 8.5px; }
  body.printing .kpi-sub { font-size: 8.5px; }

  /* ---- Price chart ---- */
  body.printing .chart-card { padding: 9px 12px 2px; margin-bottom: 8px; }
  body.printing .chart-svg { height: 130px; }
  body.printing .chart-legend { padding: 4px 0 6px; font-size: 8.5px; gap: 12px; }

  /* ---- Breakdown bars (now side-by-side) ---- */
  body.printing .breakdown { padding: 9px 12px; }
  body.printing .breakdown-score { font-size: 16px; margin-bottom: 5px; }
  body.printing .breakdown-label { font-size: 9px; }
  body.printing .breakdown-weight { font-size: 9px; }
  body.printing .bar-track { height: 5px; }

  /* ---- Metric grids ---- */
  body.printing .metric { padding: 7px 9px; }
  body.printing .metric-label { font-size: 8.5px; }
  body.printing .metric-value { font-size: 13px; }
  body.printing .metric-score { font-size: 8.5px; }
  body.printing .metric-tag { font-size: 8px; padding: 0 4px; }
  body.printing .metric-foot { margin-top: 3px; }

  /* ---- Valuation context strip ---- */
  body.printing .metric-context { margin-top: 4px; padding-top: 4px; gap: 2px; }
  body.printing .mc-pct-line { font-size: 8.5px; gap: 5px; }
  body.printing .mc-pct-text { font-size: 8px; }
  body.printing .mc-sector { font-size: 8.5px; }
  body.printing .mc-sector-delta { font-size: 8px; padding: 0 4px; }
  body.printing .mc-pct-bar { height: 3px; }

  /* ---- Quarterly table ---- */
  body.printing .q-table { font-size: 10px; min-width: 0; }
  body.printing .q-table th, body.printing .q-table td { padding: 5px 8px; }

  /* ---- Earnings card ---- */
  body.printing .earnings-stat { padding: 7px 10px; }
  body.printing .earnings-stat-row { font-size: 10.5px; }
  body.printing .earnings-stat-label { font-size: 8.5px; margin-bottom: 4px; }
  body.printing .earnings-meta { margin-bottom: 6px; font-size: 10px; }

  /* ---- Smart Money ---- */
  body.printing .smart-money-card { padding: 9px 12px; }
  body.printing .sm-net-val { font-size: 14px; }
  body.printing .sm-label { font-size: 8.5px; }
  body.printing .sm-meta { font-size: 9px; }
  body.printing .sm-top-item, body.printing .sm-tx-item { padding: 5px 8px; font-size: 9.5px; }
  body.printing .sm-tx-date { font-size: 8.5px; }
  body.printing .sm-tx-role { font-size: 8.5px; }
  body.printing .sm-ownership-wrap { margin-bottom: 6px; }
  body.printing .sm-ownership-label { font-size: 8.5px; margin-bottom: 4px; }
  body.printing .sm-ownership-legend { font-size: 9px; gap: 10px; margin-top: 4px; }
  body.printing .sm-ownership-bar { height: 7px; }

  /* ---- Analyst targets ---- */
  body.printing .analyst-card { padding: 9px 12px; }
  body.printing .target-cell { padding: 7px 9px; }
  body.printing .target-val { font-size: 13px; }
  body.printing .target-label { font-size: 8.5px; }
  body.printing .target-implied { font-size: 9.5px; }
  body.printing .analyst-pill { font-size: 9px; padding: 2px 7px; }
  body.printing .analyst-note { font-size: 8.5px; margin-top: 3px; }
  body.printing .analyst-head { margin-bottom: 8px; }

  /* ---- Catalysts vs Risks ---- */
  body.printing .cr-item { padding: 5px 9px; font-size: 10px; }
  body.printing .cr-list { gap: 4px; }
  body.printing .cr-col h3 { font-size: 9.5px; margin-bottom: 5px; }

  /* ---- Bottom line ---- */
  body.printing .bottom-line { padding: 10px 14px; }
  body.printing .bottom-verdict { font-size: 11px; margin-top: 10px; }
  body.printing .rating-bar { height: 8px; margin: 20px 0 10px; }
  body.printing .rating-marker { height: 20px; top: -6px; width: 3px; box-shadow: 0 0 0 2px var(--bg); }
  body.printing .rating-labels { font-size: 8.5px; margin-top: 6px; }

  /* ---- About ---- */
  body.printing .about-card { padding: 9px 12px; margin-top: 6px; }
  body.printing .about-text { font-size: 10.5px; line-height: 1.5; margin-top: 4px; }
  body.printing .about-link { font-size: 8.5px; }
  body.printing .about-tag { font-size: 8.5px; padding: 1px 6px; }
  body.printing .about-meta { font-size: 9px; }

  /* ---- Print-only outer padding (since @page margin = 0 for full bleed) ---- */
  body.printing .page,
  body.printing .topbar { margin-left: 4mm; margin-right: 4mm; }
}
