/* /setores/ — modal da classe, desempenho e histórico enxuto (js/setores-painel.js) */

#dsp .up, .stm .up { color: var(--bullish, #3fb950); }
#dsp .down, .stm .down { color: var(--bearish, #f85149); }

/* ---------- barra: vira botão de modal ---------- */
.bar-item { cursor: pointer; }
.bar-item::after {
  content: '›'; font-size: 1.2rem; color: var(--text-muted); margin-left: 2px; line-height: 1;
}

/* ---------- MODAL ---------- */
html.stm-aberto { overflow: hidden; }
.stm-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(1, 4, 9, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .18s ease; backdrop-filter: blur(3px);
}
.stm-backdrop.on { opacity: 1; }
.stm-backdrop[hidden] { display: none; }
.stm {
  position: relative; width: 100%; max-width: 640px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg-secondary, #161b22); border: 1px solid var(--border-color, #30363d);
  border-radius: 16px; padding: 24px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  transform: translateY(12px); transition: transform .18s ease; overscroll-behavior: contain;
}
.stm-backdrop.on .stm { transform: none; }
.stm-fechar {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--bg-tertiary, #21262d); color: var(--text-secondary); font-size: 1.4rem;
  line-height: 1; cursor: pointer;
}
.stm-fechar:hover { color: var(--text-primary); }
.stm-topo { display: flex; gap: 14px; align-items: center; margin: 0 40px 18px 0; }
.stm-icone {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.6rem; background: color-mix(in srgb, var(--stm-cor) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--stm-cor) 45%, transparent);
}
.stm-topo h2 { font-size: 1.35rem; margin: 0 0 6px; color: var(--text-primary); }
.stm-selos { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stm-peso { font-weight: 800; font-size: 1.05rem; color: var(--text-primary); }
.stm-peso small { font-weight: 500; font-size: 0.75rem; color: var(--text-muted); }
.stm-visao {
  background: var(--bg-tertiary, #21262d); border-left: 3px solid var(--brand-yellow, #d6a42d);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
}
.stm h3 {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  font-weight: 700; margin: 0 0 6px;
}
.stm h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.stm p { font-size: 0.9rem; line-height: 1.55; color: var(--text-secondary); margin: 0; }
.stm-bloco { margin-bottom: 16px; }
.stm-grade { columns: 2; column-gap: 18px; }
.stm-grade .stm-bloco { break-inside: avoid; }
.stm-pesos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.stm-pesos li { display: flex; gap: 8px; align-items: baseline; font-size: 0.85rem; color: var(--text-secondary); }
.stm-pesos .stm-pd { min-width: 52px; color: var(--text-muted); font-size: 0.78rem; }
.stm-pesos b { color: var(--text-primary); min-width: 34px; }
.stm-pesos span.up, .stm-pesos span.down { font-size: 0.75rem; font-weight: 700; }
.stm-spark { width: 100%; height: 64px; display: block; margin: 4px 0 10px; }
.stm-spark-base { stroke: rgba(255, 255, 255, 0.18); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.stm-nums { display: flex; gap: 12px; }
.stm-nums > div {
  flex: 1; background: var(--bg-tertiary, #21262d); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.stm-nums span { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stm-nums b { font-size: 1.1rem; }
.stm-fora { font-size: 0.88rem; }
.stm-cta {
  display: block; text-align: center; margin-top: 4px; padding: 12px; border-radius: 12px;
  background: var(--brand-yellow, #d6a42d); color: #111; font-weight: 700; text-decoration: none;
}
.stm-cta:hover { filter: brightness(1.08); }

@media (max-width: 640px) {
  .stm-backdrop { align-items: flex-end; padding: 0; }
  .stm {
    max-height: 88vh; border-radius: 16px 16px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(40px);
  }
  .stm-grade { columns: 1; }
}

/* ---------- DESEMPENHO ---------- */
#dsp { cursor: default; }
#dsp.dsp-erro::after { content: '—'; color: var(--text-muted); }
.dsp-carregando { height: 420px; }
.dsp-hero { display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; margin-bottom: 16px; }
.dsp-v { display: flex; flex-direction: column; gap: 3px; }
.dsp-v span { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.dsp-v b { font-size: 1.7rem; font-weight: 800; color: var(--text-secondary); }
.dsp-v b.dsp-agora { color: var(--text-primary); }
.dsp-seta { font-size: 1.6rem; color: var(--brand-yellow, #d6a42d); font-weight: 700; }
.dsp-badge { font-size: 1.1rem; font-weight: 800; padding: 6px 14px; border-radius: 12px; }
.dsp-badge.up { background: rgba(63, 185, 80, 0.15); }
.dsp-badge.down { background: rgba(248, 81, 73, 0.15); }
.dsp-metricas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.dsp-m {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px;
  background: var(--bg-tertiary, #21262d);
}
.dsp-m span { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.dsp-m b { font-size: 1.05rem; font-weight: 700; }
.dsp-m small { font-size: 0.7rem; color: var(--text-muted); }
/* Rótulo que quebra em duas linhas ("Contra o Ibovespa") não desalinha os
   números da fileira: cada cartão ocupa 3 linhas da grade-mãe (subgrid). */
@supports (grid-template-rows: subgrid) {
  .dsp-m { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 2px; align-content: start; }
}
.dsp-veredito { font-size: 0.85rem; margin: 0 0 14px; font-weight: 600; }
.dsp-legenda { display: flex; align-items: center; gap: 10px 16px; font-size: 0.74rem; color: var(--text-muted); margin-bottom: 4px; flex-wrap: wrap; }
.dsp-legenda span::before { content: ''; display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 6px; }
.dsp-legenda .lg-cart::before { border-top: 3px solid var(--bullish, #3fb950); }
.dsp-legenda .lg-ref {
  font: inherit; color: var(--text-secondary); background: transparent; cursor: pointer;
  border: 1px solid var(--border-color, #30363d); border-radius: 999px; padding: 2px 10px;
}
.dsp-legenda .lg-ref::before { content: ''; display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid var(--c); }
.dsp-legenda .lg-cdi::before { border-top-style: dashed; }
.dsp-legenda .lg-ref[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
.dsp-legenda .lg-ref:hover { border-color: var(--c); }
.dsp-legenda .lg-reb::before { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-yellow, #d6a42d); }
.dsp-grafico { position: relative; width: 100%; touch-action: pan-y; margin-bottom: 18px; }
.dsp-grafico svg { display: block; overflow: visible; }
.g-grade { stroke: rgba(255, 255, 255, 0.06); }
.g-y { fill: var(--text-muted); font-size: 11px; text-anchor: end; }
.g-x { fill: var(--text-muted); font-size: 11px; text-anchor: middle; }
.g-base { stroke: rgba(255, 255, 255, 0.22); stroke-dasharray: 5 5; }
.g-ref { fill: none; stroke-width: 1.6; stroke-linejoin: round; opacity: 0.9; }
.g-cdi { stroke-dasharray: 5 4; }
.g-cart { fill: none; stroke-width: 2.6; stroke-linejoin: round; }
.g-reb { stroke: rgba(214, 164, 45, 0.45); stroke-dasharray: 2 4; }
.g-reb-p { fill: var(--brand-yellow, #d6a42d); stroke: var(--bg-secondary, #161b22); stroke-width: 2; }
.g-cursor line { stroke: rgba(255, 255, 255, 0.35); }
.g-c1 { fill: var(--text-primary, #fff); }
.dsp-tip {
  position: absolute; top: 4px; pointer-events: none; z-index: 2; min-width: 180px;
  background: rgba(13, 17, 23, 0.96); border: 1px solid var(--border-color, #30363d); border-radius: 12px;
  padding: 8px 10px; font-size: 0.78rem; color: var(--text-secondary); line-height: 1.6;
}
.dsp-tip b { color: var(--text-primary); }
.dsp-tip .t-d { font-weight: 700; color: var(--text-primary); }
.dsp-tip i { display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; }
.dsp-tip .t-cart { background: var(--bullish, #3fb950); }
.dsp-tip .t-reb { color: var(--brand-yellow, #d6a42d); font-weight: 600; margin-top: 2px; }
.dsp-sub {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  font-weight: 700; margin: 0 0 8px;
}
.dsp-sub2 { font-size: 0.78rem; color: var(--text-muted); margin: -4px 0 10px; }
.dsp-aloc-wrap { margin-bottom: 20px; }
.dsp-aloc { display: flex; gap: 4px; height: 150px; }
.dsp-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dsp-col-atual .dsp-col-in { outline: 2px solid var(--brand-yellow, #d6a42d); outline-offset: 1px; }
.dsp-col-atual .dsp-col-d { color: var(--text-primary); font-weight: 700; }
.dsp-col-in { flex: 1; display: flex; flex-direction: column; gap: 1px; border-radius: 8px; overflow: hidden; }
.dsp-col-in span {
  display: flex; align-items: center; justify-content: center; padding: 0 2px; min-height: 0; overflow: hidden; white-space: nowrap;
  font-size: 0.68rem; font-weight: 700; color: rgba(0, 0, 0, 0.78);
}
.dsp-col-d { text-align: center; font-size: 0.66rem; color: var(--text-muted); padding-top: 4px; white-space: nowrap; overflow: hidden; }
.dsp-aloc-leg { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; }
.dsp-aloc-leg button, .dsp-cr {
  background: none; border: 0; color: var(--text-secondary); font: inherit; cursor: pointer; padding: 0;
}
.dsp-aloc-leg button { font-size: 0.75rem; }
.dsp-aloc-leg button:hover { color: var(--text-primary); }
.dsp-aloc-leg i, .dsp-cn i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dsp-contrib-wrap { margin-bottom: 14px; }
.dsp-cr {
  display: grid; grid-template-columns: 96px 1fr 92px; gap: 10px; align-items: center;
  width: 100%; padding: 5px 6px; border-radius: 8px; text-align: left;
}
.dsp-cr:hover { background: var(--bg-tertiary, #21262d); }
.dsp-cn { font-size: 0.82rem; }
.dsp-cn sup { color: var(--text-muted); }
.dsp-ct { position: relative; height: 14px; background: var(--bg-tertiary, #21262d); border-radius: 4px; }
.dsp-ct::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255, 255, 255, 0.25); }
.dsp-cb { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.dsp-cb.pos { left: 50%; background: var(--bullish, #3fb950); }
.dsp-cb.neg { right: 50%; background: var(--bearish, #f85149); }
.dsp-cv { font-size: 0.82rem; font-weight: 700; text-align: right; }
.dsp-nota { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; }
.dsp-metodo { border-top: 1px solid var(--border-color, #30363d); padding-top: 10px; }
.dsp-metodo summary { cursor: pointer; font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; }
.dsp-metodo p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.55; margin: 8px 0 0; }
.dsp-metodo .dsp-atual { font-size: 0.72rem; }

@media (max-width: 640px) {
  .dsp-metricas { grid-template-columns: 1fr 1fr; }
  .dsp-v b { font-size: 1.35rem; }
  .dsp-seta { display: none; }
  .dsp-cr { grid-template-columns: 78px 1fr 80px; gap: 8px; }
  .dsp-aloc { height: 110px; }
}

/* ---------- HISTÓRICO enxuto ---------- */
.tl-enxuta .timeline-item { padding-bottom: 14px; }
.tl-enxuta .timeline-content h4 { margin-bottom: 4px; }
.tl-enxuta .tl-fechado .timeline-content p { display: none; }
.tl-enxuta .timeline-content p { margin: 6px 0 8px; }
.tl-ler {
  background: none; border: 0; padding: 0; margin: 0 0 6px; cursor: pointer; font: inherit;
  font-size: 0.75rem; color: var(--brand-yellow, #d6a42d); font-weight: 600;
}
.tl-ler::after { content: ' ▾'; }
.timeline-item:not(.tl-fechado) .tl-ler::after { content: ' ▴'; }
.tl-enxuta:not(.tl-tudo) .tl-antigo { display: none; }
.tl-mais {
  display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 12px; cursor: pointer;
  background: var(--bg-tertiary, #21262d); border: 1px solid var(--border-color, #30363d);
  color: var(--text-secondary); font: inherit; font-size: 0.85rem; font-weight: 600;
}
.tl-mais:hover { color: var(--text-primary); }
