MarcoCarola1 commited on
Commit
8d646b7
·
verified ·
1 Parent(s): a33aff4

atualizacao automatica dos dados da CVM

Browse files
Files changed (2) hide show
  1. app.js +207 -3
  2. styles.css +33 -0
app.js CHANGED
@@ -130,6 +130,9 @@ const ARQUIVOS = [
130
  'insights_blocos.parquet',
131
  'insights_linhas.parquet',
132
  'insights_linhas_priv.parquet',
 
 
 
133
  // DOCUMENTOS DOS FUNDOS NA CVM (`etl/documentos_cvm.py`): a lista de
134
  // documentos eventuais com link e a lamina. Publicos, como na CVM.
135
  'documentos_fundo.parquet',
@@ -166,6 +169,7 @@ const VAZIOS = {
166
  null::boolean vitrine, null::varchar gerado`,
167
  insights_linhas: `select null::varchar id, null::integer pos, null::varchar dados`,
168
  insights_linhas_priv: `select null::varchar id, null::integer pos, null::varchar dados`,
 
169
  documentos_fundo: `select null::varchar cnpj, null::varchar id_subclasse, null::date dt_comptc,
170
  null::date dt_receb, null::varchar tipo, null::varchar link,
171
  null::varchar auditoria`,
@@ -14723,6 +14727,9 @@ function celulaInsight(c, r) {
14723
  // E a prova da linha, e um paragrafo inteiro aberto na tabela a afogaria.
14724
  case 'trecho': return v
14725
  ? `<details class="reg-src"><summary>ler</summary><blockquote>${esc(v)}</blockquote></details>` : '—';
 
 
 
14726
  default: return esc(v ?? '—');
14727
  }
14728
  }
@@ -14891,8 +14898,12 @@ function halteresInsight(b, { agg = false, n = 0, links = false } = {}) {
14891
  const g = b._graf;
14892
  if (!g?.a || !g?.b) return '';
14893
  const ls = [];
14894
- if (agg) (g.agg || []).forEach(a => ls.push({ nome: a.t, a: a.a, b: a.b,
14895
  sub: a.n ? `${nf(a.n, 0)} fundos` : '' }));
 
 
 
 
14896
  if (n && !b._trancado) {
14897
  const rot = b._cols.find(c => c.k === g.rot);
14898
  b._linhas.slice(0, n).forEach(r => ls.push({ nome: cmpCurto(String(r[g.rot] ?? '')),
@@ -14916,7 +14927,7 @@ function halteresInsight(b, { agg = false, n = 0, links = false } = {}) {
14916
  <span class="ih-trilho"><i class="ih-zero" style="left:${x(0)}%"></i>${ref}
14917
  <i class="ih-seg" style="left:${Math.min(xa, xb)}%;width:${Math.abs(xa - xb).toFixed(2)}%"></i>
14918
  <b class="ih-a" style="left:${xa}%"></b><b class="ih-b" style="left:${xb}%"></b></span>
14919
- <span class="ih-v"><span class="ih-va">${pct(l.a, 0)}</span><span class="ih-seta">→</span><span class="ih-vb">${pct(l.b, 0)}</span></span>
14920
  </div>`;
14921
  }).join('')}
14922
  </div>`;
@@ -15059,6 +15070,136 @@ function fatosInsight(b, n) {
15059
  `<li><b>${esc(i.n)}</b><span>${esc(i.t)}</span></li>`).join('')}</ul>`;
15060
  }
15061
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15062
  /** O desenho do cartao, pelo tipo do grafico. */
15063
  function visualCartao(b) {
15064
  const t = b._graf?.tipo;
@@ -15143,7 +15284,7 @@ async function pageInsight(id) {
15143
  const sec = (t, corpo, extra = '') => corpo
15144
  ? `<section class="ins-sec"><h2 class="ins-h">${esc(t)}${extra}</h2>${corpo}</section>` : '';
15145
  if (g?.tipo === 'halteres') {
15146
- graf = sec('Somando todos os fundos', halteresInsight(b, { agg: true }))
15147
  + sec(g.t, halteresInsight(b, { n: N, links: true }),
15148
  b._linhas.length > N ? ` <span class="ins-h-s">· os ${N} com maior diferença</span>` : '');
15149
  } else if (g?.tipo === 'iceberg' && !b._trancado) {
@@ -15167,6 +15308,19 @@ async function pageInsight(id) {
15167
  } else if (g?.tipo === 'partes') {
15168
  graf = `<section class="ins-sec"><h2 class="ins-h">${esc(g.t)}</h2>${partesInsight(b)}</section>`;
15169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
15170
  const varios = Number(b.n_total) > Number(b.n_linhas);
15171
  const num = numeroInsight(b);
15172
  // Blocos que sairam da grade mas continuam no ar (23/11/2026): o "Veja tambem"
@@ -15192,6 +15346,8 @@ async function pageInsight(id) {
15192
  ${prox ? `<a class="dir" href="#/insights/${encodeURIComponent(prox.id)}"><span>próximo →</span>${esc(prox.titulo)}</a>` : '<span></span>'}
15193
  </nav>`;
15194
 
 
 
15195
  // A janela do iceberg (5 ou 10 anos) troca so o desenho; a tabela ja traz as duas.
15196
  const jan = app.querySelector('.ins-jan');
15197
  if (jan) {
@@ -15231,6 +15387,54 @@ async function pageInsight(id) {
15231
  }
15232
 
15233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15234
  // ------------------------------------------------------- titulos privados --
15235
  //
15236
  // A aba "Titulos privados" (17/11/2026). Le os marts do `etl/titulos_privados.py`:
 
130
  'insights_blocos.parquet',
131
  'insights_linhas.parquet',
132
  'insights_linhas_priv.parquet',
133
+ // As SERIES mes a mes dos blocos com grafico de linha por fundo (23/11/2026).
134
+ // Arquivo proprio para so a pagina do bloco baixar -- a grade nao precisa.
135
+ 'insights_series.parquet',
136
  // DOCUMENTOS DOS FUNDOS NA CVM (`etl/documentos_cvm.py`): a lista de
137
  // documentos eventuais com link e a lamina. Publicos, como na CVM.
138
  'documentos_fundo.parquet',
 
169
  null::boolean vitrine, null::varchar gerado`,
170
  insights_linhas: `select null::varchar id, null::integer pos, null::varchar dados`,
171
  insights_linhas_priv: `select null::varchar id, null::integer pos, null::varchar dados`,
172
+ insights_series: `select null::varchar id, null::integer pos, null::varchar serie`,
173
  documentos_fundo: `select null::varchar cnpj, null::varchar id_subclasse, null::date dt_comptc,
174
  null::date dt_receb, null::varchar tipo, null::varchar link,
175
  null::varchar auditoria`,
 
14727
  // E a prova da linha, e um paragrafo inteiro aberto na tabela a afogaria.
14728
  case 'trecho': return v
14729
  ? `<details class="reg-src"><summary>ler</summary><blockquote>${esc(v)}</blockquote></details>` : '—';
14730
+ // Linha com grafico proprio (23/11/2026): o botao leva o fundo ao grafico do topo.
14731
+ case 'ver_serie': return v == null ? ''
14732
+ : `<button type="button" class="ins-ver" data-sid="${esc(v)}">ver no gráfico</button>`;
14733
  default: return esc(v ?? '—');
14734
  }
14735
  }
 
14898
  const g = b._graf;
14899
  if (!g?.a || !g?.b) return '';
14900
  const ls = [];
14901
+ if (agg) (g.agg || []).forEach(a => ls.push({ nome: a.curto ? cmpCurto(a.t) : a.t, a: a.a, b: a.b,
14902
  sub: a.n ? `${nf(a.n, 0)} fundos` : '' }));
14903
+ // p.p. quando os dois pontos sao diferenca contra um indice (bloco de escala)
14904
+ const fv = g.unid === 'pp'
14905
+ ? v => `${v > 0 ? '+' : v < 0 ? '−' : ''}${nf(Math.abs(v) * 100, 1)} p.p.`
14906
+ : v => pct(v, 0);
14907
  if (n && !b._trancado) {
14908
  const rot = b._cols.find(c => c.k === g.rot);
14909
  b._linhas.slice(0, n).forEach(r => ls.push({ nome: cmpCurto(String(r[g.rot] ?? '')),
 
14927
  <span class="ih-trilho"><i class="ih-zero" style="left:${x(0)}%"></i>${ref}
14928
  <i class="ih-seg" style="left:${Math.min(xa, xb)}%;width:${Math.abs(xa - xb).toFixed(2)}%"></i>
14929
  <b class="ih-a" style="left:${xa}%"></b><b class="ih-b" style="left:${xb}%"></b></span>
14930
+ <span class="ih-v"><span class="ih-va">${fv(l.a)}</span><span class="ih-seta">→</span><span class="ih-vb">${fv(l.b)}</span></span>
14931
  </div>`;
14932
  }).join('')}
14933
  </div>`;
 
15070
  `<li><b>${esc(i.n)}</b><span>${esc(i.t)}</span></li>`).join('')}</ul>`;
15071
  }
15072
 
15073
+ // ---- GRAFICO DE LINHA POR FUNDO (23/11/2026) -------------------------------
15074
+ //
15075
+ // Pedido dele: "pra cada fundo um grafico de linha do retorno x o retorno
15076
+ // ponderado pelo capital [...] as pessoas que clicaram nesse insight sao
15077
+ // curiosas, elas querem mais detalhe e detalhe visual". Um grafico GRANDE
15078
+ // (echarts, com o mes a mes no tooltip) para o fundo escolhido e uma grade de
15079
+ // MINIATURAS (SVG) dos primeiros casos; a miniatura e o "ver no grafico" da
15080
+ // tabela levam o fundo para o grande. As series vem de `insights_series`, que
15081
+ // so esta pagina baixa.
15082
+
15083
+ const MES_CURTO = 'jan fev mar abr mai jun jul ago set out nov dez'.split(' ');
15084
+ function mesesSerie(s) {
15085
+ const [a, m] = s.ini.split('-').map(Number);
15086
+ return s.a.map((_, i) => {
15087
+ const k = a * 12 + m - 1 + i;
15088
+ return `${MES_CURTO[k % 12]}/${String(Math.floor(k / 12)).slice(2)}`;
15089
+ });
15090
+ }
15091
+ const pcSerie = v => (v == null ? '—' : `${v > 0 ? '+' : v < 0 ? '−' : ''}${nf(Math.abs(v) * 100, 0)}%`);
15092
+
15093
+ /** Formatos dos valores de uma serie: retorno acumulado, R$ (em mi) ou % do par. */
15094
+ function fmtSerie(s) {
15095
+ const fmt = s.fmt || 'ret';
15096
+ if (fmt === 'brl') return { v: v => brl(v * 1e6, { sinal: false }), eixo: v => brl(v * 1e6, { sinal: false, casas: 0 }) };
15097
+ if (fmt === 'par') return { v: v => (v == null ? '—' : `${nf(v * 100, 1)}% do par`), eixo: v => `${nf(v * 100, 0)}%` };
15098
+ return { v: pcSerie, eixo: v => `${nf(v * 100, 0)}%` };
15099
+ }
15100
+ const corB = s => ((s.kb || (s.tb ? 'idx' : 'b')) === 'idx' ? 'idx' : 'b');
15101
+
15102
+ /** Miniatura: as linhas, o patrimonio em area clara quando ha, a linha do mes em
15103
+ * que o fundo cresceu (bloco de escala) e a de referencia (zero, 80% do par). */
15104
+ function serieMini(s, r, cfg) {
15105
+ const W = 300, H = 104, top = 6, bot = H - 4, l = 2, rr = W - 2;
15106
+ const n = s.a.length;
15107
+ const vals = [...s.a, ...(s.b || [])].filter(v => v != null).concat(s.ref ? [s.ref.v] : [])
15108
+ .concat((s.fmt || 'ret') === 'ret' ? [0] : []);
15109
+ const lo = Math.min(...vals), hi = Math.max(...vals);
15110
+ const x = i => l + (i / Math.max(1, n - 1)) * (rr - l);
15111
+ const y = v => bot - (v - lo) / ((hi - lo) || 1) * (bot - top);
15112
+ const linha = arr => {
15113
+ let d = '', pen = false;
15114
+ arr.forEach((v, i) => {
15115
+ if (v == null) { pen = false; return; }
15116
+ d += `${pen ? 'L' : 'M'}${x(i).toFixed(1)},${y(v).toFixed(1)}`; pen = true;
15117
+ });
15118
+ return d;
15119
+ };
15120
+ let area = '';
15121
+ if (s.pl) {
15122
+ const plMax = Math.max(...s.pl) || 1;
15123
+ area = `<path d="M${x(0)},${bot} ${s.pl.map((v, i) =>
15124
+ `L${x(i).toFixed(1)},${(bot - Math.max(0, v) / plMax * (bot - top) * 0.6).toFixed(1)}`).join(' ')} L${x(n - 1)},${bot} Z" class="sm-pl"/>`;
15125
+ }
15126
+ const f = fmtSerie(s);
15127
+ const ta = s.ta || cfg.a || 'Fundo', tb = s.tb || cfg.b || '';
15128
+ const refV = s.ref ? s.ref.v : ((s.fmt || 'ret') === 'ret' ? 0 : null);
15129
+ const ref = refV == null ? '' : `<line x1="${l}" x2="${rr}" y1="${y(refV).toFixed(1)}" y2="${y(refV).toFixed(1)}" class="sm-zero"/>`;
15130
+ const marco = s.marco != null
15131
+ ? `<line x1="${x(s.marco).toFixed(1)}" x2="${x(s.marco).toFixed(1)}" y1="${top}" y2="${bot}" class="sm-marco"/>` : '';
15132
+ const kb = corB(s);
15133
+ const leg = `<span class="ih-va">${f.v(s.a[n - 1])}</span> ${esc(ta.toLowerCase())}`
15134
+ + (s.b ? ` · <span class="${kb === 'idx' ? 'sm-tidx' : 'ih-vb'}">${f.v(s.b[s.b.length - 1])}</span> ${esc(tb.toLowerCase())}` : '');
15135
+ const nome = String(r[cfg.rot || 'fundo'] ?? r.fundo ?? '');
15136
+ return `<button type="button" class="ins-mini" data-sid="${esc(r.sid)}" title="${esc(nome)}">
15137
+ <span class="im-nome">${esc(cfg.rot === 'codigo' ? nome : cmpCurto(nome))}</span>
15138
+ <span class="im-v">${leg}</span>
15139
+ <svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" aria-hidden="true">
15140
+ ${area}${ref}${marco}
15141
+ ${s.b ? `<path d="${linha(s.b)}" class="${kb === 'idx' ? 'sm-idx' : 'sm-b'}"/>` : ''}
15142
+ <path d="${linha(s.a)}" class="sm-a"/>
15143
+ </svg></button>`;
15144
+ }
15145
+
15146
+ /** O grafico grande: as linhas no eixo da esquerda, o patrimonio em barras no
15147
+ * da direita (quando ha), a linha de referencia e o mes a mes no tooltip. */
15148
+ function serieGrande(el, s, cfg) {
15149
+ const xs = s.x || mesesSerie(s);
15150
+ const kb = corB(s);
15151
+ const ta = s.ta || cfg.a || 'Fundo', tb = s.tb || cfg.b || '';
15152
+ const f = fmtSerie(s);
15153
+ const g = echarts.getInstanceByDom(el) || echarts.init(el, null, { renderer: 'canvas' });
15154
+ if (!el._ro) { el._ro = new ResizeObserver(() => g.resize()); el._ro.observe(el); }
15155
+ const eixoTxt = { color: TEMA.tinta3, fontSize: 10, fontFamily: TEMA.mono };
15156
+ const estreito = el.clientWidth < 560;
15157
+ const corBv = kb === 'idx' ? TEMA.tinta3 : '#BD8B30';
15158
+ const marcas = [];
15159
+ if (s.marco != null) marcas.push({ xAxis: xs[s.marco], lineStyle: { color: '#A8B972', type: 'dashed', width: 1.5 },
15160
+ label: { formatter: `${cfg.marco || ''} ${brl((s.pl?.[s.marco] ?? 0) * 1e6, { sinal: false })}`,
15161
+ color: '#A8B972', fontSize: 11, position: 'insideEndTop' } });
15162
+ if (s.ref) marcas.push({ yAxis: s.ref.v, lineStyle: { color: '#A8B972', type: 'dashed', width: 1.2 },
15163
+ label: { formatter: s.ref.t, color: '#A8B972', fontSize: 11, position: 'insideStartTop' } });
15164
+ const series = [];
15165
+ if (s.pl) series.push({ name: cfg.pl || 'Patrimônio', type: 'bar', yAxisIndex: 1, data: s.pl, barCategoryGap: '15%',
15166
+ itemStyle: { color: 'rgba(141,140,131,.22)' }, emphasis: { disabled: true } });
15167
+ if (s.b) series.push({ name: tb, type: 'line', data: s.b, showSymbol: false, connectNulls: false,
15168
+ lineStyle: kb === 'idx' ? { width: 1.6, color: corBv, type: 'dashed' } : { width: 2.4, color: corBv },
15169
+ itemStyle: { color: corBv } });
15170
+ series.push({ name: ta, type: 'line', data: s.a, showSymbol: false,
15171
+ lineStyle: { width: 2.4, color: '#5B8AC4' }, itemStyle: { color: '#5B8AC4' },
15172
+ markLine: marcas.length ? { symbol: 'none', silent: true, data: marcas } : undefined });
15173
+ g.setOption({
15174
+ backgroundColor: 'transparent',
15175
+ grid: { left: (s.fmt === 'brl' ? 64 : 50), right: s.pl ? 56 : 18, top: estreito ? 66 : 44, bottom: 28 },
15176
+ legend: { show: true, top: 0, left: 0, itemWidth: 16, itemHeight: 3, itemGap: 14, icon: 'rect',
15177
+ textStyle: { color: TEMA.tinta3, fontSize: 11 } },
15178
+ tooltip: {
15179
+ trigger: 'axis', backgroundColor: TEMA.branco, borderColor: TEMA.regua,
15180
+ textStyle: { color: TEMA.tinta, fontSize: 12 },
15181
+ formatter: ps => {
15182
+ const i = ps[0]?.dataIndex;
15183
+ if (i == null) return '';
15184
+ return `<b>${esc(xs[i])}</b>`
15185
+ + `<br><span style="color:#5B8AC4">●</span> ${esc(ta)}: <b>${f.v(s.a[i])}</b>`
15186
+ + (s.b ? `<br><span style="color:${corBv}">●</span> ${esc(tb)}: <b>${f.v(s.b[i])}</b>` : '')
15187
+ + (s.pl ? `<br><span style="color:${TEMA.tinta3}">${esc(cfg.pl || 'Patrimônio')}:</span> ${brl(s.pl[i] * 1e6, { sinal: false })}` : '')
15188
+ + (s.g ? `<br><span style="color:${TEMA.tinta3}">${esc(cfg.g || 'Ganho acumulado')}:</span> ${brl(s.g[i] * 1e6)}` : '');
15189
+ },
15190
+ },
15191
+ xAxis: { type: 'category', data: xs, boundaryGap: !!s.pl, axisTick: { show: false },
15192
+ axisLine: { lineStyle: { color: TEMA.regua } }, axisLabel: eixoTxt },
15193
+ yAxis: [
15194
+ { type: 'value', scale: s.fmt === 'par', splitLine: { lineStyle: { color: TEMA.reguaFina } },
15195
+ axisLabel: { ...eixoTxt, formatter: f.eixo } },
15196
+ { type: 'value', position: 'right', show: !!s.pl, splitLine: { show: false },
15197
+ axisLabel: { ...eixoTxt, formatter: v => brl(v * 1e6, { sinal: false, casas: 0 }) } },
15198
+ ],
15199
+ series,
15200
+ }, true);
15201
+ }
15202
+
15203
  /** O desenho do cartao, pelo tipo do grafico. */
15204
  function visualCartao(b) {
15205
  const t = b._graf?.tipo;
 
15284
  const sec = (t, corpo, extra = '') => corpo
15285
  ? `<section class="ins-sec"><h2 class="ins-h">${esc(t)}${extra}</h2>${corpo}</section>` : '';
15286
  if (g?.tipo === 'halteres') {
15287
+ graf = (g.agg_pag === false ? '' : sec('Somando todos os fundos', halteresInsight(b, { agg: true })))
15288
  + sec(g.t, halteresInsight(b, { n: N, links: true }),
15289
  b._linhas.length > N ? ` <span class="ins-h-s">· os ${N} com maior diferença</span>` : '');
15290
  } else if (g?.tipo === 'iceberg' && !b._trancado) {
 
15308
  } else if (g?.tipo === 'partes') {
15309
  graf = `<section class="ins-sec"><h2 class="ins-h">${esc(g.t)}</h2>${partesInsight(b)}</section>`;
15310
  }
15311
+ // FUNDO A FUNDO: o grafico de linha de cada caso (23/11/2026). O quadro nasce
15312
+ // vazio e as series chegam depois, do `insights_series`.
15313
+ if (g?.serie && !b._trancado) {
15314
+ const cab = g.serie.rot === 'codigo' ? 'Título a título' : g.serie.rot === 'gestora' ? 'Gestora a gestora' : 'Fundo a fundo';
15315
+ graf += `<section class="ins-sec ins-serie" id="insSerie">
15316
+ <h2 class="ins-h">${cab}</h2>
15317
+ ${g.serie.leitura ? `<p class="ins-nota-g ins-serie-leit">${esc(g.serie.leitura)}</p>` : ''}
15318
+ <div class="ins-serie-top"><select id="insSerieSel" aria-label="Fundo"></select>
15319
+ <span id="insSerieRes" class="ins-serie-res"></span></div>
15320
+ <div class="chart ins-serie-graf" id="insSerieGraf"></div>
15321
+ <div class="ins-minis" id="insMinis"><div class="loading"></div></div>
15322
+ </section>`;
15323
+ }
15324
  const varios = Number(b.n_total) > Number(b.n_linhas);
15325
  const num = numeroInsight(b);
15326
  // Blocos que sairam da grade mas continuam no ar (23/11/2026): o "Veja tambem"
 
15346
  ${prox ? `<a class="dir" href="#/insights/${encodeURIComponent(prox.id)}"><span>próximo →</span>${esc(prox.titulo)}</a>` : '<span></span>'}
15347
  </nav>`;
15348
 
15349
+ if (g?.serie && !b._trancado) ligaSeries(b, id);
15350
+
15351
  // A janela do iceberg (5 ou 10 anos) troca so o desenho; a tabela ja traz as duas.
15352
  const jan = app.querySelector('.ins-jan');
15353
  if (jan) {
 
15387
  }
15388
 
15389
 
15390
+ /** Liga o "Fundo a fundo": le as series do bloco (o `insights_series` inteiro,
15391
+ * ~200 KB, baixa uma vez por visita e so quando se abre um insight; a pagina
15392
+ * ja esta na tela e este quadro se preenche por ultimo), enche o seletor e as
15393
+ * miniaturas, e desenha o primeiro caso. A tabela ("ver no grafico") e as
15394
+ * miniaturas levam o caso ao grande. */
15395
+ async function ligaSeries(b, id) {
15396
+ const ep = _epoca;
15397
+ let rows = [];
15398
+ try {
15399
+ rows = await q(`select pos, serie from insights_series where id = '${String(id).replace(/'/g, "''")}' order by pos`);
15400
+ } catch (e) { console.warn('insights_series:', e.message); }
15401
+ const sec = document.getElementById('insSerie');
15402
+ if (ep !== _epoca || !sec) return;
15403
+ const porSid = new Map();
15404
+ for (const r of rows) { try { porSid.set(String(r.pos), JSON.parse(r.serie)); } catch { /* serie ilegivel fica fora */ } }
15405
+ const casos = b._linhas.filter(r => r.sid != null && porSid.has(String(r.sid)));
15406
+ if (!casos.length) { sec.remove(); return; }
15407
+ const cfg = b._graf.serie;
15408
+ const rot = r => String(r[cfg.rot || 'fundo'] ?? r.fundo ?? '');
15409
+ const curto = r => (cfg.rot === 'codigo' ? rot(r) : cmpCurto(rot(r)));
15410
+ const sel = document.getElementById('insSerieSel');
15411
+ sel.innerHTML = casos.map(r => `<option value="${esc(r.sid)}">${esc(curto(r))}</option>`).join('');
15412
+ const res = document.getElementById('insSerieRes');
15413
+ const graf = document.getElementById('insSerieGraf');
15414
+ const escolhe = (sid, rolar) => {
15415
+ const s = porSid.get(String(sid));
15416
+ if (!s) return;
15417
+ sel.value = String(sid);
15418
+ res.textContent = s.res || '';
15419
+ serieGrande(graf, s, cfg);
15420
+ document.querySelectorAll('#insMinis .ins-mini').forEach(m => m.classList.toggle('on', m.dataset.sid === String(sid)));
15421
+ if (rolar) sec.scrollIntoView({ behavior: 'smooth', block: 'start' });
15422
+ };
15423
+ document.getElementById('insMinis').innerHTML = casos.slice(0, 12)
15424
+ .map(r => serieMini(porSid.get(String(r.sid)), r, cfg)).join('');
15425
+ sel.addEventListener('change', () => escolhe(sel.value, false));
15426
+ document.getElementById('insMinis').addEventListener('click', ev => {
15427
+ const m = ev.target.closest('.ins-mini');
15428
+ if (m) escolhe(m.dataset.sid, true);
15429
+ });
15430
+ document.getElementById('insTabela')?.addEventListener('click', ev => {
15431
+ const bt = ev.target.closest('.ins-ver');
15432
+ if (bt) escolhe(bt.dataset.sid, true);
15433
+ });
15434
+ escolhe(casos[0].sid, false);
15435
+ }
15436
+
15437
+
15438
  // ------------------------------------------------------- titulos privados --
15439
  //
15440
  // A aba "Titulos privados" (17/11/2026). Le os marts do `etl/titulos_privados.py`:
styles.css CHANGED
@@ -2665,6 +2665,39 @@ td.col-trecho { white-space: normal; text-align: left; }
2665
  border-radius: 3px; font-size: 13.5px; }
2666
  .ins-sec .ins-fatos b { font-size: 24px; }
2667
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2668
  .ins-rel { display: grid; gap: 8px; max-width: 760px; }
2669
  .ins-rel a { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--regua); border-radius: 3px;
2670
  text-decoration: none; color: var(--tinta); }
 
2665
  border-radius: 3px; font-size: 13.5px; }
2666
  .ins-sec .ins-fatos b { font-size: 24px; }
2667
 
2668
+ /* FUNDO A FUNDO (23/11/2026): grafico grande + miniaturas. */
2669
+ .ins-serie-leit { margin: -.3rem 0 .7rem; }
2670
+ .ins-serie-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: .4rem; }
2671
+ .ins-serie-top select { font: inherit; font-size: 13.5px; max-width: 100%; padding: 5px 8px; color: var(--tinta);
2672
+ background: var(--papel-2); border: 1px solid var(--regua-forte); border-radius: 3px; }
2673
+ .ins-serie-res { font-size: 13px; color: var(--tinta-2); }
2674
+ .ins-serie-res b { font-family: var(--mono); font-weight: 600; }
2675
+ .ins-serie-graf { height: 360px; max-width: 1000px; }
2676
+ .ins-minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px;
2677
+ margin-top: 1rem; max-width: 1000px; }
2678
+ .ins-mini { display: grid; gap: 3px; padding: 9px 10px 6px; text-align: left; cursor: pointer; font: inherit;
2679
+ color: var(--tinta); background: var(--papel-2); border: 1px solid var(--regua-fina); border-radius: 3px; }
2680
+ .ins-mini:hover { border-color: var(--regua-forte); }
2681
+ .ins-mini.on { border-color: var(--acento); }
2682
+ .ins-mini svg { width: 100%; height: 78px; display: block; }
2683
+ .im-nome { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2684
+ .im-v { font-family: var(--mono); font-size: 11px; color: var(--tinta-3); }
2685
+ .sm-pl { fill: rgba(141, 140, 131, .16); }
2686
+ .sm-zero { stroke: var(--regua-forte); stroke-width: 1; vector-effect: non-scaling-stroke; }
2687
+ .sm-marco { stroke: var(--acento); stroke-width: 1.2; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
2688
+ .sm-a, .sm-b, .sm-idx { fill: none; stroke-width: 1.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
2689
+ .sm-a { stroke: var(--ins-parte-0); }
2690
+ .sm-b { stroke: var(--ins-parte-1); }
2691
+ .sm-idx { stroke: var(--tinta-3); stroke-dasharray: 4 3; stroke-width: 1.3; }
2692
+ .sm-tidx { color: var(--tinta-2); }
2693
+ .ins-ver { font: inherit; font-size: 12px; padding: 3px 8px; cursor: pointer; white-space: nowrap;
2694
+ color: var(--acento); background: none; border: 1px solid var(--regua-forte); border-radius: 3px; }
2695
+ .ins-ver:hover { border-color: var(--acento); }
2696
+ @media (max-width: 560px) {
2697
+ .ins-serie-graf { height: 290px; }
2698
+ .ins-minis .ins-mini:nth-child(n+7) { display: none; }
2699
+ }
2700
+
2701
  .ins-rel { display: grid; gap: 8px; max-width: 760px; }
2702
  .ins-rel a { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--regua); border-radius: 3px;
2703
  text-decoration: none; color: var(--tinta); }