/* ============================================================================
   Foliolytic — Insights & Tearsheet · v4 (2026-04-23)
   Editorial / footer-matching aesthetic: Plus Jakarta Sans, 300/600 weight
   tension, subtle palette, horizontal use of space.
   Two components in one file:
     • Portfolio Insights ("Foliolytic's Read")
     • Monthly Returns Tearsheet (was "Monthly Heatmap")
   ============================================================================ */

/* =============================================================
   LOCAL TOKEN LAYER
   Self-contained tokens so neither component inherits metric-panel
   drift. Resolves to sensible values in both light and dark mode.
   ============================================================= */
.portfolio-insights-panel,
.monthly-tearsheet {
  --ins-text: #1a1a18;
  --ins-text-2: #3d3b36;
  --ins-text-muted: #6b6a65;
  --ins-text-faint: #a3a29c;
  --ins-text-ghost: #c8c7c2;
  --ins-accent: #635BFF;
  --ins-border: #e8e6e1;
  --ins-border-2: #d0cfca;
  --ins-rule: rgba(26, 26, 24, 0.08);
  --ins-surface: transparent;

  /* Heatmap locals — light */
  --hm-text: #1f2530;
  --hm-text-muted: #8a8a84;
  --hm-text-on-green-mid: #064e3b;
  --hm-text-on-red-mid: #7f1d1d;
  --hm-row-alt: rgba(26, 26, 24, 0.015);
}

body.dark-mode .portfolio-insights-panel,
body.dark-mode .monthly-tearsheet {
  --ins-text: #eef0f4;
  --ins-text-2: #c8cdd8;
  --ins-text-muted: #768198;
  --ins-text-faint: #4a5570;
  --ins-text-ghost: #253048;
  --ins-accent: #6e7fff;
  --ins-border: #253048;
  --ins-border-2: #1a2240;
  --ins-rule: rgba(255, 255, 255, 0.06);
  --ins-surface: transparent;

  --hm-text: #d8dce4;
  --hm-text-muted: #626d84;
  --hm-text-on-green-mid: #a7f3d0;
  --hm-text-on-red-mid: #fecaca;
  --hm-row-alt: rgba(255, 255, 255, 0.022);
}

/* =============================================================
   PORTFOLIO INSIGHTS — editorial layout v4 (2026-04-24)
   Stacked flex: header / editorial 2-col / extremes rail / footnote.
   Inset from container edges, symmetrical horizontal padding.
   ============================================================= */
.portfolio-insights-panel {
  position: relative;
  margin: 40px 0 8px;
  padding: 34px clamp(20px, 4vw, 56px) 22px;
  border-top: 1px solid var(--ins-rule);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--ins-text);
  animation: insFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;

  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.portfolio-insights-panel,
.portfolio-insights-panel * {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Section header: kicker + auto-extending hairline --- */
.ins-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: -4px;
}

.ins-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  white-space: nowrap;
}

.ins-header::after {
  content: '';
  flex: 1 1 auto;
  height: 1px;
  background: var(--ins-rule);
}

/* --- Editorial two-column block (headline left · prose right) --- */
.ins-editorial {
  display: grid;
  grid-template-columns: minmax(260px, 5fr) minmax(0, 7fr);
  column-gap: clamp(32px, 4vw, 56px);
  row-gap: 18px;
  align-items: start;
}

.ins-lead { min-width: 0; }

.ins-headline {
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.14;
  color: var(--ins-text);
  margin: 0;
  max-width: 440px;
}

.ins-headline strong,
.ins-headline em {
  font-weight: 600;
  font-style: normal;
  letter-spacing: -0.04em;
}

.ins-body {
  min-width: 0;
  max-width: 68ch; /* widened from 640px — lets lines breathe out */
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ins-body p {
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: 0.005em;
  color: var(--ins-text-2);
  margin: 0;
}

/* Anchor first prose paragraph baseline to the headline top */
.ins-body p:first-of-type { margin-top: 2px; }

.ins-body p:first-child::first-line { color: var(--ins-text); }

.ins-body .quant-highlight {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ins-text);
}

/* --- Quote block: deliberately under-weighted --- */
.ins-quote {
  position: relative;
  padding-left: 12px;
  margin-top: 8px;
}

.ins-quote::before {
  content: '';
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 1.5px;
  border-radius: 1px;
  background: var(--ins-border-2);
  opacity: 0.6;
  transition: opacity 0.45s ease, background 0.45s ease;
}

.ins-quote:hover::before { opacity: 1; background: var(--ins-accent); }

.ins-quote-text {
  font-size: 11.5px;
  font-weight: 300;
  font-style: italic;
  line-height: 1.65;
  letter-spacing: 0.005em;
  color: var(--ins-text-muted);
  margin: 0;
}

.ins-quote-text::before { content: '\201C'; margin-right: 1px; opacity: 0.65; }
.ins-quote-text::after  { content: '\201D'; margin-left: 1px;  opacity: 0.65; }

.ins-quote-attr {
  display: block;
  font-size: 10px;
  font-weight: 300;
  font-style: normal;
  line-height: 1.6;
  margin-top: 3px;
  color: var(--ins-text-faint);
  letter-spacing: 0.01em;
}

/* Anonymous-aphorism variant — italicized to read as folklore rather than a misattribution */
.ins-quote-attr-anon {
  font-style: italic;
  opacity: 0.78;
}

/* --- Extremes rail: full-width under editorial --- */
.ins-extremes {
  padding-top: 18px;
  border-top: 1px solid var(--ins-rule);
}

.ins-extremes-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  margin: 0 0 14px;
}

.ins-stat-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px 28px;
  margin: 0;
  padding: 0;
}

/* Each card: subtle left tick (box-shadow inset, per global UI rules)
   Now a <button> so it's keyboard-focusable + hover-glowable + click-to-pin.
   Reset all default button chrome so it visually matches the original card. */
.ins-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 6px 8px 6px 12px;
  margin-left: -8px;        /* pull back so the inset tick still aligns with the rail edge */
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 1.5px 0 0 var(--ins-rule);
  transition: box-shadow 0.35s ease, background 0.25s ease, transform 0.25s ease;
}

.ins-stat[data-signal="good"] {
  box-shadow: inset 1.5px 0 0 var(--ins-accent);
}

.ins-stat[data-signal="bad"] {
  box-shadow: inset 1.5px 0 0 var(--ins-text-muted);
}

/* Hover affordance — subtle glow + slight lift, matches the metric panel info-button language */
.ins-stat:hover {
  background: color-mix(in srgb, var(--ins-accent) 5%, transparent);
  transform: translateY(-1px);
}
.ins-stat[data-signal="good"]:hover {
  box-shadow:
    inset 2px 0 0 var(--ins-accent),
    0 0 0 1px color-mix(in srgb, var(--ins-accent) 18%, transparent),
    0 4px 14px -6px color-mix(in srgb, var(--ins-accent) 35%, transparent);
}
.ins-stat[data-signal="bad"]:hover {
  box-shadow:
    inset 2px 0 0 var(--ins-text-muted),
    0 0 0 1px color-mix(in srgb, var(--ins-text-muted) 18%, transparent),
    0 4px 14px -6px color-mix(in srgb, var(--ins-text-muted) 25%, transparent);
}

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

/* Hint that the card is interactive — small ⓘ glyph always softly visible, brightens on hover.
   Always-on visibility is the affordance: users immediately read "I can click these". */
.ins-stat::after {
  content: "ⓘ";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--ins-text-faint);
  opacity: 0.32;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.ins-stat:hover::after,
.ins-stat:focus-visible::after {
  opacity: 0.85;
  transform: scale(1.1);
}

.ins-stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  margin: 0;
}

.ins-stat-value {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ins-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.04;
  margin: 1px 0 0;
}

.ins-stat[data-signal="bad"] .ins-stat-value { color: var(--ins-text-2); }

.ins-stat-hint {
  font-size: 9.75px;
  font-weight: 400;
  color: var(--ins-text-faint);
  letter-spacing: 0.015em;
  line-height: 1.35;
  margin: 0;
}

/* Percentile micro-bar */
.ins-stat-bar {
  display: block;
  position: relative;
  height: 2px;
  margin-top: 6px;
  background: var(--ins-rule);
  border-radius: 1px;
}

.ins-stat-bar-dot {
  position: absolute;
  top: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ins-text-muted);
  transform: translateX(-50%);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.ins-stat[data-signal="good"] .ins-stat-bar-dot {
  background: var(--ins-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ins-accent) 18%, transparent);
}

.ins-stat[data-signal="bad"] .ins-stat-bar-dot {
  background: var(--ins-text-2);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ins-text-2) 14%, transparent);
}

/* --- Footnote: one compact line --- */
.ins-footnote {
  margin: 6px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--ins-rule);
  font-size: 10px;
  font-weight: 400;
  color: var(--ins-text-faint);
  letter-spacing: 0.02em;
  line-height: 1.6;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Responsive: large desktop / wide monitor --- */
@media (min-width: 1600px) {
  .portfolio-insights-panel {
    padding-inline: clamp(48px, 5vw, 80px);
  }
  .ins-editorial { column-gap: 60px; }
}

/* --- Responsive: tablet collapse & mobile --- */
@media (max-width: 900px) {
  .portfolio-insights-panel {
    padding: 28px clamp(16px, 4vw, 24px) 18px;
    gap: 20px;
  }
  .ins-editorial {
    grid-template-columns: 1fr;
    row-gap: 14px;
  }
  .ins-headline { max-width: none; }
  .ins-body { max-width: none; }
  .ins-stat-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .ins-footnote {
    white-space: normal;
    text-overflow: clip;
  }
}

@media (max-width: 520px) {
  .ins-stat-rail { grid-template-columns: 1fr; gap: 14px; }
}

/* =============================================================
   MONTHLY TEARSHEET — full-width editorial heatmap
   ============================================================= */
.monthly-tearsheet {
  position: relative;
  margin: 32px 0 8px;
  padding: 28px clamp(20px, 4vw, 56px) 18px;
  border-top: 1px solid var(--ins-rule);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--ins-text);
  animation: insFadeUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.monthly-tearsheet,
.monthly-tearsheet * {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Header: title column left, stats rail right */
.tearsheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 32px;
  align-items: end;
  margin-bottom: 20px;
}

.tearsheet-heading { min-width: 0; }

.tearsheet-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  margin-bottom: 6px;
}

.tearsheet-title {
  font-size: clamp(18px, 1.8vw, 24px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--ins-text);
  margin: 0 0 6px;
}

.tearsheet-title strong { font-weight: 600; letter-spacing: -0.035em; }

.tearsheet-subtitle {
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0.005em;
  color: var(--ins-text-muted);
  margin: 0;
  max-width: 680px;
}

/* Header stats — inline, not stacked vertically */
.tearsheet-stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 32px;
  margin: 0;
  padding: 0;
}

.tearsheet-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: right;
  min-width: 0;
}

.tearsheet-stat .stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  margin: 0;
}

.tearsheet-stat .stat-value {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ins-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin: 2px 0 0;
}

.tearsheet-stat .stat-positive { color: #059669; }
.tearsheet-stat .stat-negative { color: #dc2626; }

body.dark-mode .tearsheet-stat .stat-positive { color: #34d399; }
body.dark-mode .tearsheet-stat .stat-negative { color: #f87171; }

.tearsheet-stat .stat-when {
  font-size: 10px;
  font-weight: 400;
  color: var(--ins-text-faint);
  letter-spacing: 0.01em;
  margin: 2px 0 0;
}

/* Scroll container keeps the table from overflowing on narrow viewports */
.tearsheet-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--ins-border-2) transparent;
}

.tearsheet-scroll::-webkit-scrollbar { height: 6px; }
.tearsheet-scroll::-webkit-scrollbar-thumb { background: var(--ins-border-2); border-radius: 3px; }

.tearsheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

/* Header cells */
.tearsheet-table thead th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  text-align: center;
  padding: 6px 2px 10px;
  background: transparent;
  border-bottom: 1px solid var(--ins-rule);
}

.tearsheet-table thead th.hm-corner { width: 52px; }

.tearsheet-table thead th.hm-ytd-head {
  color: var(--ins-text-muted);
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* Row hover — subtle lift */
.tearsheet-table tbody tr.hm-row-year:hover td,
.tearsheet-table tbody tr.hm-row-year:hover th { filter: brightness(1.08); }

/* Year label cells */
.tearsheet-table .hm-year-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--ins-text-muted);
  letter-spacing: 0.005em;
  text-align: right;
  padding: 6px 10px 6px 2px;
  white-space: nowrap;
}

/* Data cells */
.tearsheet-table .hm-cell,
.tearsheet-table .hm-ytd-cell {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-align: center;
  padding: 7px 2px;
  border-radius: 4px;
  transition: transform 0.2s ease, filter 0.2s ease;
  cursor: default;
  vertical-align: middle;
}

.tearsheet-table .hm-cell:hover,
.tearsheet-table .hm-ytd-cell:hover {
  transform: translateY(-1px);
  filter: brightness(1.12) saturate(1.05);
}

.tearsheet-table .hm-cell.is-empty,
.tearsheet-table .hm-ytd-cell.is-empty {
  background: transparent;
  cursor: default;
}

.tearsheet-table .hm-ytd-cell {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* AVG row — visually distinct from year rows */
.tearsheet-table .hm-row-avg th,
.tearsheet-table .hm-row-avg td {
  padding-top: 10px;
}

.tearsheet-table .hm-year-label-avg {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ins-text);
  text-transform: uppercase;
}

.tearsheet-table .hm-cell-avg,
.tearsheet-table .hm-ytd-cell-avg {
  font-weight: 600;
  border: 1px solid var(--ins-rule);
}

.tearsheet-table .hm-row-avg { position: relative; }

.tearsheet-table .hm-row-avg th::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--ins-border);
  pointer-events: none;
  opacity: 0.55;
}

/* =============================================================
   HALLOWEEN INDICATOR ("Sell in May…") — small subtle line that
   sits between the AVG row and the legend. Tooltip on the ⓘ.
   ============================================================= */
.tearsheet-halloween {
  position: relative;
  margin: 14px 0 4px;
  padding: 10px 16px 0;
  text-align: center;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0.005em;
  color: var(--ins-text-muted);
  border-top: 1px solid var(--ins-rule);
  white-space: nowrap;
  overflow: visible;
}

/* If the table is narrow enough that one line would overflow,
   gracefully fall back to wrapping (handled at the mobile breakpoint
   below). On desktop we expect the line to fit comfortably. */

.tearsheet-halloween .hi-text em {
  font-style: italic;
  font-weight: 500;
  color: var(--ins-text-2);
  letter-spacing: 0;
}

.tearsheet-halloween .hi-text strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.tearsheet-halloween .hi-pos  { color: #059669; }
.tearsheet-halloween .hi-neg  { color: #dc2626; }
.tearsheet-halloween .hi-flat { color: var(--ins-text-muted); }

body.dark-mode .tearsheet-halloween .hi-pos  { color: #34d399; }
body.dark-mode .tearsheet-halloween .hi-neg  { color: #fb7185; }

/* Inline wrapper keeps ⓘ glued to the end of the sentence so the
   tooltip can anchor relative to the icon, not the whole line. */
.tearsheet-halloween .hi-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  vertical-align: middle;
}

.tearsheet-halloween .hi-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ins-text-faint);
  cursor: help;
  border-radius: 50%;
  opacity: 0.85;
  transition: opacity 0.16s ease, color 0.16s ease;
}

.tearsheet-halloween .hi-info:hover,
.tearsheet-halloween .hi-info:focus,
.tearsheet-halloween .hi-info:focus-visible {
  opacity: 1;
  color: var(--ins-text);
  outline: none;
}

.tearsheet-halloween .hi-info:focus-visible {
  box-shadow: 0 0 0 2px rgba(99, 91, 255, 0.25);
}

/* Halloween tooltip itself is now rendered by the shared smart-tooltip
   primitive (js/components/smartTooltip.js). The CSS for it lives in that
   module's injected stylesheet and uses position:fixed + JS clamping, which
   solves the prior right-anchor-vs-translateX-50% bug. The trigger styles
   above (.hi-info / .hi-tip-wrap) stay because they target the in-line
   button that anchors the tooltip. */

/* Tablet and below: allow line to wrap so it never overflows the table.
   Above this breakpoint the table is wide enough for a single line. */
@media (max-width: 1100px) {
  .tearsheet-halloween {
    white-space: normal;
  }
}

/* Mobile: keep small */
@media (max-width: 640px) {
  .tearsheet-halloween {
    font-size: 11px;
    padding: 9px 12px 0;
    margin-top: 12px;
    line-height: 1.6;
  }
}

@media print {
  .tearsheet-halloween .hi-info { display: none; }
}

/* Legend */
.tearsheet-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--ins-rule);
}

.tearsheet-legend .legend-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
}

.tearsheet-legend .legend-ramp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tearsheet-legend .legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 22px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ins-text-2);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.tearsheet-legend .legend-red-strong   { background: rgba(220,38,38,0.85); color:#fff; }
.tearsheet-legend .legend-red-light    { background: rgba(239,68,68,0.30); }
.tearsheet-legend .legend-zero         { background: transparent; border: 1px solid var(--ins-border); }
.tearsheet-legend .legend-green-light  { background: rgba(16,185,129,0.30); }
.tearsheet-legend .legend-green-strong { background: rgba(5,150,105,0.85); color:#fff; }

.tearsheet-legend .legend-note {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 300;
  letter-spacing: 0.01em;
  color: var(--ins-text-faint);
}

/* Empty state */
.monthly-tearsheet.empty {
  padding: 40px 0 20px;
  text-align: center;
}

.tearsheet-empty-msg {
  font-size: 12px;
  font-weight: 400;
  color: var(--ins-text-faint);
  letter-spacing: 0.005em;
}

/* Responsive — shrink cells on mobile but keep readable */
@media (max-width: 900px) {
  .tearsheet-header {
    grid-template-columns: 1fr;
    row-gap: 16px;
  }
  .tearsheet-stats {
    justify-content: flex-start;
    gap: 20px;
  }
  .tearsheet-stat { text-align: left; }
  .tearsheet-table .hm-cell,
  .tearsheet-table .hm-ytd-cell {
    padding: 6px 1px;
    font-size: 10px;
  }
}

@media (max-width: 600px) {
  .monthly-tearsheet { padding-left: 16px; padding-right: 16px; }
  /* Bleed the scroll container to the section edges so the table can scroll
     edge-to-edge without the gutter cropping the first/last cell */
  .tearsheet-scroll {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .tearsheet-table {
    min-width: 680px; /* force horizontal scroll rather than squishing */
  }
  /* Make first column (year) sticky so users keep their bearings while scrolling */
  .tearsheet-table th.hm-year-label,
  .tearsheet-table th.hm-year-label-avg {
    position: sticky;
    left: 0;
    background: var(--ins-bg, var(--ins-surface, #ffffff));
    z-index: 1;
  }
  body.dark-mode .tearsheet-table th.hm-year-label,
  body.dark-mode .tearsheet-table th.hm-year-label-avg {
    background: var(--mp-bg, #0f172a);
  }
}

/* =============================================================
   INCEPTION CELL — subtly desaturated + corner mark
   ============================================================= */
.tearsheet-table .hm-cell.is-inception {
  position: relative;
  filter: saturate(0.6);
  opacity: 0.84;
}

.tearsheet-table .hm-cell.is-inception::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

/* =============================================================
   INCEPTION BANNER — small, friendly note above the heatmap
   ============================================================= */
.tearsheet-banner {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 12px;
  font-size: 10px;
  color: var(--ins-text-faint);
  letter-spacing: 0.04em;
}

.tearsheet-inception-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px dashed var(--ins-border);
  border-radius: 999px;
  font-weight: 500;
  cursor: help;
}

.tearsheet-inception-note::before {
  content: '◐';
  font-size: 11px;
  opacity: 0.6;
}

/* =============================================================
   AVG-of-month annotation markers (★ best, ▾ worst)
   ============================================================= */
.tearsheet-table .hm-cell-avg.is-best,
.tearsheet-table .hm-cell-avg.is-worst {
  font-weight: 700;
  letter-spacing: -0.005em;
}

/* =============================================================
   YEAR markers — best year ★ / worst year ▾ on YTD column
   Symmetric with the AVG row's per-month markers. Subtle weight
   bump, no color override (the heat color already telegraphs the
   sign — adding a second color cue would feel busy).
   ============================================================= */
.tearsheet-table .hm-ytd-cell.is-best-year,
.tearsheet-table .hm-ytd-cell.is-worst-year {
  font-weight: 700;
  letter-spacing: -0.005em;
}

/* =============================================================
   CURRENT MONTH "you are here" indicator
   A subtle pulsing ring on whichever cell matches today's YYYY-MM,
   drawn via inset box-shadow so it never displaces layout. Animates
   gently — fast enough to notice on first scan, slow enough to
   never feel like a notification badge.
   ============================================================= */
.tearsheet-table .hm-cell.is-current,
.tearsheet-table .hm-cell.is-empty.is-current {
  position: relative;
  z-index: 1;
  animation: hm-current-pulse 2.4s ease-in-out infinite;
}

@keyframes hm-current-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1.5px rgba(99, 91, 255, 0.55),
      0 0 0 1px rgba(99, 91, 255, 0.0);
  }
  50% {
    box-shadow:
      inset 0 0 0 1.5px rgba(99, 91, 255, 0.95),
      0 0 0 3px rgba(99, 91, 255, 0.18);
  }
}

body.dark-mode .tearsheet-table .hm-cell.is-current,
body.dark-mode .tearsheet-table .hm-cell.is-empty.is-current {
  animation-name: hm-current-pulse-dark;
}

@keyframes hm-current-pulse-dark {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1.5px rgba(110, 127, 255, 0.55),
      0 0 0 1px rgba(110, 127, 255, 0.0);
  }
  50% {
    box-shadow:
      inset 0 0 0 1.5px rgba(110, 127, 255, 1),
      0 0 0 3px rgba(110, 127, 255, 0.22);
  }
}

/* Respect reduced-motion preference — drop the pulse, keep a static
   ring so the "you are here" cue still lands without animation. */
@media (prefers-reduced-motion: reduce) {
  .tearsheet-table .hm-cell.is-current,
  .tearsheet-table .hm-cell.is-empty.is-current {
    animation: none;
    box-shadow:
      inset 0 0 0 1.5px rgba(99, 91, 255, 0.7),
      0 0 0 2px rgba(99, 91, 255, 0.15);
  }
  body.dark-mode .tearsheet-table .hm-cell.is-current,
  body.dark-mode .tearsheet-table .hm-cell.is-empty.is-current {
    box-shadow:
      inset 0 0 0 1.5px rgba(110, 127, 255, 0.8),
      0 0 0 2px rgba(110, 127, 255, 0.2);
  }
}

/* =============================================================
   STAT STRIP (above the heatmap, below the header)
   Five compact stat cards: hot months, longest green/red, avg up/down, cagr vs arith
   ============================================================= */
.tearsheet-stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 4px 0 18px;
  padding: 14px 0;
  border-top: 1px solid var(--ins-rule);
  border-bottom: 1px solid var(--ins-rule);
}

.tss-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 18px;
  min-width: 0;
}

.tss-card + .tss-card {
  border-left: 1px solid var(--ins-rule);
}

.tss-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ins-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tss-value {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ins-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.tss-unit {
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ins-text-faint);
  text-transform: lowercase;
  margin-left: 2px;
}

.tss-divider {
  font-size: 11px;
  color: var(--ins-text-ghost);
  font-weight: 300;
  margin: 0 2px;
}

.tss-up    { color: #059669; }
.tss-down  { color: #dc2626; }
.tss-muted { color: var(--ins-text-muted); }

body.dark-mode .tss-up    { color: #34d399; }
body.dark-mode .tss-down  { color: #f87171; }

.tss-hint {
  font-size: 9.5px;
  font-weight: 400;
  color: var(--ins-text-faint);
  letter-spacing: 0.015em;
  line-height: 1.35;
}

@media (max-width: 1100px) {
  .tearsheet-stat-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 18px;
  }
  .tss-card:nth-child(3n+1) { border-left: 0; }
  .tss-card:nth-child(n+4) { border-top: 1px solid var(--ins-rule); padding-top: 14px; margin-top: 4px; }
}

@media (max-width: 700px) {
  .tearsheet-stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tss-card { padding: 0 12px; }
  .tss-card:nth-child(2n+1) { border-left: 0; }
  .tss-card:nth-child(n+3) { border-top: 1px solid var(--ins-rule); padding-top: 14px; margin-top: 4px; }
  .tss-value { font-size: 17px; }
}

/* =============================================================
   CELL TOOLTIP ANCHORS — make cells feel interactive
   ============================================================= */
.tearsheet-table [data-tearsheet-cell] {
  cursor: pointer;
  outline: none;
  position: relative;
}

.tearsheet-table [data-tearsheet-cell]:focus-visible {
  outline: 2px solid var(--ins-accent);
  outline-offset: -1px;
  z-index: 2;
}

.tearsheet-table [data-tearsheet-cell].is-tooltip-anchor {
  box-shadow: inset 0 0 0 1.5px var(--ins-accent);
}

.tearsheet-table [data-avg-cell] {
  cursor: pointer;
  outline: none;
}

.tearsheet-table [data-avg-cell]:focus-visible {
  outline: 2px solid var(--ins-accent);
  outline-offset: -1px;
}

/* =============================================================
   LEGEND — add export buttons + dark-mode swatches
   ============================================================= */
.tearsheet-legend .legend-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}

.tearsheet-legend .legend-action {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--ins-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ins-text-muted);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.tearsheet-legend .legend-action:hover {
  color: var(--ins-text);
  border-color: var(--ins-border-2);
  background: color-mix(in srgb, var(--ins-accent) 5%, transparent);
}

.tearsheet-legend .legend-action:focus-visible {
  outline: 2px solid var(--ins-accent);
  outline-offset: 2px;
}

/* Dark-mode legend swatches — restore visibility against dark bg */
body.dark-mode .tearsheet-legend .legend-red-strong   { background: rgba(248, 113, 113, 0.85); color:#0f172a; }
body.dark-mode .tearsheet-legend .legend-red-light    { background: rgba(248, 113, 113, 0.30); color: var(--ins-text); }
body.dark-mode .tearsheet-legend .legend-zero         { border-color: var(--ins-border-2); }
body.dark-mode .tearsheet-legend .legend-green-light  { background: rgba(52, 211, 153, 0.30); color: var(--ins-text); }
body.dark-mode .tearsheet-legend .legend-green-strong { background: rgba(52, 211, 153, 0.85); color:#0f172a; }

/* =============================================================
   RICH HOVER TOOLTIP — pinnable, theme-aware, keyboard-friendly
   ============================================================= */
.tearsheet-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9999;
  min-width: 280px;
  max-width: 360px;
  padding: 14px 16px 12px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 10px;
  box-shadow:
    0 20px 50px -12px rgba(15, 23, 42, 0.30),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11.5px;
  line-height: 1.45;
  color: #1a1a18;
  letter-spacing: 0.005em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.tearsheet-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tearsheet-tooltip.is-pinned {
  border-color: rgba(99, 91, 255, 0.40);
  box-shadow:
    0 20px 50px -12px rgba(15, 23, 42, 0.30),
    0 0 0 2px rgba(99, 91, 255, 0.20);
}

body.dark-mode .tearsheet-tooltip {
  background: rgba(30, 41, 59, 0.985);
  border-color: rgba(255, 255, 255, 0.14);
  color: #eef0f4;
  box-shadow:
    0 24px 56px -12px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.dark-mode .tearsheet-tooltip.is-pinned {
  border-color: rgba(110, 127, 255, 0.55);
  box-shadow:
    0 20px 50px -12px rgba(0, 0, 0, 0.60),
    0 0 0 2px rgba(110, 127, 255, 0.25);
}

/* Tooltip arrow */
.tearsheet-tooltip.tt-below::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: inherit;
  border-top: 1px solid rgba(15, 23, 42, 0.10);
  border-left: 1px solid rgba(15, 23, 42, 0.10);
  border-top-left-radius: 3px;
}

.tearsheet-tooltip.tt-above::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: inherit;
  border-bottom: 1px solid rgba(15, 23, 42, 0.10);
  border-right: 1px solid rgba(15, 23, 42, 0.10);
  border-bottom-right-radius: 3px;
}

body.dark-mode .tearsheet-tooltip.tt-below::before,
body.dark-mode .tearsheet-tooltip.tt-above::before {
  border-color: rgba(255, 255, 255, 0.10);
}

.tearsheet-tooltip .tt-head {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.dark-mode .tearsheet-tooltip .tt-head {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.tearsheet-tooltip .tt-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tearsheet-tooltip .tt-head-row + .tt-head-row {
  margin-top: 3px;
}

.tearsheet-tooltip .tt-head-month {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.62);
}

body.dark-mode .tearsheet-tooltip .tt-head-month {
  color: rgba(255, 255, 255, 0.62);
}

.tearsheet-tooltip .tt-head-return {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tearsheet-tooltip .tt-head-dollar {
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.tearsheet-tooltip .tt-up    { color: #059669; }
.tearsheet-tooltip .tt-down  { color: #dc2626; }
body.dark-mode .tearsheet-tooltip .tt-up    { color: #34d399; }
body.dark-mode .tearsheet-tooltip .tt-down  { color: #f87171; }

.tearsheet-tooltip .tt-pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 8px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.12);
  color: #635BFF;
  border: 1px solid rgba(99, 91, 255, 0.25);
  cursor: help;
}

body.dark-mode .tearsheet-tooltip .tt-pill {
  background: rgba(110, 127, 255, 0.18);
  color: #a3afff;
  border-color: rgba(110, 127, 255, 0.40);
}

.tearsheet-tooltip .tt-section {
  margin: 8px 0 0;
}

.tearsheet-tooltip .tt-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.52);
  margin-bottom: 6px;
}

body.dark-mode .tearsheet-tooltip .tt-section-label {
  color: rgba(255, 255, 255, 0.52);
}

.tearsheet-tooltip .tt-arrow {
  font-size: 9px;
  line-height: 1;
}

.tearsheet-tooltip .tt-section-gainers .tt-arrow { color: #059669; }
.tearsheet-tooltip .tt-section-losers .tt-arrow  { color: #dc2626; }
body.dark-mode .tearsheet-tooltip .tt-section-gainers .tt-arrow { color: #34d399; }
body.dark-mode .tearsheet-tooltip .tt-section-losers .tt-arrow  { color: #f87171; }

.tearsheet-tooltip .tt-mover-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tearsheet-tooltip .tt-mover {
  display: grid;
  /* id (flex) | weight-bar+label (60px) | pct (52px) | usd (62px) */
  grid-template-columns: minmax(0, 1fr) 60px 52px 62px;
  column-gap: 10px;
  align-items: center;
  padding: 5px 6px;
  margin: 0 -6px;
  border-radius: 5px;
  transition: background 0.15s ease;
}

.tearsheet-tooltip .tt-mover:hover {
  background: rgba(15, 23, 42, 0.04);
}

body.dark-mode .tearsheet-tooltip .tt-mover:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tearsheet-tooltip .tt-mover-id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tearsheet-tooltip .tt-mover-sym {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tearsheet-tooltip .tt-mover-name {
  font-size: 9.5px;
  font-weight: 400;
  color: rgba(15, 23, 42, 0.50);
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

body.dark-mode .tearsheet-tooltip .tt-mover-name {
  color: rgba(255, 255, 255, 0.50);
}

/* Inline weight rail + label — visual rhythm anchor for the mover row */
.tearsheet-tooltip .tt-mover-weight-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.tearsheet-tooltip .tt-mover-weight-bar {
  position: relative;
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
  min-width: 0;
}

body.dark-mode .tearsheet-tooltip .tt-mover-weight-bar {
  background: rgba(255, 255, 255, 0.10);
}

.tearsheet-tooltip .tt-mover-weight-bar > span {
  display: block;
  height: 100%;
  background: rgba(15, 23, 42, 0.32);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark-mode .tearsheet-tooltip .tt-mover-weight-bar > span {
  background: rgba(255, 255, 255, 0.40);
}

.tearsheet-tooltip [data-direction="up"] .tt-mover-weight-bar > span {
  background: rgba(5, 150, 105, 0.55);
}
.tearsheet-tooltip [data-direction="down"] .tt-mover-weight-bar > span {
  background: rgba(220, 38, 38, 0.55);
}
body.dark-mode .tearsheet-tooltip [data-direction="up"] .tt-mover-weight-bar > span {
  background: rgba(52, 211, 153, 0.65);
}
body.dark-mode .tearsheet-tooltip [data-direction="down"] .tt-mover-weight-bar > span {
  background: rgba(248, 113, 113, 0.65);
}

.tearsheet-tooltip .tt-mover-weight-label {
  flex: 0 0 auto;
  font-size: 9.5px;
  color: rgba(15, 23, 42, 0.50);
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

body.dark-mode .tearsheet-tooltip .tt-mover-weight-label {
  color: rgba(255, 255, 255, 0.55);
}

.tearsheet-tooltip .tt-pct {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tearsheet-tooltip .tt-pct-up    { color: #059669; }
.tearsheet-tooltip .tt-pct-down  { color: #dc2626; }
body.dark-mode .tearsheet-tooltip .tt-pct-up    { color: #34d399; }
body.dark-mode .tearsheet-tooltip .tt-pct-down  { color: #f87171; }

.tearsheet-tooltip .tt-usd {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tearsheet-tooltip .tt-usd-up    { color: #059669; }
.tearsheet-tooltip .tt-usd-down  { color: #dc2626; }
body.dark-mode .tearsheet-tooltip .tt-usd-up    { color: #34d399; }
body.dark-mode .tearsheet-tooltip .tt-usd-down  { color: #f87171; }

.tearsheet-tooltip .tt-foot {
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 9.5px;
  font-weight: 400;
  color: rgba(15, 23, 42, 0.55);
  letter-spacing: 0.01em;
}

body.dark-mode .tearsheet-tooltip .tt-foot {
  border-top-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
}

.tearsheet-tooltip .tt-foot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}

.tearsheet-tooltip .tt-foot-method {
  align-items: flex-start;
  font-size: 9.5px;
  color: rgba(15, 23, 42, 0.62);
}
body.dark-mode .tearsheet-tooltip .tt-foot-method {
  color: rgba(255, 255, 255, 0.62);
}
.tearsheet-tooltip .tt-foot-method strong {
  font-weight: 600;
  color: rgba(15, 23, 42, 0.80);
}
body.dark-mode .tearsheet-tooltip .tt-foot-method strong {
  color: rgba(255, 255, 255, 0.80);
}
.tearsheet-tooltip .tt-foot-method-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(99, 91, 255, 0.12);
  color: #635BFF;
  font-size: 9px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  margin-top: 1px;
}
body.dark-mode .tearsheet-tooltip .tt-foot-method-icon {
  background: rgba(110, 127, 255, 0.20);
  color: #a3afff;
}

.tearsheet-tooltip .tt-foot-meta-row {
  font-size: 9px;
  color: rgba(15, 23, 42, 0.45);
}
body.dark-mode .tearsheet-tooltip .tt-foot-meta-row {
  color: rgba(255, 255, 255, 0.45);
}

/* Dividend income line — only renders when material (≥5% of |P&L| or
   ≥0.05% of starting capital). Sits above the method line so users see
   "you also got paid X in dividends" before the method footnote. */
.tearsheet-tooltip .tt-foot-divs {
  align-items: center;
  font-size: 10px;
  color: rgba(15, 23, 42, 0.72);
  line-height: 1.45;
}
body.dark-mode .tearsheet-tooltip .tt-foot-divs {
  color: rgba(255, 255, 255, 0.72);
}
.tearsheet-tooltip .tt-foot-divs-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
body.dark-mode .tearsheet-tooltip .tt-foot-divs-icon {
  background: rgba(52, 211, 153, 0.22);
  color: #34d399;
}
.tearsheet-tooltip .tt-foot-divs-amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(4, 120, 87, 0.95);
}
body.dark-mode .tearsheet-tooltip .tt-foot-divs-amt {
  color: rgba(110, 231, 183, 0.96);
}

.tearsheet-tooltip .tt-foot-meta {
  font-weight: 400;
}

.tearsheet-tooltip .tt-foot-pin {
  white-space: nowrap;
  font-weight: 500;
  margin-left: auto;
}

.tearsheet-tooltip.is-pinned .tt-foot-pin::before {
  content: '📌 ';
  margin-right: 1px;
  font-size: 8.5px;
}

/* NET dollar pill in header — visually distinct from the % return */
.tearsheet-tooltip .tt-head-dollar {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}
body.dark-mode .tearsheet-tooltip .tt-head-dollar {
  background: rgba(255, 255, 255, 0.06);
}

/* Section count chip (e.g. "3" beside "Top gainers") */
.tearsheet-tooltip .tt-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: rgba(15, 23, 42, 0.55);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0;
  margin-left: auto;
}
body.dark-mode .tearsheet-tooltip .tt-section-count {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
}

/* YTD pill differentiated from INCEPTION */
.tearsheet-tooltip .tt-pill-ytd {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
  border-color: rgba(5, 150, 105, 0.30);
}
body.dark-mode .tearsheet-tooltip .tt-pill-ytd {
  background: rgba(52, 211, 153, 0.18);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.40);
}

.tearsheet-tooltip .tt-empty {
  font-size: 10.5px;
  color: rgba(15, 23, 42, 0.55);
  line-height: 1.55;
  padding: 4px 0 2px;
}

body.dark-mode .tearsheet-tooltip .tt-empty {
  color: rgba(255, 255, 255, 0.55);
}

.tearsheet-tooltip .tt-avg-note {
  font-size: 10.5px;
  color: rgba(15, 23, 42, 0.55);
  line-height: 1.55;
  padding: 2px 0 0;
}

body.dark-mode .tearsheet-tooltip .tt-avg-note {
  color: rgba(255, 255, 255, 0.55);
}

/* Mobile: switch tooltip to bottom-sheet style */
@media (max-width: 600px) {
  .tearsheet-tooltip {
    position: fixed !important;
    top: auto !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px;
    max-width: none;
    min-width: 0;
    width: auto;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }
  .tearsheet-tooltip.tt-above::before,
  .tearsheet-tooltip.tt-below::before { display: none; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .tearsheet-tooltip { transition: opacity 0.1s linear; transform: none !important; }
  .monthly-tearsheet { animation: none; }
}
