/* Series colors are the app's own hue family (the same ramp the lifecycle
   tokens are cut from), stepped to the chart-surface contrast band and checked
   for colorblind separation on every adjacent pair in both modes. */
.trend-view {
  --tv-s1: #2563eb;
  --tv-s2: #d97706;
  --tv-s3: #0d9488;
  --tv-s4: #7c3aed;
  --tv-s5: #db2777;
  --tv-intl: #60a5fa;
  --tv-dom: #1e40af;
  --tv-up: #2563eb;
  --tv-down: #dc2626;
  --tv-zero: #94a3b8;
  width: 100%; padding: 25px clamp(14px, 2.3vw, 34px) 40px; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .trend-view {
    --tv-s1: #3b82f6; --tv-s2: #d97706; --tv-s3: #0d9488; --tv-s4: #8b5cf6; --tv-s5: #ec4899;
    --tv-intl: #3b82f6; --tv-dom: #bfdbfe;
    --tv-up: #3b82f6; --tv-down: #ef4444; --tv-zero: #5c7a9a;
  }
}
:root[data-theme="dark"] .trend-view {
  --tv-s1: #3b82f6; --tv-s2: #d97706; --tv-s3: #0d9488; --tv-s4: #8b5cf6; --tv-s5: #ec4899;
  --tv-intl: #3b82f6; --tv-dom: #bfdbfe;
  --tv-up: #3b82f6; --tv-down: #ef4444; --tv-zero: #5c7a9a;
}
.trend-view *, .trend-view *::before, .trend-view *::after { box-sizing: border-box; }

.tv-top {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
}
.tv-header { min-width: 0; }
.tv-header h1 { margin: 0 0 8px; font-size: clamp(22px, 2vw, 29px); line-height: 1.3; letter-spacing: -.6px; }
.tv-header p { max-width: 640px; margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }

.tv-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--card);
}
.tv-range { display: flex; align-items: center; gap: 7px; }
.tv-range-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.tv-range-sep { color: var(--muted); font-size: 11px; }
.tv-select {
  min-height: 34px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--input-bg, var(--card)); color: var(--text); font-size: 12px;
}
.tv-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.tv-preset {
  min-height: 32px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--muted); font-size: 11px; font-weight: 650; cursor: pointer;
}
.tv-preset:hover { border-color: var(--accent); color: var(--accent); }
.tv-preset.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tv-scope { margin: 10px 0 22px; font-size: 11px; color: var(--muted); }
.tv-hero { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 12px; align-items: stretch; }
.tv-chart-card { display: flex; flex-direction: column; justify-content: center; }
.tv-tiles { display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.tv-tile {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center;
  padding: 12px 16px 12px 19px; border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.tv-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border); }
.tv-tile.is-total::before { background: var(--muted); }
.tv-tile.is-domestic::before { background: var(--tv-dom); }
.tv-tile.is-international::before { background: var(--tv-intl); }
.tv-tile.is-growth::before { background: var(--tv-s3); }
.tv-tile dt { margin: 0 0 5px; color: var(--muted); font-size: 10.5px; font-weight: 700; }
.tv-tile dd { margin: 0; font-size: 25px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.tv-tile-note { margin: 5px 0 0; font-size: 9.5px; line-height: 1.5; color: var(--muted); }
.tv-tile.is-up dd { color: var(--tv-up); }
.tv-tile.is-down dd { color: var(--tv-down); }

.tv-section { margin-bottom: 34px; }
.tv-section-head { margin-bottom: 12px; padding-left: 10px; border-left: 3px solid var(--accent); }
.tv-section-head h2 { margin: 0; font-size: 15px; font-weight: 750; }
.tv-section-head p { margin: 5px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--muted); }
.tv-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.tv-card {
  min-width: 0; display: flex; flex-direction: column;
  padding: 16px 17px 18px; border: 1px solid var(--border); border-radius: 13px; background: var(--card);
}
.tv-card h3 { margin: 0 0 4px; font-size: 12.5px; font-weight: 700; }
.tv-card-help { margin: 0 0 12px; font-size: 10.5px; line-height: 1.6; color: var(--muted); }
.tv-sub { margin: 16px 0 8px; font-size: 11px; font-weight: 700; color: var(--muted); }
.tv-axis-head {
  display: flex; align-items: center; gap: 7px; margin: 15px 0 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted);
}
.tv-axis-head:first-of-type { margin-top: 4px; }
.tv-axis-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.tv-axis-n {
  font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 999px;
  background: var(--hover-surface, var(--surface)); border: 1px solid var(--border);
}
.tv-sub:first-of-type { margin-top: 6px; }
.tv-empty { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }

.tv-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; font-size: 10.5px; color: var(--muted); }
.tv-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.tv-legend-dot { width: 10px; height: 10px; border-radius: 3px; }

.tv-bars, .tv-diverge { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tv-bar-row, .tv-diverge-row {
  display: grid; grid-template-columns: minmax(84px, 33%) minmax(0, 1fr) auto;
  align-items: center; gap: 9px; padding: 4px 6px; border-radius: 7px;
}
.tv-bars.is-ranked .tv-bar-row { grid-template-columns: 18px minmax(80px, 31%) minmax(0, 1fr) auto; }
.tv-bar-row:hover, .tv-diverge-row:hover { background: var(--hover-surface, var(--surface)); }
.tv-bar-rank {
  font-size: 10px; font-weight: 700; color: var(--muted); text-align: right;
  font-variant-numeric: tabular-nums; opacity: .7;
}
.tv-bar-rank.is-lead { opacity: 1; color: var(--text); }
.tv-bar-label {
  min-width: 0; display: flex; flex-direction: column; gap: 1px;
  font-size: 11px; line-height: 1.45; overflow-wrap: anywhere;
}
.tv-bar-sub { color: var(--muted); font-size: 9px; font-style: normal; }
.tv-bar-value { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv-bar-track { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.tv-bar-fill { display: block; height: 100%; border-radius: 999px; }

.tv-diverge-track { position: relative; height: 12px; border-radius: 999px; background: var(--border); }
.tv-diverge-zero { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--tv-zero); }
.tv-diverge-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.tv-diverge-fill.is-up { left: 50%; }
.tv-diverge-fill.is-down { right: 50%; }

.tv-chart { width: 100%; height: auto; display: block; }
.tv-grid { stroke: var(--border); stroke-width: 1; }
.tv-axis { fill: var(--muted); font-size: 10px; }
.tv-value { fill: var(--muted); font-size: 10px; font-weight: 650; }
.tv-bar-intl { fill: var(--tv-intl); }
.tv-bar-dom { fill: var(--tv-dom); }
.tv-hit { fill: transparent; }
.tv-hit:hover { fill: color-mix(in srgb, var(--accent) 7%, transparent); }

.tv-status { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 12.5px; }
.tv-status.is-error { color: var(--danger, #b42318); }

@media (max-width: 1160px) {
  .tv-hero { grid-template-columns: minmax(0, 1fr); }
  .tv-tiles { grid-template-rows: none; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tv-grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .tv-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .trend-view { padding: 18px 12px 30px; }
  .tv-top { align-items: stretch; }
  .tv-controls { width: 100%; }
  .tv-bar-row, .tv-diverge-row { grid-template-columns: minmax(70px, 40%) minmax(0, 1fr) auto; }
  .tv-bars.is-ranked .tv-bar-row { grid-template-columns: 16px minmax(66px, 38%) minmax(0, 1fr) auto; }
}
