/* ==========================================================================
   W·Invest — design system
   --------------------------------------------------------------------------
   Um arquivo para as quatro views. Antes cada HTML carregava sua própria cópia
   dos tokens e das correções de cascata; qualquer ajuste de cor precisava ser
   feito quatro vezes e as páginas divergiam na prática.

   Ordem de carga: Tailwind (CDN) → este arquivo. As utilities do Tailwind
   continuam vencendo em elementos que as usam; os componentes daqui (.card,
   .btn, .input…) definem propriedades que o markup não sobrescreve com
   utility, então não há disputa de especificidade.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  /* Superfícies: o branco puro do card se destaca do plano levemente quente
     da página — é o que dá profundidade sem precisar de sombra pesada. */
  --surface-1:       #ffffff;
  --surface-2:       #f2f2ef;   /* poços internos (dl, code, thead) */
  --surface-3:       #e9e9e4;   /* trilho de segmented control, hover de poço */
  --page-plane:      #f7f7f5;

  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #8a8880;

  --gridline:        #e5e4dd;
  --baseline:        #c3c2b7;
  --border-hairline: rgba(11, 11, 11, 0.09);
  --border-strong:   rgba(11, 11, 11, 0.18);

  /* Série única do slot 1 — a mesma cor responde por marca e acento. */
  --series-1:        #2a78d6;
  --accent:          #2a78d6;
  --accent-strong:   #1f63b8;
  --accent-ink:      #1c5fae;                 /* acento como TEXTO, em claro */
  --accent-soft:     rgba(42, 120, 214, 0.10);
  --accent-line:     rgba(42, 120, 214, 0.35);

  --success:         #0ca30c;
  --success-text:    #006300;
  --warning:         #fab219;
  --warning-text:    #8a5a00;
  --danger:          #d03b3b;
  --danger-text:     #b02a2a;

  --shadow-xs: 0 1px 2px rgba(16, 15, 12, .06);
  --shadow-sm: 0 1px 2px rgba(16, 15, 12, .04), 0 2px 6px -2px rgba(16, 15, 12, .07);
  --shadow-md: 0 4px 16px -6px rgba(16, 15, 12, .14), 0 1px 3px rgba(16, 15, 12, .05);
  --shadow-lg: 0 24px 48px -20px rgba(16, 15, 12, .26), 0 2px 8px rgba(16, 15, 12, .06);

  --radius-lg: 16px;
  --radius:    12px;
  --radius-sm: 9px;

  /* Brilho de fundo do topo: dois pontos de luz muito diluídos. Dá vida à
     página sem virar decoração competindo com os dados. */
  --aurora-1: rgba(42, 120, 214, .13);
  --aurora-2: rgba(12, 163, 12, .07);

  --ease:      cubic-bezier(.22, .61, .36, 1);
  --ease-out:  cubic-bezier(.16, 1, .3, 1);
  --header-h:  0px;
}

/* Dark é escolhido, não um flip automático: mesmos hues, steps próprios para a
   superfície escura. Declarado nos dois escopos — a media query cobre o ajuste
   do SO, o data-theme cobre o toggle e precisa vencer nos dois sentidos (o
   :not() deixa um stamp "light" ganhar do SO em dark). */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:       #191918;
    --surface-2:       #232321;
    --surface-3:       #2e2e2b;
    --page-plane:      #0d0d0c;
    --text-primary:    #ffffff;
    --text-secondary:  #c3c2b7;
    --text-muted:      #8f8d86;
    --gridline:        #2c2c2a;
    --baseline:        #383835;
    --border-hairline: rgba(255, 255, 255, 0.10);
    --border-strong:   rgba(255, 255, 255, 0.22);
    --series-1:        #3987e5;
    --accent:          #3987e5;
    --accent-strong:   #5c9df0;
    --accent-ink:      #7db3f2;
    --accent-soft:     rgba(57, 135, 229, 0.16);
    --accent-line:     rgba(57, 135, 229, 0.45);
    --success:         #0ca30c;
    --success-text:    #35c035;
    --warning:         #fab219;
    --warning-text:    #e7a520;
    --danger:          #d03b3b;
    --danger-text:     #ef6b6b;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .40);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .34), 0 2px 8px -2px rgba(0, 0, 0, .44);
    --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, .60), 0 1px 3px rgba(0, 0, 0, .40);
    --shadow-lg: 0 28px 56px -24px rgba(0, 0, 0, .80), 0 2px 10px rgba(0, 0, 0, .50);
    --aurora-1: rgba(57, 135, 229, .18);
    --aurora-2: rgba(12, 163, 12, .08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:       #191918;
  --surface-2:       #232321;
  --surface-3:       #2e2e2b;
  --page-plane:      #0d0d0c;
  --text-primary:    #ffffff;
  --text-secondary:  #c3c2b7;
  --text-muted:      #8f8d86;
  --gridline:        #2c2c2a;
  --baseline:        #383835;
  --border-hairline: rgba(255, 255, 255, 0.10);
  --border-strong:   rgba(255, 255, 255, 0.22);
  --series-1:        #3987e5;
  --accent:          #3987e5;
  --accent-strong:   #5c9df0;
  --accent-ink:      #7db3f2;
  --accent-soft:     rgba(57, 135, 229, 0.16);
  --accent-line:     rgba(57, 135, 229, 0.45);
  --success:         #0ca30c;
  --success-text:    #35c035;
  --warning:         #fab219;
  --warning-text:    #e7a520;
  --danger:          #d03b3b;
  --danger-text:     #ef6b6b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .34), 0 2px 8px -2px rgba(0, 0, 0, .44);
  --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, .60), 0 1px 3px rgba(0, 0, 0, .40);
  --shadow-lg: 0 28px 56px -24px rgba(0, 0, 0, .80), 0 2px 10px rgba(0, 0, 0, .50);
  --aurora-1: rgba(57, 135, 229, .18);
  --aurora-2: rgba(12, 163, 12, .08);
}

/* ── Base ───────────────────────────────────────────────────────────────── */

/* O preflight do Tailwind declara [hidden]{display:none} ANTES das utilities,
   então uma classe de display (flex, grid, block) vence por ordem e o elemento
   "escondido" aparece. Sem isto, banners de erro ficam visíveis e vazios. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--page-plane);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Luz de fundo fixa no topo. `fixed` em vez de um pseudo-elemento rolável:
   assim ela não estica o documento nem some ao descer a página. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 520px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(680px 300px at 12% -8%, var(--aurora-1), transparent 70%),
    radial-gradient(560px 260px at 88% -14%, var(--aurora-2), transparent 70%);
}
body > * { position: relative; z-index: 1; }

/* Cor e borda acompanham a troca de tema em vez de saltar. */
body, .card, .well, .input, .btn, .table td, .table th {
  transition: background-color .22s var(--ease), border-color .22s var(--ease),
              color .22s var(--ease);
}

::selection { background: var(--accent-soft); color: var(--text-primary); }

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Barra de rolagem discreta, coerente com o tema. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* Números em coluna alinham; o resto usa figuras proporcionais. */
.tnum { font-variant-numeric: tabular-nums; }

/* Scroll horizontal contido. `overflow-x:auto` sozinho não basta: o Chrome
   ainda soma o conteúdo transbordante ao scrollWidth do documento e a PÁGINA
   rola de lado no mobile. `contain: paint` corta a propagação sem afetar o
   sticky do header — que `overflow-x:hidden` no body quebraria. */
.scroll-x { overflow-x: auto; contain: paint; overscroll-behavior-x: contain; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface-1) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease),
              background-color .25s var(--ease);
}
/* Ao descolar do topo o header ganha limite e elevação — a hierarquia só
   aparece quando ela passa a ser necessária. */
.app-header.is-stuck {
  border-bottom-color: var(--border-hairline);
  box-shadow: var(--shadow-sm);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
}
/* Progresso de leitura + indicador de coleta, no mesmo trilho de 2px. */
.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
}
.topbar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transform-origin: left center;
  transition: width .1s linear, opacity .3s;
}
html.is-busy .topbar > i {
  width: 100% !important;
  animation: topbar-indeterminate 1.15s var(--ease) infinite;
}
@keyframes topbar-indeterminate {
  0%   { transform: translateX(-100%) scaleX(.35); }
  55%  { transform: translateX(0%)    scaleX(.55); }
  100% { transform: translateX(100%)  scaleX(.35); }
}

/* Marca */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text-primary);
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent-strong), var(--accent));
  box-shadow: 0 2px 8px -2px var(--accent-line), inset 0 1px 0 rgba(255,255,255,.28);
  flex: none;
}
.brand-dim { color: var(--text-muted); font-weight: 400; }
.brand-name { font-size: 14px; letter-spacing: -.015em; }

/* ── Sidebar e navegação ───────────────────────────────────────────────── */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: 224px;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface-1) 94%, var(--page-plane));
  border-right: 1px solid var(--border-hairline);
}

.sidebar-head {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.sidebar-toggle,
.sidebar-scrim {
  display: none;
}

.app-sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
}

.app-sidebar .nav::before {
  content: "NAVEGAÇÃO";
  padding: 0 10px 8px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .11em;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.nav-link:hover { color: var(--text-primary); background: var(--surface-2); }
.nav-link[aria-current="page"] {
  color: var(--accent-ink);
  font-weight: 550;
  background: var(--accent-soft);
}
.nav-link::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: .5;
  transition: transform .18s var(--ease), background-color .18s var(--ease),
              opacity .18s var(--ease);
}
.nav-link:hover::before { opacity: .8; }
.nav-link[aria-current="page"]::before {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.35);
}
.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  animation: nav-rail .3s var(--ease-out) both;
}
@keyframes nav-rail { from { transform: scaleY(0); opacity: 0 } }

@media (min-width: 768px) {
  body { padding-left: 224px; }
}

/* Em telas estreitas a marca vira uma app bar e a navegação continua lateral,
   agora como drawer. Assim o conteúdo não perde largura e as tabs não voltam. */
@media (max-width: 767px) {
  body { padding-top: 58px; }

  .app-sidebar {
    inset: 0;
    width: auto;
    height: auto;
    overflow: visible;
    border-right: 0;
    background: transparent;
    pointer-events: none;
  }

  .sidebar-head {
    position: relative;
    z-index: 43;
    min-height: 58px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border-hairline);
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    backdrop-filter: saturate(1.5) blur(14px);
    -webkit-backdrop-filter: saturate(1.5) blur(14px);
    pointer-events: auto;
  }

  .sidebar-toggle {
    position: relative;
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--border-hairline);
    border-radius: 9px;
    background: var(--surface-1);
    color: var(--text-secondary);
    cursor: pointer;
  }

  .sidebar-toggle-icon,
  .sidebar-toggle-icon::before,
  .sidebar-toggle-icon::after {
    display: block;
    width: 16px;
    height: 1.5px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .2s var(--ease), opacity .2s var(--ease);
  }
  .sidebar-toggle-icon { position: relative; }
  .sidebar-toggle-icon::before,
  .sidebar-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }
  .sidebar-toggle-icon::before { top: -5px; }
  .sidebar-toggle-icon::after { top: 5px; }

  .sidebar-open .sidebar-toggle-icon { background: transparent; }
  .sidebar-open .sidebar-toggle-icon::before { transform: translateY(5px) rotate(45deg); }
  .sidebar-open .sidebar-toggle-icon::after { transform: translateY(-5px) rotate(-45deg); }

  .app-sidebar .nav {
    position: fixed;
    inset: 58px auto 0 0;
    z-index: 42;
    width: min(82vw, 300px);
    padding: 20px 12px;
    overflow-y: auto;
    background: var(--surface-1);
    border-right: 1px solid var(--border-hairline);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .25s var(--ease-out), visibility .25s;
  }

  .sidebar-open .app-sidebar .nav {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 58px 0 0;
    z-index: 39;
    width: 100%;
    border: 0;
    background: rgba(0, 0, 0, .42);
    cursor: default;
  }

  .sidebar-open .sidebar-scrim { display: block; }
  .sidebar-open { overflow: hidden; }

  .app-header {
    top: 58px;
  }

  .app-header > div:not(.topbar) {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ── Botões ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s var(--ease), color .16s var(--ease),
              border-color .16s var(--ease), transform .16s var(--ease),
              box-shadow .16s var(--ease);
}
.btn:hover { background: var(--surface-2); color: var(--text-primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn > svg { flex: none; width: 15px; height: 15px; }

.btn-primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #fff;
  box-shadow: 0 1px 2px rgba(16,15,12,.14), 0 6px 16px -8px var(--accent-line);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 2px 4px rgba(16,15,12,.16), 0 10px 22px -10px var(--accent-line);
}
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--surface-2); }

.btn-icon { width: 34px; padding: 0; }
.btn-icon svg { width: 15px; height: 15px; }

.btn-sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }

/* Ícone de recarga gira enquanto a página está ocupada. */
html.is-busy .spin-when-busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Segmented control ──────────────────────────────────────────────────── */

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-hairline);
}
.seg > button {
  padding: 4px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color .16s var(--ease), background-color .16s var(--ease),
              box-shadow .16s var(--ease);
}
.seg > button:hover { color: var(--text-primary); }
.seg > button:disabled { opacity: .45; cursor: not-allowed; }
.seg > button:disabled:hover { color: var(--text-secondary); }
.seg > button[aria-pressed="true"] {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--border-hairline);
}

/* ── Campos ─────────────────────────────────────────────────────────────── */

/* `.input.input` (e não `.input`) de propósito: o plugin `forms` do Tailwind
   estiliza `[type='text']`, `[type='date']`… com a MESMA especificidade de uma
   classe e é injetado pelo CDN depois deste arquivo — na disputa por empate ele
   venceria e devolveria os campos ao visual padrão. Dobrar a classe resolve sem
   `!important`, e as utilities aplicadas no markup continuam vencendo. */
.input.input {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease),
              background-color .16s var(--ease);
}
.input.input::placeholder { color: var(--text-muted); opacity: 1; }
.input.input:hover { border-color: var(--border-strong); }
.input.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Modificadores de campo moram aqui, e não em utilities do Tailwind: `.input`
   precisa da especificidade dobrada para vencer o plugin `forms`, e por isso
   venceria também um `pl-8` ou `text-xs` aplicado no markup. */
.input.has-icon { padding-left: 30px; }
.input.input-sm  { height: 28px; font-size: 12px; padding: 0 6px; border-radius: 7px; }

.input-ticker.input-ticker {
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.input-ticker.input-ticker::placeholder {
  font-weight: 400; letter-spacing: normal; text-transform: none;
}
select.input.input { padding-right: 28px; }
textarea.input.input { height: auto; padding: 8px 10px; }

.label {
  display: flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .01em;
}

input[type="checkbox"].check.check {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  color: var(--accent);            /* o plugin pinta o marcado com currentColor */
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
/* Só o estado VAZIO recebe superfície própria: sobrescrever o fundo do marcado
   apagaria o próprio tique, que o plugin `forms` desenha como background. */
input[type="checkbox"].check.check:not(:checked) { background-color: var(--surface-1); }
input[type="checkbox"].check.check:hover:not(:checked) { border-color: var(--accent); }
input[type="checkbox"].check.check:focus { box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

/* ── Sugestões do campo de ativo ────────────────────────────────────────── */

/* A lista existe para o usuário não precisar saber a categoria de cor: cada
   sugestão vem rotulada como Ação ou FII. É o que resolve os 35 tickers cujo
   sufixo engana (KLBN11 é ação; ANCR11B é FII). */
.ac-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 268px;
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  box-shadow: var(--shadow-lg);
}
.ac-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.ac-item[aria-selected="true"], .ac-item:hover { background: var(--surface-2); }
.ac-item .ac-ticker {
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.ac-item .ac-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-muted);
}
.ac-kind {
  flex: none;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid var(--border-hairline);
  background: var(--surface-2);
  color: var(--text-secondary);
}
.ac-empty { padding: 10px; font-size: 12px; color: var(--text-muted); }

/* ── Superfícies ────────────────────────────────────────────────────────── */

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}
/* Cards de conteúdo sobem 1px no hover: confirma que a superfície é um objeto,
   sem animar nada que o usuário precise ler. */
.card-hover { transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Poço: bloco recuado dentro de um card (dl, resumo, código). */
.well {
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 12px;
}
/* Mesmo poço, marcado como RESULTADO — o número que os outros produzem. Sem
   isso, entrada e resultado ficam com o mesmo peso e a leitura vira uma lista. */
.well-accent {
  border-radius: var(--radius);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
  padding: 10px 12px;
}
.well-accent .well-label { color: var(--accent-ink); }

.hairline { border-color: var(--border-hairline); }

code.inline, .prose code {
  border-radius: 5px;
  background: var(--surface-2);
  padding: 1.5px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  color: var(--text-primary);
}

/* Texto explicativo — as views são densas em prosa curta. */
.prose { color: var(--text-secondary); font-size: 12px; line-height: 1.65; }
.prose strong { color: var(--text-primary); font-weight: 550; }

.context-details {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 48%, transparent);
}
.context-details summary {
  position: relative;
  min-height: 38px;
  padding: 10px 34px 10px 12px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  font-weight: 600;
}
.context-details summary::-webkit-details-marker { display: none; }
.context-details summary::after {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  content: "";
  transform: translateY(-70%) rotate(45deg);
  transition: transform .18s var(--ease);
}
.context-details[open] summary {
  border-bottom: 1px solid var(--border-hairline);
}
.context-details[open] summary::after {
  transform: translateY(-20%) rotate(225deg);
}
.context-details > .prose { padding: 11px 12px 12px; }
.context-details-edge {
  border-width: 1px 0 0;
  border-radius: 0;
  background: transparent;
}
.context-details-edge summary { padding-right: 38px; padding-left: 20px; }
.context-details-edge > .prose { padding-right: 20px; padding-left: 20px; }

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Número-herói: figuras alinhadas, tracking fechado. */
.display {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: .95;
  font-weight: 600;
}

/* ── Stat tile ──────────────────────────────────────────────────────────── */

.tile {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  padding: 11px 13px 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .22s var(--ease), transform .22s var(--ease),
              border-color .22s var(--ease);
}
.tile:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  border-color: var(--border-strong);
}
/* Filete de acento que cresce no hover — a única decoração da tile. */
.tile::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform .28s var(--ease-out);
}
.tile:hover::after { transform: scaleY(1); }
.tile-value {
  margin-top: 2px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.tile-label { display: flex; align-items: center; font-size: 11.5px; color: var(--text-muted); }
.tile-sub { margin-top: 2px; font-size: 11px; color: var(--text-muted); }

/* ── Badges e status ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge-ok      { color: var(--success-text); border-color: color-mix(in srgb, var(--success) 32%, transparent); background: color-mix(in srgb, var(--success) 9%, var(--surface-1)); }
.badge-warn    { color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 11%, var(--surface-1)); }
.badge-danger  { color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 34%, transparent);  background: color-mix(in srgb, var(--danger) 9%, var(--surface-1)); }
.badge-accent  { color: var(--accent-ink);   border-color: var(--accent-line); background: var(--accent-soft); }

/* Faixas de aviso: a cor é reforço, o ícone e o texto carregam o significado. */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius);
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  box-shadow: var(--shadow-xs);
  padding: 11px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.notice-danger { border-left: 3px solid var(--danger); }
.notice-warn   { border-left: 3px solid var(--warning); }
.notice-icon   { flex: none; margin-top: 1px; line-height: 1.3; }

/* ── Diálogos e feedback ───────────────────────────────────────────────── */

.action-dialog {
  width: min(92vw, 440px);
  max-width: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}
.action-dialog::backdrop {
  background: rgba(0, 0, 0, .48);
  backdrop-filter: blur(3px);
}
.action-dialog-panel { padding: 20px; }
.action-dialog-copy h2 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.015em;
}
.action-dialog-copy p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}
.action-dialog-field {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}
.action-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 88%, #000);
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  width: min(360px, calc(100vw - 28px));
  gap: 8px;
  pointer-events: none;
}
.toast {
  transform: translateY(8px);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  color: var(--text-secondary);
  padding: 11px 13px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.toast.is-visible { transform: none; opacity: 1; }
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error { border-left-color: var(--danger); }

@media (max-width: 639px) {
  .action-dialog-actions .btn { flex: 1; }
  .toast-region {
    right: 14px;
    bottom: 14px;
  }
}

/* ── Tabelas ────────────────────────────────────────────────────────────── */

/* A tabela rola com a PÁGINA — sem painel de altura própria e sem cabeçalho
   preso. Um `position: sticky` no thead exigiria um container de rolagem
   próprio, e a rolagem aninhada que isso cria é justamente o que atrapalha. */
.table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
.table thead th {
  background: var(--surface-1);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border-hairline);
}
.table th.th-group { height: 28px; padding-top: 0; padding-bottom: 0; }

.table tbody tr { transition: background-color .12s linear; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody td, .table tbody th { border-top: 1px solid var(--border-hairline); }
.table tbody tr:first-child td, .table tbody tr:first-child th { border-top: 0; }
.table th[data-key] { cursor: pointer; user-select: none; }
.table th[data-key]:hover { color: var(--text-primary); }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--text-primary); }

/* Coluna de identidade fixa na rolagem HORIZONTAL: numa tabela mais larga que a
   tela, rolar de lado deixava as linhas anônimas. É sticky só no eixo x, dentro
   do próprio `.scroll-x` — a rolagem vertical continua sendo a da página. */
.table .col-pin {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 116px;
  background: var(--surface-1);
}
.table thead .col-pin { z-index: 4; }
.table tfoot .col-pin { z-index: 3; }
.table tbody tr:hover .col-pin { background: var(--surface-2); }
.table .col-after-pin { padding-left: 16px; }
.table .col-pin-select {
  left: 0;
  width: 48px;
  min-width: 48px;
}
.table .col-pin-ticker {
  left: 48px;
  min-width: 104px;
}
.table .col-pin-select::after { display: none; }
/* Fio à direita, separando o que passa por baixo da coluna fixa. */
.table .col-pin::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 1px;
  background: var(--border-hairline);
}

/* ── Cabeçalho interno das páginas ─────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.page-head-copy {
  min-width: 0;
  max-width: 680px;
}
.page-head-subtitle { line-height: 1.5; }
.page-head-actions {
  display: flex;
  flex: none;
  gap: 8px;
}
.page-head-actions .page-head-theme { flex: none; }

/* ── Universo de ativos ────────────────────────────────────────────────── */

.universe-meta {
  max-width: 230px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.universe-controls {
  margin-bottom: 16px;
  padding: 16px 18px;
}
.universe-controls-head {
  display: flex;
  min-height: 45px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.universe-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--border-hairline);
}
.filter-chip {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--accent-line);
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.filter-chip:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.universe-controls-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}
.universe-count {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--border-hairline);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11px;
}
.universe-filter-panel {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-hairline);
}
.universe-filter-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.universe-filter-footer #filter-select { margin-left: auto; }
.universe-loading { margin-top: 16px; }
.universe-results { margin-top: 16px; }
.state-message {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.state-message .btn { flex: none; }
.universe-results-head {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--border-hairline);
}
.universe-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 34px 20px;
  text-align: center;
}
.universe-empty-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
}
.universe-empty h3 {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}
.universe-empty p {
  max-width: 390px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.55;
}
.universe-empty .btn { margin-top: 3px; }
.universe-selection-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.universe-results .table tbody td { height: 43px; }

/* ── Filtro de setor por chips ─────────────────────────────────────────── */

.universe-sector-filter {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.universe-sector-filter legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  padding: 0;
}
.universe-sector-count {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.universe-sector-count.is-active {
  color: var(--accent-ink);
  font-weight: 500;
}
.universe-sector-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* O marcado não se distingue só pela cor: ganha peso, borda mais firme e um
   traço à esquerda — legível em daltonismo e em impressão monocromática. */
.sector-chip {
  padding: 4px 10px;
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.sector-chip:hover { border-color: var(--border-strong); }
.sector-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.sector-chip[aria-pressed="true"] {
  border-color: var(--accent-line);
  border-left-width: 3px;
  padding-left: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Linha de escolha: rótulo à esquerda e o controle ao lado, com o mesmo ritmo
   dos blocos de Setor e Filtros salvos. */
.universe-choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 12px;
  padding: 0;
  border: 0;
}
.universe-choice-row legend {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  float: left;              /* legend só entra no flex do fieldset flutuando */
}
.universe-choice-row .seg { flex: none; }

/* ── Filtros salvos ────────────────────────────────────────────────────── */
/*
 * Mesma gramática visual dos chips de setor — é a mesma ideia de "escolha
 * visível" —, mas com duas ações no mesmo chip: aplicar (o nome) e excluir (o
 * ×). Por isso o wrapper é um <span> com dois <button> dentro, e não um botão
 * só: um botão dentro de outro é HTML inválido e o clique fica ambíguo.
 */
.universe-saved-filters {
  margin-top: 12px;
  padding: 0;
  border: 0;
}
.universe-saved-filters legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  padding: 0;
}

.saved-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  background: var(--surface-1);
  overflow: hidden;
  transition: border-color .12s var(--ease), background-color .12s var(--ease);
}
.saved-chip:hover { border-color: var(--border-strong); }
.saved-chip-apply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
}
.saved-chip-del {
  display: inline-flex;
  align-items: center;
  padding: 0 8px 0 4px;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color .12s var(--ease);
}
.saved-chip-del:hover { color: var(--danger); }
.saved-chip-apply:focus-visible, .saved-chip-del:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 999px;
}

/* Aplicado: mesmo tratamento do setor marcado — peso, borda firme e traço à
   esquerda, para não depender de cor. O realce cai sozinho quando os critérios
   deixam de bater com o preset. */
.saved-chip.is-applied {
  border-color: var(--accent-line);
  border-left-width: 3px;
  background: var(--accent-soft);
}
.saved-chip.is-applied .saved-chip-apply {
  color: var(--accent-ink);
  font-weight: 600;
  padding-left: 8px;
}
.saved-chip-cat {
  padding: 1px 5px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Tracejado: é uma ação de criar, não um filtro que existe. */
.saved-chip-add {
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color .12s var(--ease), color .12s var(--ease);
}
.saved-chip-add:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.saved-chip-add:disabled { opacity: .5; cursor: not-allowed; }

/* O × do chip de filtro aplicado só aparece no hover/foco: em repouso a lista
   precisa ser lida como estado, não como um punhado de botões. */
.filter-chip-x {
  margin-left: 5px;
  opacity: 0;
  transition: opacity .12s var(--ease);
}
.filter-chip:hover .filter-chip-x,
.filter-chip:focus-visible .filter-chip-x { opacity: .7; }
.filter-chip-clear {
  border-style: dashed;
  border-color: var(--border-strong);
  background: none;
  color: var(--text-secondary);
}
.filter-chip-clear:hover {
  border-color: var(--danger);
  background: none;
  color: var(--danger-text);
}

/* ── Leitura por setor ─────────────────────────────────────────────────── */

.universe-view-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 17px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--surface-2);
  font-size: 12.5px;
}
/* Cada controle viaja junto com o seu "?": quebrando a linha em celular, o
   ícone de ajuda não pode ficar órfão numa linha sozinha. */
.universe-view-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.universe-view-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  cursor: pointer;
}
.universe-view-note {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11.5px;
}
#reference-order[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Faixa do setor. O conteúdo gruda na borda esquerda para continuar legível
   enquanto a tabela rola na horizontal — as colunas fixas fazem o mesmo. */
.group-row > td {
  padding: 0;
  background: var(--surface-3);
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-hairline);
}
.universe-results .table tbody .group-row td { height: auto; }
.group-row-inner {
  position: sticky;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 9px;
  width: max-content;
  max-width: 100vw;
  padding: 7px 17px;
}
.group-name {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.group-count {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 11px;
}
.group-medians {
  color: var(--text-muted);
  font-size: 11.5px;
}

/* Alavancagem acima da mediana do setor: o número segue legível, o traço
   inferior é o que sinaliza — cor sozinha não carrega o significado. */
.debt-heavy {
  border-bottom: 1.5px solid var(--warning);
  padding-bottom: 1px;
}

/* Caixa líquido: o índice é negativo porque sobra caixa depois de quitar a
   dívida, e não porque falta lucro operacional. Os dois casos aparecem
   negativos na mesma coluna e significam o oposto — daí o traço, na mesma
   gramática do `.debt-heavy` acima. O leitor de tela recebe a distinção por
   texto, no `sr-only` da célula. */
.debt-cash {
  border-bottom: 1.5px solid var(--success);
  padding-bottom: 1px;
}

/* ── Apurado × calculado ───────────────────────────────────────────────────
   A distinção que o Walter pediu (W5b): ROE, P/VP e P/L vêm da fonte e podem
   ser conferidos na página dela; Retorno, Valorização e Ganho real são conta
   nossa a partir desses três.

   A marca é uma FAIXA de fundo na coluna, não a cor do texto: o número precisa
   seguir com o mesmo contraste dos outros, e cor de texto sozinha não carrega
   significado para quem não a distingue. A legenda abaixo da tabela nomeia as
   duas famílias em palavras. */
.col-calc {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
thead .col-calc {
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Derivado: a fonte não publica o número, ele foi reconstruído dos que ela
   publica. Sublinhado pontilhado — a convenção de "há uma explicação aqui" —
   com o porquê no title. */
.valor-derivado {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
}

.source-impact-legend {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.source-impact-legend .legend-apurado,
.source-impact-legend .legend-calc {
  color: var(--text-secondary);
  font-weight: 500;
}
.source-impact-legend .legend-calc {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 3px;
  padding: 0 3px;
}

/* ── A raiz da divergência entre fontes ────────────────────────────────────
   Uma frase no lugar de sete linhas de tabela. Aparece só quando dois
   indicadores independentes apontam o mesmo insumo — ver `core/divergence.py`. */
.source-root {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  font-size: 12.5px;
  line-height: 1.55;
}
.source-root-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.source-root-head span { color: var(--accent); font-size: 10px; }
.source-root p { margin: 0; color: var(--text-secondary); }
.source-root em { font-style: normal; font-weight: 500; color: var(--text-primary); }
.source-root-note {
  margin-top: 6px !important;
  font-size: 11px;
  color: var(--text-muted) !important;
}

/* ── Grade de rentabilidade do card ────────────────────────────────────────
   Dois cortes independentes sobre o mesmo retorno — com e sem inflação, com e
   sem imposto —, e por isso uma GRADE e não quatro números soltos: a leitura
   que importa é comparar célula com célula, na horizontal e na vertical.

   O canto de baixo à direita é o único comparável entre alternativas de
   investimento, e é o que vem em corpo maior. */
.portfolio-proj {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
  table-layout: fixed;
}
.portfolio-proj th,
.portfolio-proj td {
  padding: 5px 0;
  text-align: right;
  font-size: 12.5px;
}
/* A tabela sangra de borda a borda de propósito — é o que mantém a régua do
   <thead> alinhada com as divisórias dos blocos vizinhos. O que não pode sangrar
   é o TEXTO: o recuo vai nas células das pontas, não na tabela. */
.portfolio-proj th:first-child,
.portfolio-proj td:first-child { padding-left: var(--card-inset); }
.portfolio-proj th:last-child,
.portfolio-proj td:last-child { padding-right: var(--card-inset); }
/* A primeira coluna carrega o rótulo da lente e leva o que sobra; as três de
   número dividem o resto por igual, para os dígitos alinharem na vertical. */
.portfolio-proj thead th:first-child { width: 31%; }
.portfolio-proj thead th:not(:first-child) { width: 23%; }
.portfolio-proj thead th {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 4px;
}
.portfolio-proj thead th abbr { text-decoration: none; }
.portfolio-proj tbody th {
  text-align: left;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.portfolio-proj td {
  font-variant-numeric: tabular-nums;
  padding-left: 8px;
}
/* A última linha é a mais rigorosa das três; um filete acima dela separa "o que
   a fonte diz" de "o que sobra em poder de compra" sem precisar de cor. */
.portfolio-proj-final th,
.portfolio-proj-final td {
  padding-top: 7px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-proj-final td { font-weight: 600; }
/* Zero por construção: apagado, porque não é medida. */
.portfolio-proj .is-estrutural { color: var(--text-muted); font-weight: 400; }

/* Prende o `?` à última palavra da frase. Solto, ele cai sozinho na linha
   seguinte e lê como erro de digitação em vez de affordance. */
.nao-quebra { white-space: nowrap; }

/* O período real da mediana, quando ele é menor que o do rótulo da coluna. */
.payout-janela {
  margin-left: 3px;
  font-size: 9px;
  color: var(--text-muted);
  vertical-align: super;
}

.portfolio-proj-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 2px var(--card-inset) 6px;
}
.portfolio-proj-head > span {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.portfolio-proj-head > small { font-size: 10px; color: var(--text-muted); }

/* A conclusão: o único número do card que responde ao método de retirada. */
.portfolio-conclusao {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 9px var(--card-inset) 10px;
  border-top: 1px solid var(--border-hairline);
  background: color-mix(in srgb, var(--surface-2) 40%, transparent);
  font-size: 12px;
  color: var(--text-secondary);
}
.portfolio-conclusao small { display: block; font-size: 10.5px; color: var(--text-muted); }
.portfolio-conclusao strong { font-size: 19px; font-weight: 650; line-height: 1.15; white-space: nowrap; }
.portfolio-conclusao strong small {
  display: block; font-size: 11px; font-weight: 400; text-align: right;
}

/* Card muito estreito: os rótulos das lentes encurtam antes de a tabela
   espremer os números, porque é o número que se compara entre carteiras. */
@container (max-width: 330px) {
  .portfolio-proj th, .portfolio-proj td { font-size: 11.5px; }
  .portfolio-proj tbody th { font-size: 10.5px; }
  .portfolio-proj td { padding-left: 5px; }
}

/* O cenário que NÃO responde ao seletor de retirada, dito com essas palavras.
   Ele estava em destaque no topo do card e por isso o seletor parecia quebrado:
   um cenário sem retirada é imune ao método de retirada por construção. */
.portfolio-reinvest {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px var(--card-inset) 11px;
  border-top: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--text-secondary);
}
.portfolio-reinvest small {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}
.portfolio-reinvest strong {
  font-size: 14px;
  white-space: nowrap;
}
/* Card muito estreito (iPhone SE e afins, onde ele fica com ~288px): o rótulo
   e o número não cabem na mesma linha, e o que sobrava para a linha de baixo
   era só o `?` — sozinho, lendo como erro de digitação. Empilhar põe o número
   embaixo do rótulo inteiro, com o `?` onde ele pertence.

   O gatilho é a largura do CARD e não a da tela, pela mesma razão das métricas:
   numa tela de 901px o card cai para 308px sem a tela mudar de tamanho. */
@container (max-width: 310px) {
  .portfolio-reinvest {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}

/* ── Comparação de ativos ──────────────────────────────────────────────── */

.compare-controls {
  margin-bottom: 16px;
  padding: 16px 18px;
}
.compare-controls-head {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
}
.compare-form {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}
.compare-portfolio-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.compact-action-menu { position: relative; }
.compact-action-menu > summary {
  list-style: none;
  cursor: pointer;
}
.compact-action-menu > summary::-webkit-details-marker { display: none; }
.compact-action-menu[open] > summary {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.compact-action-menu-panel {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 24;
  display: grid;
  width: 190px;
  overflow: hidden;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-lg);
}
.compact-action-item {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text-secondary);
  text-align: left;
  font-size: 11.5px;
}
.compact-action-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.compact-action-item.is-danger { color: var(--danger-text); }
.compare-date { min-width: 148px; }
.compare-progress {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.compare-progress-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}
.compare-ticker-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 7px;
  margin-top: 10px;
}
.compare-ticker-status {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 43px;
  padding: 6px 9px;
  border: 1px solid var(--border-hairline);
  border-radius: 9px;
  background: var(--surface-2);
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.compare-ticker-status strong {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.compare-ticker-status small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-ticker-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 10px;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.compare-ticker-status.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.compare-ticker-status.is-active .compare-ticker-icon {
  border: 2px solid var(--accent-line);
  border-top-color: var(--accent);
  box-shadow: none;
  animation: spin .9s linear infinite;
}
.compare-ticker-status.is-done .compare-ticker-icon {
  color: var(--success-text);
  background: color-mix(in srgb, var(--success) 12%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 35%, transparent);
}
.compare-ticker-status.is-error .compare-ticker-icon {
  color: var(--danger-text);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface-1));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 34%, transparent);
}

/* ── Análise individual do ativo ───────────────────────────────────────── */

.asset-controls {
  margin-bottom: 20px;
  padding: 16px 18px;
}
.asset-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
}
.asset-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
  gap: 9px;
}
.asset-ticker-field { min-width: 0; }
.asset-shortcut {
  flex: none;
}
.asset-recents {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.asset-advanced {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-hairline);
}
.asset-advanced summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 12px;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  list-style: none;
}
.asset-advanced summary::-webkit-details-marker { display: none; }
.asset-advanced-summary {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-advanced-chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s var(--ease);
}
.asset-advanced[open] .asset-advanced-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}
.asset-advanced-body {
  display: grid;
  grid-template-columns: minmax(148px, 172px) minmax(0, 1fr);
  align-items: end;
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 9px;
  background: var(--surface-2);
}
.asset-advanced-body p {
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.55;
}
.asset-hero {
  position: relative;
  overflow: hidden;
}
.asset-hero::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}
.asset-source-bar {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 16px 9px 19px;
  border-bottom: 1px solid var(--border-hairline);
  background: color-mix(in srgb, var(--surface-2) 52%, transparent);
}
.asset-source-context {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}
.asset-source-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}
.asset-source-label {
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 650;
}
.asset-source-availability {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-source-switch { flex: 0 0 auto; }
.asset-source-switch button:disabled {
  cursor: not-allowed;
  opacity: .42;
}
.asset-hero-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, auto);
  align-items: center;
  gap: 28px;
  min-height: 156px;
  padding: 22px 24px 22px 27px;
}
.asset-identity { min-width: 0; }
.asset-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.asset-title-row #a-ticker {
  font-size: 32px;
  letter-spacing: -.035em;
}
.asset-price {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--border-hairline);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.asset-company {
  margin-top: 8px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}
.asset-data-status {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 9.5px;
  font-weight: 600;
}
.asset-meta {
  color: var(--text-muted);
  font-size: 10px;
}
.asset-context-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.asset-decision {
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-xs);
}
.asset-decision-head {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hairline);
}
.asset-decision-head h3 {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 650;
}
.asset-decision-head > span {
  color: var(--text-muted);
  font-size: 10.5px;
}
.asset-decision-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.asset-decision-item {
  display: grid;
  min-width: 0;
  grid-template-columns: 7px minmax(0, 1fr);
  gap: 9px;
  padding: 13px 16px 14px;
}
.asset-decision-item + .asset-decision-item {
  border-left: 1px solid var(--border-hairline);
}
.asset-decision-state {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}
.asset-decision-item.is-ok .asset-decision-state { background: var(--success); }
.asset-decision-item.is-warning .asset-decision-state { background: var(--warning); }
.asset-decision-item.is-danger .asset-decision-state { background: var(--danger); }
.asset-decision-item p {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.asset-decision-item strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}
.asset-decision-item small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.analysis-index {
  position: sticky;
  top: 10px;
  z-index: 18;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 6px;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.analysis-index a {
  display: inline-flex;
  min-height: 31px;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.analysis-index a:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.analysis-index a[aria-current="location"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.analysis-index a[aria-current="location"] span {
  background: var(--accent);
  color: #fff;
}
.analysis-index a span {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 9.5px;
}
/* Enquanto a faixa superior do mobile existe — ela vai até 767px, junto com o
   `body { padding-top: 58px }` — o índice precisa grudar ABAIXO dela. Esta
   regra vivia no bloco de 639px, e por isso de 640 a 767 o índice voltava a
   `top: 10px` e sumia sob a faixa: as seções ficavam invisíveis justamente na
   faixa de tablet estreito. */
@media (max-width: 767px) {
  .analysis-index { top: 66px; }
}
#t-cc, #t-dy, #t-po, #t-val, #t-reg, #t-src { scroll-margin-top: 66px; }

@media (max-width: 639px) {
  .asset-decision-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
  .asset-decision-grid { grid-template-columns: 1fr; }
  .asset-decision-item + .asset-decision-item {
    border-top: 1px solid var(--border-hairline);
    border-left: 0;
  }
  .analysis-index a { flex: 0 0 auto; }
  .state-message {
    align-items: flex-start;
    flex-direction: column;
  }
}
.asset-yield {
  min-width: 280px;
  padding-left: 28px;
  border-left: 1px solid var(--border-hairline);
  text-align: right;
}
.asset-yield-value {
  margin-top: 7px;
  font-size: 54px;
}
.asset-yield-note {
  margin-top: 9px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

/* ── Payout: gráfico e tabela são a mesma análise ──────────────────────── */

.payout-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}
.payout-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 14px;
}
.payout-control {
  display: grid;
  gap: 5px;
}
.payout-control-label {
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .04em;
}
.payout-description {
  margin-top: 13px;
  margin-bottom: 18px;
}
.payout-view {
  padding-top: 15px;
  border-top: 1px solid var(--border-hairline);
}
.payout-table-view {
  animation: fade-in .24s var(--ease-out) both;
}
.payout-table-view table { min-width: 620px; }
.payout-table-view .table th,
.payout-table-view .table td {
  padding-top: 10px;
  padding-bottom: 10px;
}
.payout-table-note {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ── Conferência de fontes ─────────────────────────────────────────────── */

.source-check {
  overflow: hidden;
  padding: 0;
}
.source-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-hairline);
}
.source-check-kicker {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.source-check-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.source-check-subtitle {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.5;
}
.source-overview {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: 11px;
  background: var(--surface-2);
}
.source-overview-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 5px;
  min-height: 45px;
  padding: 9px 12px 7px;
}
.source-overview-item + .source-overview-item {
  border-left: 1px solid var(--border-hairline);
}
.source-overview-item strong {
  font-size: 19px;
  line-height: 1;
}
.source-overview-item span {
  color: var(--text-muted);
  font-size: 10px;
}
.source-overview-item.is-ok strong { color: var(--success-text); }
.source-overview-item.is-warning strong { color: var(--warning-text); }
.source-overview-total {
  grid-column: 1 / -1;
  padding: 5px 12px 6px;
  border-top: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 9.5px;
  text-align: center;
}
.source-unavailable {
  margin: 18px 22px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--warning) 38%, var(--border-hairline));
  border-radius: 10px;
  background: color-mix(in srgb, var(--warning) 7%, var(--surface-2));
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.5;
}
.source-impact {
  margin: 18px 22px 0;
  padding: 16px;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  background: var(--surface-2);
}
.source-impact-head {
  display: grid;
  grid-template-columns: minmax(190px, .7fr) minmax(280px, 1.3fr);
  align-items: center;
  gap: 20px;
}
.source-impact-head h4,
.source-family-section-head h4 {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 650;
}
.source-verdict {
  padding-left: 14px;
  border-left: 2px solid var(--border-strong);
}
.source-verdict-ok { border-left-color: var(--success); }
.source-verdict-wide { border-left-color: var(--warning); }
.source-verdict-flip { border-left-color: var(--danger); }
.source-verdict-label {
  display: block;
  margin-bottom: 3px;
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 650;
}
.source-verdict-ok .source-verdict-label { color: var(--success-text); }
.source-verdict-wide .source-verdict-label { color: var(--warning-text); }
.source-verdict-flip .source-verdict-label { color: var(--danger-text); }
.source-verdict p {
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.45;
}
.source-impact-table {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border-hairline);
}
.source-impact-table table { min-width: 620px; }
.source-scope {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 10px;
}
.source-scope summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 550;
}
.source-scope p {
  max-width: 760px;
  margin-top: 6px;
  line-height: 1.5;
}
.source-family-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 22px 11px;
}
.source-family-section-head p {
  color: var(--text-muted);
  font-size: 10.5px;
}
.source-families {
  display: grid;
  gap: 8px;
  padding: 0 22px;
}
.source-family {
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  background: var(--surface-1);
}
.source-family.has-differences {
  border-left: 2px solid color-mix(in srgb, var(--warning) 70%, transparent);
}
.source-family summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 13px;
  cursor: pointer;
  transition: background-color .15s var(--ease);
}
.source-family summary:hover { background: var(--surface-2); }
.source-family[open] summary {
  border-bottom: 1px solid var(--border-hairline);
  background: color-mix(in srgb, var(--surface-2) 62%, transparent);
}
.source-family-name {
  font-size: 11.5px;
  font-weight: 600;
}
.source-family-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--border-hairline);
  border-radius: 99px;
  font-size: 9.5px;
  font-weight: 600;
  white-space: nowrap;
}
.source-family-status.is-ok {
  border-color: color-mix(in srgb, var(--success) 28%, var(--border-hairline));
  color: var(--success-text);
}
.source-family-status.is-warning {
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border-hairline));
  color: var(--warning-text);
}
.source-family-body {
  padding: 11px 13px 13px;
}
.source-family-body > p {
  max-width: 720px;
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}
.source-family-body table { min-width: 500px; }
.source-family-body th,
.source-family-body td {
  border-top: 1px solid var(--border-hairline);
}
.source-family-body thead th { border-top: 0; }
.source-metric-name { padding: 7px 12px 7px 0; }
.source-delta {
  padding: 7px 0 7px 12px;
  color: var(--text-muted);
  text-align: right;
}
.source-delta.is-diverging {
  color: var(--warning-text);
  font-weight: 600;
}
.source-method-note {
  margin: 17px 22px 20px;
  padding-top: 13px;
  border-top: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ── Carteiras ─────────────────────────────────────────────────────────── */

.portfolio-loading { margin-top: 12px; }
.portfolio-page { min-width: 0; }
#editor { scroll-margin-top: 76px; }
.portfolio-editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .portfolio-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portfolio-editor-grid > :first-child { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .portfolio-editor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portfolio-editor-grid > :first-child { grid-column: auto; }
}
.portfolio-method-bar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -10px 0 18px;
  padding: 10px 13px 10px 15px;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-1) 76%, transparent);
}
.portfolio-method-bar > div { min-width: 0; }
.portfolio-method-bar p {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}
.portfolio-method-bar small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-method-bar select {
  width: 210px;
  flex: none;
}

/* Premissas globais em uma única superfície. O resumo mantém a escolha
   visível quando o bloco está fechado; os controles só competem com as
   carteiras quando a pessoa decide ajustá-los. */
.portfolio-assumptions {
  margin: -10px 0 18px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-1) 76%, transparent);
}
.portfolio-assumptions > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  min-height: 56px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}
.portfolio-assumptions > summary::-webkit-details-marker { display: none; }
.portfolio-assumptions > summary:hover { background: var(--surface-2); }
.portfolio-assumptions > summary > span:first-child { min-width: 0; }
.portfolio-assumptions > summary strong {
  display: block;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 650;
}
.portfolio-assumptions > summary small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portfolio-assumptions-action {
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 600;
}
.portfolio-assumptions[open] .portfolio-assumptions-action { display: none; }
.portfolio-assumptions[open] > summary {
  border-bottom: 1px solid var(--border-hairline);
}
.portfolio-assumptions[open] .portfolio-detail-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}
.portfolio-assumptions-body {
  display: grid;
  gap: 0;
}
.portfolio-assumption {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}
.portfolio-assumption + .portfolio-assumption {
  border-top: 1px solid var(--border-hairline);
}
.portfolio-assumption > div { min-width: 0; }
.portfolio-assumption p {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}
.portfolio-assumption small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-assumption select { width: 190px; flex: none; }
@media (min-width: 900px) {
  .portfolio-assumptions-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portfolio-assumption + .portfolio-assumption {
    border-top: 0;
    border-left: 1px solid var(--border-hairline);
  }
  .portfolio-assumption { align-items: flex-start; flex-direction: column; }
  .portfolio-assumption select { width: 100%; }
}
.portfolio-empty-mark {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 24px;
  font-weight: 300;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.portfolio-section-head {
  display: flex;
  min-height: 44px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.portfolio-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.portfolio-overview-tools {
  display: flex;
  align-items: center;
  gap: 14px;
}
.portfolio-source-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
  white-space: nowrap;
}
/* Classe, e não `> span`. O seletor pegava qualquer span filho, e no dia em que
   a legenda ganhou um para o texto da idade, esse texto virou uma caixa de 6×6px
   com fundo verde — a frase inteira vazou por cima da linha ao lado. */
.portfolio-source-legend > .legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 11%, transparent);
}
.portfolio-source-legend small {
  color: var(--text-muted);
  font-size: inherit;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 14px;
}
.portfolio-card {
  /* Permite que o conteúdo interno se adapte à largura DO CARD, e não à da
     janela: o mesmo card mede 628px numa tela de 900px e 308px numa de 901px,
     quando a grade passa a duas colunas. */
  /* O recuo horizontal do card, num lugar só. Cada bloco definia o seu — 17px
     no cabeçalho, 16px nas métricas, ZERO na escada e na linha de reinvestimento
     —, e o resultado era o rótulo "Bruta" encostado na borda enquanto "Retorno
     esperado" logo abaixo respeitava 16px. Medido igual em 1440px, 768px e
     375px: não era um problema de largura, era de alinhamento. */
  --card-inset: 16px;

  container-type: inline-size;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease),
              transform .2s var(--ease);
}
.portfolio-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.portfolio-card.is-featured {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm), inset 0 2px 0 var(--accent);
}
.portfolio-card-head {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px var(--card-inset) 12px;
}
.portfolio-card-head > div { min-width: 0; }
.portfolio-featured-label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-ink);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.portfolio-status {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 550;
  white-space: nowrap;
}
.portfolio-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.portfolio-status.is-complete {
  color: var(--success-text);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}
.portfolio-status.is-warning {
  color: var(--warning-text);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
}

.is-positive { color: var(--success-text); }
.is-negative { color: var(--danger-text); }

.portfolio-metrics-source {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 16px 0;
  color: var(--text-muted);
  font-size: 9.5px;
}
.portfolio-metrics-source::after {
  height: 1px;
  flex: 1;
  background: var(--border-hairline);
  content: "";
}
.portfolio-metrics-source span {
  order: 2;
  color: var(--text-secondary);
  font-weight: 600;
}
.portfolio-metrics-source::after { order: 1; }
.portfolio-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 10px var(--card-inset) 0;
}
.portfolio-metrics > div {
  display: flex;
  min-width: 0;
  /* Valor colado no rodapé da célula. Os rótulos têm alturas diferentes — um
     cabe em uma linha, outro tem legenda embaixo —, e sem isto os três números
     ficavam em três alturas: 36px de desalinho em tela de 360px, 5px mesmo em
     1600px. A linha existe para ser lida na horizontal; desalinhada, não é. */
  flex-direction: column;
  justify-content: space-between;
  padding: 0 10px;
  border-left: 1px solid var(--border-hairline);
}
.portfolio-metrics > div:first-child {
  padding-left: 0;
  border-left: 0;
}

/* O gatilho é a largura do CARD, não a da tela.

   A primeira versão usava `@media (max-width: 520px)`, e errava nos dois
   sentidos: numa tela de 900px o card tem 628px e cabiam três colunas
   folgadas; numa de 901px, com duas colunas na grade, ele cai para 308px e as
   três métricas voltavam a espremer — mesma tela, um pixel de diferença,
   resultados opostos. Container query pergunta o que importa. */
@container (max-width: 420px) {
  .portfolio-metrics { grid-template-columns: 1fr; gap: 2px; }
  .portfolio-metrics > div {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-top: 1px solid var(--border-hairline);
    border-left: 0;
  }
  .portfolio-metrics > div:first-child { border-top: 0; }
  .portfolio-metrics dt { flex: 1; min-height: 0; }
  .portfolio-metrics dt small { width: auto; }
  .portfolio-metrics dd { margin-top: 0; white-space: nowrap; }
}
.portfolio-metrics > div:last-child { padding-right: 0; }
.portfolio-metrics dt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 5px;
  min-height: 28px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.25;
}
/* "só se vender": a natureza do número ao lado do rótulo, para a soma das três
   colunas não sugerir que as três chegam do mesmo jeito. */
.portfolio-metrics dt small {
  width: 100%;
  color: var(--text-muted);
  font-size: 9px;
  opacity: .85;
}
.portfolio-metrics dd {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 600;
}

.portfolio-money-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px var(--card-inset) 0;
  padding: 9px 10px;
  border: 1px solid var(--border-hairline);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.4;
}
.portfolio-money-prompt .btn { flex: none; }

.portfolio-allocation {
  margin: 16px var(--card-inset) 0;
  padding-top: 13px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-allocation-head {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-allocation-bar {
  display: flex;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-3);
}
.portfolio-allocation-segment {
  min-width: 2px;
  background: var(--accent);
  border-right: 1px solid color-mix(in srgb, var(--surface-1) 70%, transparent);
}
.portfolio-allocation-segment:nth-child(2n) { opacity: .72; }
.portfolio-allocation-segment:nth-child(3n) { opacity: .48; }
.portfolio-allocation-segment:nth-child(4n) { opacity: .32; }
/* ── Composição por classe e por setor ─────────────────────────────────────
   Mesmo vocabulário visual da barra de alocação por papel, trocando só o
   critério de agregação. A identidade de cada fatia é carregada pelo NOME na
   legenda; o tom serve para localizar, não para identificar — por isso variar
   opacidade do acento basta, e não é preciso introduzir uma escala categórica
   que teria de ser validada para daltonismo. */

.portfolio-mixes {
  display: flex;
  flex-direction: column;
  gap: 9px;
  /* Mesmo ritmo do bloco Alocação: 16px de respiro externo e 13px depois da
     divisória. Os dois blocos passam a formar uma sequência previsível. */
  margin: 16px 16px 0;
  padding-top: 13px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-mix-label {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.portfolio-mix-bar {
  display: flex;
  height: 8px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.portfolio-mix-seg {
  min-width: 3px;
  background: var(--accent);
  /* Separador opaco: com 70% de mistura as fatias se fundiam num degradê e a
     barra deixava de parecer dividida. */
  border-right: 2px solid var(--surface-1);
}
.portfolio-mix-seg:last-child { border-right: 0; }
/* Degraus largos de propósito: num quadrado de 7px, 1,00 contra 0,78 é o mesmo
   tom. A identidade vem do NOME ao lado; o tom só precisa deixar localizar a
   fatia na barra, e para isso os passos têm de ser visíveis. */
/* A rampa de tons é calculada no JS, pela quantidade de fatias — ver
   `barraComposicao`. Aqui ficou só o que não depende de quantas são. */
.portfolio-mix-legend {
  /* Grade, e não linha que quebra: com todas as fatias visíveis, o percentual
     de cada uma cai na mesma coluna e a lista pode ser lida na vertical. As
     colunas se acomodam à largura do card sem media query. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 3px 16px;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
}
.portfolio-mix-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
}
.portfolio-mix-item i {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}
/* "Petróleo. Gás e Biocombustíveis" tem 31 caracteres e, no celular, empurra a
   porcentagem para outra linha — justamente o número que importa. O nome trunca
   e o valor fica sempre visível; o nome inteiro continua no title e no
   aria-label da barra. */
.portfolio-mix-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portfolio-mix-item strong { color: var(--text-primary); font-weight: 600; }
.portfolio-mix-note {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
}
.portfolio-mix-note small { color: var(--text-muted); font-size: 10px; }

@media (max-width: 640px) {
  /* Uma fatia por linha: em 390px, duas lado a lado deixavam o nome com ~12
     caracteres úteis, e "Petróleo. Gás e Bi…" ao lado de "Financeiro e O…" não
     distingue nada. Empilhado, cada nome usa a largura que precisar. */
  .portfolio-mix-legend { grid-template-columns: 1fr; }
  .portfolio-mix-note {
    flex-wrap: wrap;
    row-gap: 1px;
  }
}

/* ── Simulador de renda ────────────────────────────────────────────────── */

.portfolio-amount-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.portfolio-amount-field > span {
  color: var(--text-muted);
  font-size: 12px;
}
.portfolio-amount-field input { width: 128px; text-align: right; }

.portfolio-income {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
}
.portfolio-income-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 500;
}
.portfolio-income-head strong { font-size: 12.5px; font-weight: 700; }
.portfolio-income dl {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 6px;
}
.portfolio-income dt {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 10.5px;
}
.portfolio-income dt small { color: var(--text-muted); font-size: 9.5px; }
.portfolio-income dd {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.portfolio-income-split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.portfolio-income-split dd {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
@media (max-width: 640px) {
  .portfolio-income-split { flex-direction: column; gap: 6px; }
}

/* ── Leitura do retorno ───────────────────────────────────────────────────
   Cada card começa pela conclusão. A memória de cálculo fica no disclosure,
   disponível para conferência sem dominar a primeira leitura. */
.portfolio-insight-card {
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  background: var(--surface-2);
}
.portfolio-insight-head {
  display: flex;
  min-height: 108px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
}
.portfolio-insight-head > div:first-child { min-width: 0; }
.portfolio-insight-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.portfolio-insight-head h4 {
  display: flex;
  align-items: center;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 650;
}
.portfolio-insight-head p {
  max-width: 290px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}
.portfolio-insight-result {
  flex: none;
  text-align: right;
}
.portfolio-insight-result > span {
  display: block;
  color: var(--text-muted);
  font-size: 9.5px;
}
.portfolio-insight-result strong {
  display: block;
  margin-top: 2px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.025em;
}
.portfolio-insight-result small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 9px;
}
.portfolio-breakdown {
  border-top: 1px solid var(--border-hairline);
}
.portfolio-breakdown > summary {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 550;
  list-style: none;
}
.portfolio-breakdown > summary::-webkit-details-marker { display: none; }
.portfolio-breakdown > summary:hover { background: color-mix(in srgb, var(--surface-3) 58%, transparent); }
.portfolio-breakdown > summary i {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s var(--ease);
}
.portfolio-breakdown[open] > summary i { transform: rotate(225deg); }
.portfolio-breakdown-body {
  padding: 4px 13px 12px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-breakdown-body dl { margin-top: 6px; }
.casc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 4px 14px;
  padding: 3px 0;
}
.casc-row dt {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
}
.casc-row dt small { color: var(--text-muted); font-size: 9.5px; }
.casc-row dd { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.casc-brl {
  min-width: 74px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
}
/* O que subtrai fica recuado e mais leve: a hierarquia visual repete a
   aritmética, então dá para ver que é dedução sem ler o sinal. */
.casc-minus dt { padding-left: 10px; }
.casc-minus dd { font-weight: 500; color: var(--text-secondary); }
.casc-sum, .casc-total {
  border-top: 1px solid var(--border-hairline);
  margin-top: 2px;
  padding-top: 5px;
}
.casc-total dd { font-size: 15px; font-weight: 700; }
.casc-total.is-negative dd { color: var(--danger); }

/* Em tela estreita a grade de três colunas espremeria o rótulo até quebrar em
   três linhas. Duas colunas, e os reais descem para junto do rótulo. */
@media (max-width: 480px) {
  .portfolio-insight-head { min-height: 0; }
  .casc-row { grid-template-columns: 1fr auto; }
  .casc-brl {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    text-align: left;
  }
}

/* Média, não pagamento: o tracejado distingue sem depender de cor e convida a
   passar o mouse, onde a conta está escrita. */
.portfolio-avg-cell {
  border-bottom: 1px dotted var(--border-strong);
  cursor: help;
}

.portfolio-income-note {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
}

@media (max-width: 640px) {
  /* Empilha para o valor não brigar com o rótulo em 390px. */
  .portfolio-income dl { flex-direction: column; gap: 6px; }
  .portfolio-income-head { flex-wrap: wrap; row-gap: 2px; }
  .portfolio-amount-field { width: 100%; }
  .portfolio-amount-field input { flex: 1; width: auto; }
}

/* Etiqueta de classe na composição de carteira mista. */
.portfolio-kind-tag {
  display: inline-block;
  padding: 0 5px;
  margin-right: 4px;
  border: 1px solid var(--border-hairline);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .02em;
  vertical-align: 1px;
}

.portfolio-tickers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 9.5px;
}
.portfolio-tickers-label {
  width: 100%;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.portfolio-tickers strong {
  color: var(--text-secondary);
  font-weight: 600;
}
.portfolio-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 16px 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-card-meta strong {
  color: var(--text-secondary);
  font-weight: 600;
}
.portfolio-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 15px;
  padding: 12px var(--card-inset);
  border-top: 1px solid var(--border-hairline);
  background: color-mix(in srgb, var(--surface-2) 44%, transparent);
}

.portfolio-details {
  display: grid;
  gap: 9px;
}
.portfolio-detail-card {
  scroll-margin-top: 80px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-xs);
}
.portfolio-detail-card summary {
  display: grid;
  /* Duas colunas: o nome e a seta. A do valor saiu junto com ele — o card
     logo acima já mostra o mesmo número, e repeti-lo na linha fechada
     gastava espaço para não dizer nada de novo. */
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  transition: background-color .16s var(--ease);
}
.portfolio-detail-card summary > div { min-width: 0; }
.portfolio-detail-card summary::-webkit-details-marker { display: none; }
.portfolio-detail-card summary:hover { background: var(--surface-2); }
.portfolio-detail-card[open] summary {
  border-bottom: 1px solid var(--border-hairline);
}
.portfolio-detail-card summary h3 {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portfolio-detail-card summary span {
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-detail-chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s var(--ease);
}
.portfolio-detail-card[open] .portfolio-detail-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}
.portfolio-holdings-mobile { display: none; }

/* O rodapé é o único lugar da tabela onde uma coluna SOMA. Ele fecha o bloco em
   vez de continuar a lista: fundo próprio, régua acima e nenhuma linha entre as
   células, para não ser lido como o vigésimo primeiro papel. */
.portfolio-holdings-total td,
.portfolio-holdings-total th {
  border-top: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}
/* A unidade não compete com o número: menor, apagada, e sempre à mesma
   distância — assim a coluna continua sendo lida como uma coluna de números. */
.portfolio-holdings-desktop small.un,
.portfolio-holdings-total small {
  margin-left: 2px;
  color: var(--text-muted);
  font-weight: 500;
}
.portfolio-holdings-total-mobile {
  padding: 11px 15px 13px;
  border-top: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.portfolio-holdings-total-mobile > span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}
/* Os mesmos pares rótulo/valor das fichas acima, na mesma grade de duas
   colunas: o total é a última ficha da lista, e não um rodapé de outra
   natureza. */
.portfolio-holdings-total-mobile dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 0;
  margin-top: 8px;
}
.portfolio-holdings-total-mobile dt {
  color: var(--text-muted);
  font-size: 9.5px;
}
.portfolio-holdings-total-mobile dd {
  margin-top: 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.portfolio-holdings-total-mobile dl div { padding: 0 9px; border-left: 1px solid var(--border-hairline); }
.portfolio-holdings-total-mobile dl div:nth-child(odd) { padding-left: 0; border-left: 0; }
.portfolio-holdings-total-mobile dl div:nth-child(even) { padding-right: 0; }

.portfolio-holding {
  padding: 13px 15px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-holding:first-child { border-top: 0; }
.portfolio-holding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.portfolio-holding-head p {
  max-width: 230px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Quatro medidas em duas linhas de duas, e não três mais uma órfã: a
   contribuição entrou como quarto campo e caía sozinha embaixo, com a régua da
   esquerda apontando para o vazio. Em 2×2 cada linha fecha. */
.portfolio-holding dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px 0;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-holding dl div {
  min-width: 0;
  padding: 0 9px;
  border-left: 1px solid var(--border-hairline);
}
/* A régua separa COLUNA, então quem abre a linha não leva régua — em 2×2 isso
   é o primeiro e o terceiro, não só o primeiro. */
.portfolio-holding dl div:nth-child(odd) { padding-left: 0; border-left: 0; }
.portfolio-holding dl div:nth-child(even) { padding-right: 0; }
.portfolio-holding dt {
  color: var(--text-muted);
  font-size: 9.5px;
}
.portfolio-holding dd {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
}

/* O cabeçalho da seção empilha a partir de 640px, e NÃO de 768px.

   A regra morava dentro do bloco de 768–1099px, e entre 640px e 767px não
   havia nada: `.portfolio-section-head` continuava sendo uma linha, com
   `white-space: nowrap` na legenda das fontes e no "Ordenar por". Os filhos não
   podiam encolher, a linha travava em 671px, e a PÁGINA INTEIRA passava a rolar
   na horizontal — 30px de estouro a 767px, 157px a 640px. Uma faixa de 128px de
   largura, bem no tamanho de tablet pequeno e celular deitado, sem cobertura.

   Fica num bloco só, com o limite de baixo colado no ponto onde o layout de
   coluna do celular assume (639px), para não sobrar vão de novo. */
@media (min-width: 640px) and (max-width: 1099px) {
  .portfolio-section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .portfolio-overview-tools {
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .portfolio-source-legend small { display: none; }
}

/* Com a sidebar aberta, tablets têm uma área útil menor que o viewport. */
@media (min-width: 768px) and (max-width: 1099px) {
  .portfolio-page .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 22px;
  }
  /* A barra desce para a própria linha, mas os botões NÃO esticam. Com
     `flex: 1` em 1024px, "Nova carteira" virava um botão de 348px — a ação
     mais larga da tela, e ela não é a mais importante. Esticar só faz sentido
     no celular, onde a largura é o alvo de toque; aqui sobra espaço. */
  .portfolio-page .page-head-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .portfolio-page .page-head-actions .page-head-theme { flex: 0 0 36px; }
  .portfolio-method-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: -4px;
  }
  .portfolio-method-bar select { width: 100%; }
  /* Uma coluna só até 900px. A regra antiga valia até 1099px, e o motivo
     escrito era que "com a sidebar, duas colunas deixavam cards mais estreitos
     do que no celular" — verdade quando o card tinha onze seções e 34 números.
     Agora ele tem quatro números, e a 1024px duas colunas dão 369px cada,
     MAIS que os 328px do celular. E a grade existe para comparar carteiras
     lado a lado: mantê-las empilhadas até 1100px adiava isso sem ganho. */
  .portfolio-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 901px) and (max-width: 1099px) {
  .portfolio-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  }
}

@media (max-width: 639px) {
  .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 22px;
  }
  .page-head-actions { width: 100%; }
  .page-head-actions .btn { flex: 1; }
  .page-head-actions .page-head-theme { flex: 0 0 36px; }
  .universe-controls { padding: 14px; }
  .universe-controls-head { align-items: flex-end; }
  .universe-meta, .universe-count { display: none; }
  .universe-filter-footer { align-items: stretch; }
  .universe-filter-footer #filter-select {
    width: 100%;
    margin-left: 0;
  }
  .universe-results-head {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }
  .universe-selection-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .universe-selection-actions #sel-count {
    flex-basis: 100%;
    min-height: 0;
  }
  .universe-selection-actions .btn { flex: 1; padding: 0 7px; }
  .universe-selection-actions.is-active {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 35;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-1) 96%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
  }
  .universe-selection-actions.is-active #sel-count {
    flex-basis: auto;
    min-width: 100%;
  }
  .has-universe-selection .universe-page { padding-bottom: 96px; }

  .compare-controls { padding: 14px; }
  .compare-portfolio-tools {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }
  .compare-portfolio-tools #pf-select {
    width: 100%;
    grid-column: 1 / -1;
  }
  .compare-portfolio-tools > .btn,
  .compare-portfolio-tools > .compact-action-menu,
  .compact-action-menu > summary {
    width: 100%;
  }
  .compare-form {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .compare-form > .compare-ticker-field {
    width: 100%;
    flex: 0 0 100%;
  }
  .compare-form > div:not(.compare-ticker-field) { flex: 1 1 140px; }
  .compare-date { width: 100%; min-width: 0; }
  .compare-form > .btn {
    align-self: flex-end;
    flex: 1 1 100px;
  }
  .compare-progress {
    padding-top: 13px;
  }
  .compare-ticker-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .asset-controls { padding: 14px; }
  .asset-form {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
  }
  .asset-ticker-field, .asset-scope-field { flex: 0 0 100%; }
  .asset-scope-field .seg { display: flex; width: 100%; }
  .asset-scope-field .seg > button { flex: 1; }
  .asset-submit {
    align-self: flex-end;
    flex: 1 1 108px;
  }
  .asset-advanced-body {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .asset-source-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 12px 14px 12px 17px;
  }
  .asset-source-context {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
  .asset-source-availability {
    max-width: 100%;
    white-space: normal;
  }
  .asset-source-switch {
    display: flex;
    width: 100%;
  }
  .asset-source-switch > button {
    min-width: 0;
    flex: 1;
  }
  .asset-hero-main {
    grid-template-columns: 1fr;
    gap: 18px;
    min-height: 0;
    padding: 19px 18px 19px 21px;
  }
  .asset-title-row #a-ticker { font-size: 29px; }
  .asset-company { white-space: normal; }
  .asset-yield {
    min-width: 0;
    padding-top: 17px;
    padding-left: 0;
    border-top: 1px solid var(--border-hairline);
    border-left: 0;
    text-align: left;
  }
  .asset-yield .eyebrow { justify-content: flex-start; }
  .asset-yield-value { font-size: 46px; }

  .payout-head {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }
  .payout-toolbar {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px;
  }
  .payout-control .seg {
    display: flex;
    width: 100%;
  }
  .payout-control .seg > button {
    min-width: 0;
    flex: 1;
    padding-right: 8px;
    padding-left: 8px;
  }
  .payout-description {
    margin-top: 15px;
    margin-bottom: 14px;
  }

  .source-check-head {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 17px;
  }
  .source-overview {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }
  .source-overview-item {
    justify-content: center;
  }
  .source-impact {
    margin: 14px 14px 0;
    padding: 14px;
  }
  .source-impact-head {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .source-verdict {
    padding-top: 10px;
    padding-left: 0;
    border-top: 2px solid var(--border-strong);
    border-left: 0;
  }
  .source-verdict-ok { border-top-color: var(--success); }
  .source-verdict-wide { border-top-color: var(--warning); }
  .source-verdict-flip { border-top-color: var(--danger); }
  .source-family-section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    margin: 19px 14px 9px;
  }
  .source-families { padding: 0 14px; }
  .source-family summary { padding: 10px 11px; }
  .source-family-body { padding: 10px 11px 12px; }
  .source-method-note { margin: 15px 14px 17px; }

  .portfolio-section-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .portfolio-overview-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }
  .portfolio-method-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: -4px;
  }
  .portfolio-method-bar select { width: 100%; }
  .portfolio-assumptions { margin-top: -4px; }
  .portfolio-assumptions > summary { min-height: 58px; }
  .portfolio-assumptions-body { padding: 0 12px 12px; }
  .portfolio-assumption {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 12px 0;
  }
  .portfolio-assumption + .portfolio-assumption {
    border-top: 1px solid var(--border-hairline);
  }
  .portfolio-assumption select { width: 100%; min-height: 44px; }
  .portfolio-amount-modes .seg { width: 100%; }
  .portfolio-amount-modes .money-btn { min-height: 44px; flex: 1; }
  .portfolio-amount-field { min-height: 44px; }
  .portfolio-amount-field .input,
  .portfolio-amount-field .btn { min-height: 44px; }
  .portfolio-page .page-head-actions .btn { min-height: 44px; }
  .portfolio-source-legend {
    white-space: normal;
  }
  .portfolio-source-legend small { display: none; }
  .portfolio-sort {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }
  .portfolio-sort .input { width: 100%; }
  .portfolio-card-head { align-items: flex-start; }
  .portfolio-status { margin-top: 1px; }
  .portfolio-source-cell dt small { display: none; }
  .portfolio-source-cell dd { font-size: 23px; }
  .portfolio-method-details dl { grid-template-columns: 1fr; }
  .portfolio-method-details dl > div + div {
    border-top: 1px solid var(--border-hairline);
    border-left: 0;
  }
  .portfolio-method-details dt { min-height: 0; }
  .portfolio-metrics > div { padding: 0 7px; }
  .portfolio-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .portfolio-card-actions .btn {
    min-width: 0;
    min-height: 44px;
    width: 100%;
    padding: 0 7px;
  }
  .portfolio-card-actions .btn-primary,
  .portfolio-card-actions > span {
    grid-column: 1 / -1;
  }
  .portfolio-card-actions > span {
    padding: 3px 0;
    text-align: left;
  }
  .portfolio-detail-card summary {
    grid-template-columns: minmax(0, 1fr) 14px;
    gap: 10px;
  }
  .portfolio-holdings-desktop { display: none; }
  .portfolio-holdings-mobile { display: block; }

  /* O editor deixa de simular uma tabela larga em 390px. Cada papel vira uma
     linha compacta: identidade à esquerda, peso e remoção sempre visíveis. */
  #ed-list-wrap { overflow: visible; }
  #ed-list-wrap table,
  #ed-list-wrap tbody { display: block; }
  #ed-list-wrap thead { display: none; }
  #ed-list-wrap tbody {
    display: grid;
    gap: 7px;
  }
  #ed-list-wrap tbody tr {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) 72px 44px;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 7px;
    padding: 10px;
    border: 1px solid var(--border-hairline);
    border-radius: 9px;
    background: var(--surface-2);
  }
  #ed-list-wrap tbody td {
    min-width: 0;
    padding: 0;
  }
  #ed-list-wrap tbody td:nth-child(1) { grid-area: 1 / 1; }
  #ed-list-wrap tbody td:nth-child(2) {
    grid-area: 2 / 1;
    margin-top: 2px;
  }
  #ed-list-wrap tbody td:nth-child(3) { grid-area: 1 / 2 / 3 / 3; }
  #ed-list-wrap tbody td:nth-child(4) { grid-area: 1 / 3 / 3 / 4; }
  #ed-list-wrap tbody input {
    width: 72px;
    min-height: 44px;
  }
  #ed-list-wrap tbody button {
    width: 44px;
    min-height: 44px;
    padding: 0;
  }
  .portfolio-editor-company {
    max-width: 100%;
    margin-left: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .portfolio-card .help-btn {
    width: 24px;
    height: 24px;
  }
  .portfolio-page .help-btn {
    position: relative;
  }
  .portfolio-page .help-btn::after {
    position: absolute;
    inset: -10px;
    content: "";
  }
  #editor .btn { min-height: 44px; }
  .portfolio-money-prompt {
    align-items: stretch;
    flex-direction: column;
  }
  .portfolio-money-prompt .btn { width: 100%; min-height: 44px; }
  .portfolio-breakdown > summary { min-height: 44px; }
  .portfolio-insight-head { gap: 12px; padding: 12px; }
  .portfolio-insight-result strong { font-size: 20px; }
  .portfolio-detail-analysis { gap: 12px; padding: 10px; }
  .portfolio-detail-section-head { padding-right: 2px; padding-left: 2px; }
  .portfolio-detail-context {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .portfolio-holdings-heading { align-items: flex-start; padding: 13px 15px 11px; }
}

@media (min-width: 640px) and (max-width: 767px) {
  .portfolio-page .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 22px;
  }
  /* Mesmo tratamento da faixa de cima: a barra desce, os botões não esticam.
     Antes eles esticavam aqui e não esticavam a 768px, e um pixel de diferença
     na janela trocava "Nova carteira" de 238px para o tamanho do texto. O
     esticamento fica abaixo de 640px, onde a largura é alvo de toque. */
  .portfolio-page .page-head-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .portfolio-page .page-head-actions .page-head-theme { flex: 0 0 36px; }
  .portfolio-method-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: -4px;
  }
  .portfolio-method-bar select { width: 100%; }
}

/* Em tablet estreito, a sidebar deixa menos de 680px para o conteúdo. A tabela
   de sete colunas ainda funcionaria com scroll, mas os cards preservam a
   comparação por papel sem transformar metade da tela em uma faixa rolável. */
@media (min-width: 640px) and (max-width: 899px) {
  .portfolio-detail-card summary {
    grid-template-columns: minmax(0, 1fr) 14px;
    gap: 10px;
  }
  .portfolio-holdings-desktop { display: none; }
  .portfolio-holdings-mobile { display: block; }
}

/* ── Estados ────────────────────────────────────────────────────────────── */

/* Refetch mantém o render anterior esmaecido — sem skeleton flash. */
.is-loading { opacity: .45; transition: opacity .15s ease; pointer-events: none; }

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-2);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent,
              color-mix(in srgb, var(--surface-3) 80%, transparent), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%) } }

.spinner {
  width: 15px; height: 15px;
  border-radius: 99px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

/* ── Gráficos ───────────────────────────────────────────────────────────── */

/* Só os alvos de hover recebem ponteiro. Sem isto, as linhas de referência e
   os rótulos ficam por cima dos alvos e roubam o hover. */
.chart-svg line, .chart-svg text, .chart-svg path, .chart-svg circle { pointer-events: none; }
.chart-svg .hit, .chart-svg rect[role="button"] { pointer-events: all; }
.chart-svg .hit:focus-visible, .chart-svg rect[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Marca entra crescendo da base. `transform-box: fill-box` é o que faz o
   transform-origin valer para o próprio path em SVG. */
.chart-svg .mark {
  transform-box: fill-box;
  transition: opacity .18s var(--ease);
}
.chart-svg .mark-col { transform-origin: bottom center; animation: mark-up .5s var(--ease-out) backwards; }
.chart-svg .mark-bar { transform-origin: left center;   animation: mark-right .5s var(--ease-out) backwards; }
.chart-svg .mark-dot { transform-origin: center;        animation: mark-pop .45s var(--ease-out) backwards; }
@keyframes mark-up    { from { transform: scaleY(.02); opacity: .3 } }
@keyframes mark-right { from { transform: scaleX(.02); opacity: .3 } }
@keyframes mark-pop   { from { transform: scale(.2);   opacity: 0  } }

/* Foco por atenuação: ao apontar uma marca, as outras recuam. */
.chart-svg.dimmed .mark { opacity: .32; }
.chart-svg.dimmed .mark.is-on { opacity: 1; }

/* ── Tooltip ────────────────────────────────────────────────────────────── */

.tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 260px;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 9px 11px;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(3px) scale(.98);
  transition: opacity .12s var(--ease), transform .12s var(--ease);
}
.tip.is-open { opacity: 1; transform: none; }
.tip-dim { color: var(--text-secondary); }
/* Três colunas de números dentro do balão: rótulo, o que foi, o que se
   estimava e a diferença. Em linha corrida, "+24,9 pp" quebrava sozinho na
   linha de baixo e a comparação se perdia. */
.tip .tip-grade {
  display: grid;
  grid-template-columns: auto auto auto auto;
  gap: 2px 10px;
  align-items: baseline;
  margin: 5px 0 4px;
}
/* Duas colunas quando não há "estimado" para comparar: rótulo e valor. */
.tip .tip-grade.duas { grid-template-columns: 1fr auto; }
.tip .tip-grade.duas > :nth-child(even) { text-align: right; }
.tip .tip-grade:not(.duas) > :nth-child(4n+2),
.tip .tip-grade:not(.duas) > :nth-child(4n+3),
.tip .tip-grade:not(.duas) > :nth-child(4n+4) { text-align: right; }

/* Entrada de conteúdo trocado por render (tiles, linhas de tabela). */
.fade-in { animation: fade-in .35s var(--ease-out) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px) } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ── Painel de filtros recolhível (só no mobile) ────────────────────────── */

/* O header é sticky e carrega os filtros; em celular e tablet eles ocupariam
   a maior parte da altura útil. A partir de lg o painel volta a ser contínuo. */
@media (max-width: 1023px) {
  .filters-collapsed #filter-panel { display: none; }
}
#filters-toggle .chev { transition: transform .25s var(--ease); }
#filters-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ── Utilidades pontuais ────────────────────────────────────────────────── */

.link {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: color .15s var(--ease);
}
.link:hover { color: var(--accent-ink); text-decoration-style: solid; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  border: 1px solid var(--border-hairline);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--accent-line); color: var(--accent-ink); background: var(--accent-soft); }

kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 4px;
  border-radius: 5px;
  border: 1px solid var(--border-hairline);
  border-bottom-width: 2px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ── Carteira: ganho real comparado, sem valor principal duplicado ────────── */
.portfolio-source-comparison {
  margin: 0 12px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.portfolio-source-head {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.portfolio-source-head > span {
  display: inline-flex;
  align-items: center;
}
.portfolio-source-delta {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.portfolio-source-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.portfolio-source-cell {
  min-width: 0;
  padding: 13px 12px 12px;
}
.portfolio-source-cell + .portfolio-source-cell {
  border-left: 1px solid var(--border-hairline);
}
.portfolio-source-cell dt {
  display: flex;
  min-height: 18px;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-source-cell dt small {
  padding: 2px 5px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 8.5px;
  white-space: nowrap;
}
.portfolio-source-cell dd {
  margin-top: 3px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.15;
}
.portfolio-source-conclusion {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 12px 9px;
  border-top: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.45;
}
.portfolio-source-conclusion > span {
  width: 5px;
  height: 5px;
  margin-top: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--success);
}
.portfolio-source-comparison.is-single {
  padding-bottom: 12px;
}
.portfolio-source-single {
  display: block;
  padding: 12px 12px 0;
  font-size: 26px;
}
.portfolio-source-comparison.is-single > p {
  padding: 5px 12px 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
/* Inversão de sinal entre as fontes: o único caso em que a escolha decide. */
.portfolio-source-comparison.is-flip {
  background: color-mix(in srgb, #fab219 10%, var(--surface-2));
  border-color: color-mix(in srgb, #fab219 42%, transparent);
}
.portfolio-source-comparison.is-flip .portfolio-source-conclusion > span {
  background: var(--warning);
}

/* Outros métodos ficam sob demanda: preserva contexto sem poluir cada card. */
.portfolio-method-details {
  margin: 0;
  border: 1px solid var(--border-hairline);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-2) 54%, transparent);
}
.portfolio-method-details summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 8px;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}
.portfolio-method-details summary::-webkit-details-marker { display: none; }
.portfolio-method-details summary > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}
.portfolio-method-details summary > span > small {
  color: var(--accent-ink);
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.portfolio-method-details summary > span > strong {
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 650;
}
.portfolio-method-details summary > small {
  color: var(--text-muted);
  font-size: 10px;
}
.portfolio-method-details summary > i {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s var(--ease);
}
.portfolio-method-details[open] summary > i {
  transform: rotate(225deg);
}
.portfolio-method-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-method-body > p {
  max-width: 620px;
  padding: 10px 0 8px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}
.portfolio-method-body > p strong { color: var(--text-secondary); font-weight: 650; }
.portfolio-method-details dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
}
.portfolio-method-details dl > div {
  min-width: 0;
  padding: 9px 10px 10px;
}
.portfolio-method-details dl > div + div {
  border-left: 1px solid var(--border-hairline);
}
.portfolio-method-details dt {
  min-height: 26px;
  color: var(--text-muted);
  font-size: 9.5px;
  line-height: 1.3;
}
.portfolio-method-details dt small {
  display: block;
  color: var(--accent-ink);
  font-size: 8.5px;
}
.portfolio-method-details dd {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.portfolio-method-details .is-active dd { color: var(--accent-ink); }

@media (max-width: 639px) {
  .portfolio-method-details summary { min-height: 60px; }
  .portfolio-method-details dl { grid-template-columns: 1fr; }
  .portfolio-method-details dl > div + div {
    border-top: 1px solid var(--border-hairline);
    border-left: 0;
  }
  .portfolio-method-details dt { min-height: 0; }
}

/* A sobra deixou de ser rodapé: é a única coisa que o percentual não sabe
   dizer, e em aporte pequeno chega a 18% do que se pretendia investir. */
.portfolio-leftover {
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-2);
}
.portfolio-leftover strong { color: var(--text-primary); font-weight: 650; }

/* ── Card: o destaque, e a grade que iguala as alturas ────────────────────
   A grade existe para comparar carteiras lado a lado, e isso só funciona se a
   mesma linha estiver na mesma altura nos três. Antes o card de FII era metade
   do de ações, porque cada um tinha um conjunto diferente de blocos. */
.portfolio-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
}
.portfolio-headline > div { display: flex; flex-direction: column; gap: 1px; }
.portfolio-headline span {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 550;
}
.portfolio-headline small { color: var(--text-muted); font-size: 9.5px; }
.portfolio-headline strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.portfolio-grid > .portfolio-card { align-self: start; }

/* A análise completa, dentro do <details>: os mesmos blocos do card antigo,
   agora com largura inteira para respirar. */
.portfolio-detail-analysis {
  display: grid;
  gap: 14px;
  padding: 12px;
}
.portfolio-detail-lead {
  display: grid;
  gap: 10px;
}
.portfolio-detail-lead .portfolio-source-comparison {
  margin: 0;
}
.portfolio-detail-lead .portfolio-source-cell {
  padding-top: 10px;
  padding-bottom: 9px;
}
.portfolio-detail-lead .portfolio-source-cell dd { font-size: 22px; }
.portfolio-detail-lead .portfolio-source-conclusion { padding-top: 7px; padding-bottom: 7px; }
.portfolio-detail-lead .portfolio-mixes {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.portfolio-detail-lead .portfolio-mix + .portfolio-mix {
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
}
.portfolio-detail-section-head {
  padding: 3px 2px 0;
}
.portfolio-detail-section-head > div > span,
.portfolio-holdings-heading > div > span,
.portfolio-detail-context > span {
  display: block;
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.portfolio-detail-section-head h4,
.portfolio-holdings-heading h4 {
  margin-top: 2px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 650;
}
.portfolio-detail-section-head p,
.portfolio-holdings-heading p {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}
/* Duas colunas só para os DOIS blocos de conta, que têm tamanho parecido.
   A primeira versão jogava tudo numa grade de duas colunas com
   `align-items: start`, e como os blocos têm alturas diferentes sobravam
   buracos grandes: a composição setorial de um lado e um vão do outro. O que é
   largo — a comparação entre fontes e a composição — ocupa a linha inteira. */
@media (min-width: 1100px) {
  .portfolio-detail-lead { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
  .portfolio-detail-duo {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    /* Cada cálculo cresce de forma independente quando sua memória é aberta. */
    align-items: start;
  }
  .portfolio-detail-duo > * { margin: 0; }
}
.portfolio-detail-context {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border-hairline);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-2) 56%, transparent);
}
.portfolio-detail-context > span { flex: none; }
.portfolio-detail-context dl {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
}
.portfolio-detail-context dl > div {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}
.portfolio-detail-context dt { color: var(--text-muted); font-size: 10px; }
.portfolio-detail-context dd { color: var(--text-secondary); font-size: 10.5px; font-weight: 650; }
.portfolio-holdings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 11px;
  border-top: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
  background: color-mix(in srgb, var(--surface-2) 42%, transparent);
}
.portfolio-holdings-heading > div { min-width: 0; }
/* Coluna opcional, no espírito do "ocultar coluna" da planilha: ela existe no
   HTML e some da vista, então mostrar de volta não custa nem uma coleta nem um
   redesenho da tabela inteira. */
.sem-contrib .col-opcional { display: none; }
.portfolio-holdings-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}
.col-toggle {
  padding: 4px 9px;
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .12s var(--ease-out), border-color .12s var(--ease-out),
              background .12s var(--ease-out);
}
.col-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.col-toggle[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent-ink);
}
.portfolio-holdings-heading > strong {
  flex: none;
  padding: 4px 8px;
  border: 1px solid var(--border-hairline);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}
@media (max-width: 639px) {
  .portfolio-detail-context {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .portfolio-holdings-heading { align-items: flex-start; }
}
.portfolio-spend {
  margin-top: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.portfolio-spend strong { font-weight: 700; }

/* ── Consolidado entre carteiras ─────────────────────────────────────────
   Só existe no modo "o que tenho aplicado": somar "R$ 100 mil em cada" não
   responderia nada sobre o patrimônio de fato. */
.portfolio-consolidated {
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}
.portfolio-consolidated-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 10px 24px;
}
.portfolio-consolidated dt {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 6px;
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 550;
}
.portfolio-consolidated dt small { color: var(--text-muted); font-size: 9.5px; }
.portfolio-consolidated dd {
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.portfolio-consolidated dd span {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0;
}
.portfolio-consolidated-note {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 10.5px;
}
.portfolio-amount-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Reais sob o número, e não emendados na descrição: concatenados, a frase
   passava de uma linha e o bloco crescia nos três cards de uma vez.

   As três colunas compartilham as MESMAS linhas da grade, com subgrid. Sem
   isso, só a coluna com reais ficava mais alta e o número dela subia 16px em
   relação aos vizinhos — e a linha existe justamente para ser lida na
   horizontal. */
.portfolio-metrics { grid-template-rows: 1fr auto auto; }
.portfolio-metrics > div {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
}
.metric-money { min-height: 0; }
.portfolio-headline-value { text-align: right; }
.portfolio-headline-value small,
.metric-money small {
  display: block;
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}
/* Sem valor informado o lugar não some — diria uma altura diferente em cada
   card e a grade deixaria de alinhar. Fica o convite, em tom apagado. */
.casc-brl-empty { opacity: .55; font-style: italic; }
@container (max-width: 420px) {
  /* Em fila a grade de três linhas não se aplica: cada métrica vira uma linha
     com rótulo à esquerda e número à direita, e os reais acompanham o número. */
  .portfolio-metrics { grid-template-rows: none; }
  .portfolio-metrics > div {
    display: flex;
    flex-wrap: wrap;
    grid-row: auto;
    grid-template-rows: none;
  }
  /* Os reais descem para uma linha própria. Como terceiro item da fila, eles
     disputavam largura com o rótulo e empurravam o "?" para baixo, longe do
     termo que ele explica. */
  .metric-money { width: 100%; text-align: right; }
  .metric-money:empty { display: none; }
  .metric-money small { white-space: normal; }
}

/* ── Histórico ──────────────────────────────────────────────────────────── */
/* A tela lê a mesma gramática das carteiras (card, grade 3×3, legenda de
   fonte) e acrescenta o que só ela tem: KPIs de fim de ano, o gráfico dos
   R$ 100, o triângulo e o haltere projetado × realizado. Nada de cor nova —
   as séries usam o acento, o texto secundário e o verde/vermelho semânticos. */

.historico-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 22px;
  margin-bottom: 16px;
  padding: 14px 18px;
}
.historico-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 150px;
}
.historico-field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.historico-field .seg > button { height: 28px; font-size: 12px; }
.historico-base {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-bottom: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.historico-base > .legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 11%, transparent);
}
.historico-base small { color: var(--text-muted); font-size: inherit; }

.historico-coleta { margin-bottom: 16px; padding: 14px 18px; }
.historico-coleta-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.historico-coleta-bar {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.historico-coleta-bar > div {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s var(--ease);
}

.historico-nota {
  margin: 0 0 14px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 12%, var(--surface-1));
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}
.historico-nota .link { margin-left: 4px; }

/* A frase que abre cada seção: o número traduzido em português. */
/* Sem caixa. Era um bloco cinza em cada seção, e seis blocos cinzas iguais
   faziam a frase — que é a resposta — parecer uma nota lateral. Agora é o
   lide: corpo maior, medida de leitura, direto sob o título. */
.historico-leitura {
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  max-width: 68ch;
  text-wrap: pretty;
}
.historico-fatos {
  margin: 0;
  max-width: 76ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.historico-fatos b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.historico-leitura b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* O guia de leitura: fechado por padrão, sem roubar a cena. */
.historico-guia { margin-bottom: 14px; padding: 0; }
.historico-guia > summary {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  list-style: none;
}
.historico-guia > summary::-webkit-details-marker { display: none; }
.historico-guia > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--text-muted); transition: transform .16s var(--ease); }
.historico-guia[open] > summary::before { transform: rotate(90deg); }
.historico-guia > summary:hover { color: var(--text-primary); }
.historico-guia-corpo { padding: 2px 16px 16px 30px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); max-width: 78ch; }
.historico-guia-corpo p { margin: 0 0 10px; }
.historico-guia-corpo strong { color: var(--text-primary); font-weight: 600; }
.historico-guia-corpo ol { margin: 0 0 12px; padding-left: 20px; }
.historico-guia-corpo ol li { margin: 4px 0; }
.historico-guia-corpo dl { display: grid; grid-template-columns: 1fr; gap: 6px 0; margin: 0; border-top: 1px solid var(--border-hairline); padding-top: 10px; }
.historico-guia-corpo dl > div { display: grid; grid-template-columns: 200px 1fr; gap: 12px; }
.historico-guia-corpo dt { color: var(--text-primary); font-weight: 500; }
.historico-guia-corpo dd { margin: 0; }
.historico-tabela abbr, .portfolio-proj abbr { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
@media (max-width: 640px) {
  .historico-guia-corpo dl > div { grid-template-columns: 1fr; gap: 2px; }
}
.historico-loading-inline { display: flex; justify-content: center; padding: 40px 0; }

/* ── As seis seções ─────────────────────────────────────────────────────── */
/* Cada seção é uma pergunta. O que segura a densidade não é o CSS, é a regra
   de no máximo três números por seção — mas o espaço entre elas é o que faz o
   olho entender que são blocos separados, e não uma parede. */
.historico-secao { display: flex; flex-direction: column; gap: 14px; }
.historico-secao:empty { display: none; }
#content { display: flex; flex-direction: column; gap: 34px; }
.historico-secao-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-strong);
}
.historico-secao-head h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}
/* O seletor de ano vive DENTRO do título: "E se eu tivesse comprado em [2019]?"
   é a pergunta inteira, e separá-los deixava a pergunta sem objeto. */
.historico-secao-head h2 select { font-size: 15px; font-weight: 600; padding-block: 2px; }
.historico-secao-controle { display: flex; align-items: center; gap: 8px; }
.historico-secao.is-carregando { opacity: .55; transition: opacity .15s var(--ease); }

/* O divisor: a virada de "todos os anos" para "um ano de cada vez". Não é
   ornamento — é a única pista de que a pergunta mudou de natureza. */
.historico-divisor {
  margin: 14px 0 0;
  padding-top: 26px;
  border-top: 2px solid var(--text-primary);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── A régua ────────────────────────────────────────────────────────────── */
/* Três marcas, as mesmas na página inteira: ○ o método estimava · ● rendeu ·
   ┃ o CDI. Tudo por token, para os dois temas saírem do mesmo desenho. */
.historico-regua { margin: 6px 0 2px; }
.historico-regua svg { display: block; width: 100%; height: auto; overflow: visible; }
.historico-regua .grid { stroke: var(--gridline); stroke-width: 1; }
.historico-regua .zero { stroke: var(--baseline); stroke-width: 1; }
.historico-regua .eixo { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.historico-regua .trilho { stroke: var(--border-strong); stroke-width: 1; }
.historico-regua .faixa { fill: var(--accent-soft); }
.historico-regua .elo { stroke: var(--accent-line); stroke-width: 3; stroke-linecap: round; }
.historico-regua line.cdi { stroke: var(--text-primary); stroke-width: 2; }
.historico-regua circle.est { fill: var(--surface-1); stroke: var(--text-secondary); stroke-width: 2; }
.historico-regua circle.real { fill: var(--series-1); }
.historico-regua .nome { fill: var(--text-secondary); font-size: 12.5px; }
.historico-regua .rotulo { font-size: 12px; font-variant-numeric: tabular-nums; fill: var(--text-secondary); }
.historico-regua .rotulo.real { fill: var(--text-primary); font-weight: 600; }
.historico-regua .rotulo.quieto { fill: var(--text-muted); font-size: 11.5px; }
.historico-regua .fundo { fill: transparent; }
.regua-linha { cursor: pointer; outline: none; }
/* A linha escolhida fala; as outras duas recuam, mas ficam — é vê-las juntas
   que mostra o imposto e a inflação empurrando tudo para a esquerda. */
.regua-linha:not(.is-on) { opacity: .5; transition: opacity .15s var(--ease); }
.regua-linha:not(.is-on):hover { opacity: .85; }
.regua-linha.is-on .nome { fill: var(--text-primary); font-weight: 600; }
.regua-linha:focus-visible .fundo { stroke: var(--accent); stroke-width: 2; }
.historico-regua figcaption,
.historico-grafico figcaption { align-items: center; }
.historico-regua figcaption {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  margin-top: 6px; font-size: 11.5px; color: var(--text-muted);
}
.historico-regua figcaption span { display: inline-flex; align-items: center; gap: 7px; }

/* As marcas, fora do SVG: legenda e parcelas usam as MESMAS três. */
.marca { display: inline-block; flex: none; box-sizing: border-box; }
.marca.est { width: 11px; height: 11px; border-radius: 99px; border: 2px solid var(--text-secondary); background: var(--surface-1); }
.marca.real { width: 11px; height: 11px; border-radius: 99px; background: var(--series-1); }
.marca.cdi { width: 2px; height: 14px; background: var(--text-primary); }
.marca.faixa { width: 18px; height: 10px; border-radius: 3px; background: var(--accent-soft); }
.historico-grafico line.cdi { stroke: var(--text-primary); stroke-width: 2; }

/* As parcelas: a mesma régua, em HTML. */
.historico-parte-trilho { position: relative; display: block; height: 22px; }
.historico-parte-trilho::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border-strong);
}
.historico-parte-trilho i { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.historico-parte-trilho i.zero { width: 1px; height: 16px; background: var(--baseline); }
.historico-parte-trilho i.elo { height: 3px; border-radius: 2px; background: var(--accent-line); transform: translateY(-50%); }
.historico-parte-trilho i.elo.neg { background: color-mix(in srgb, var(--danger) 45%, transparent); }

/* ── A grade da carteira, comparada ─────────────────────────────────────── */
.historico-grade-comparada { width: 100%; border-collapse: collapse; }
.historico-grade-comparada th,
.historico-grade-comparada td {
  padding: 12px 14px;
  text-align: right;
  vertical-align: bottom;
  border-bottom: 1px solid var(--border-hairline);
}
.historico-grade-comparada thead th {
  padding-block: 0 8px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  border-bottom-color: var(--border-strong);
}
.historico-grade-comparada th[scope="row"] {
  text-align: left; vertical-align: middle;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.historico-grade-comparada th small,
.historico-grade-comparada td small {
  display: block; font-size: 11.5px; font-weight: 400; color: var(--text-muted); white-space: normal;
}
.historico-grade-comparada th small { max-width: 26ch; }
.historico-grade-comparada td strong { display: block; font-size: 21px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.historico-grade-comparada td em { font-style: normal; font-size: 12px; font-weight: 600; }
.historico-grade-comparada td.is-cdi strong { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.historico-grade-comparada tbody tr:last-child th,
.historico-grade-comparada tbody tr:last-child td { border-bottom: 0; }
/* A linha da lente em uso: uma barra à esquerda, não um fundo — fundo em
   linha de tabela briga com os números coloridos. */
.historico-grade-comparada tr.is-on th[scope="row"] { box-shadow: inset 3px 0 0 var(--series-1); padding-left: 14px; }
.historico-grade-comparada tr:not(.is-on) td strong { font-weight: 500; }

/* O selo de amostra — a ressalva que anda colada ao número. */
.historico-selo {
  font-size: 11.5px;
  color: var(--text-muted);
  padding-left: 11px;
  border-left: 2px solid var(--border-strong);
}

/* O detalhe pesado. O tamanho vai no rótulo: quem abre sabe no que se mete. */
.historico-detalhe { border-top: 1px solid var(--border-hairline); }
.historico-detalhe > summary {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 0;
  font-size: 12.5px;
  color: var(--accent-ink);
  cursor: pointer;
  list-style: none;
}
.historico-detalhe > summary::-webkit-details-marker { display: none; }
.historico-detalhe > summary::before {
  content: "›"; font-size: 15px; line-height: 1;
  transition: transform .16s var(--ease);
}
.historico-detalhe[open] > summary::before { transform: rotate(90deg); }
.historico-detalhe > summary:hover { color: var(--text-primary); }
.historico-detalhe-corpo { padding: 4px 0 16px; }

/* Barras da seção 3: estimado x entregue, uma parcela por linha. */
.historico-barras { display: flex; flex-direction: column; gap: 14px; }
.historico-barra {
  display: grid;
  grid-template-columns: 92px minmax(120px, 1fr) auto;
  align-items: center;
  gap: 16px;
}
.historico-barra-rotulo { font-size: 12.5px; color: var(--text-secondary); }
.historico-barra-valores {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--text-muted);
}
.historico-barra-valores strong { font-size: 14px; color: var(--text-primary); }
.historico-barra-valores > :last-child { font-weight: 600; min-width: 58px; text-align: right; }

.historico-ressalvas {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 80ch;
}
.historico-ressalvas strong { color: var(--text-primary); font-weight: 600; }

.historico-bloco { padding: 18px 20px; }
.historico-bloco .portfolio-proj { margin: 0 -20px; width: calc(100% + 40px); }
.historico-bloco-head { margin-bottom: 12px; }
.historico-bloco-head h2 { font-size: 14px; font-weight: 600; }
.historico-bloco-head h2 small { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.historico-bloco-head p { margin-top: 3px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.historico-rodape { margin-top: 12px; font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
/* O cabeçalho do painel de um papel: título à esquerda, fechar à direita. */
.historico-papel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* Tabelas: cabeçalho apagado, números à direita, sub-rótulo em small. */
.historico-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.historico-tabela th,
.historico-tabela td {
  padding: 7px 8px;
  text-align: right;
  vertical-align: top;
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}
.historico-tabela thead th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom-color: var(--border-strong);
}
.historico-tabela th[scope="row"],
.historico-tabela thead th:first-child { text-align: left; font-weight: 600; }
.historico-tabela th[scope="colgroup"] { text-align: center; }
.historico-tabela tbody tr:last-child td,
.historico-tabela tbody tr:last-child th { border-bottom: 0; }
.historico-tabela small {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
}
.historico-tabela .is-muted { color: var(--text-muted); }

/* O fecho da tabela de um ano: o acumulado tem peso de total, não de mais uma
   linha — regra forte em cima e fundo levemente destacado. */
.historico-tabela tfoot th,
.historico-tabela tfoot td {
  border-bottom: 0;
  font-weight: 600;
  background: var(--surface-2);
}
.historico-tabela tfoot tr:first-child th,
.historico-tabela tfoot tr:first-child td { border-top: 1px solid var(--border-strong); }
.historico-tabela tfoot tr:last-child th,
.historico-tabela tfoot tr:last-child td { font-weight: 500; color: var(--text-secondary); }

/* "Como contar": o seletor governa a TABELA, e por isso mora colado nela. */
.historico-visao {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 14px 0 8px;
}
.historico-visao-rotulo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.historico-visao-nota {
  flex: 1 1 220px;
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.historico-tabela .is-neutral { color: var(--text-secondary); }
.historico-depois td strong { font-weight: 600; }
.ticker-link {
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.ticker-link:hover { text-decoration-style: solid; }

/* Triângulo: intensidade pela magnitude, cor pelo sinal. */
.historico-triangulo td.is-positive {
  background: color-mix(in srgb, var(--success) calc(var(--k, 0) * 28%), transparent);
}
.historico-triangulo td.is-negative {
  background: color-mix(in srgb, var(--danger) calc(var(--k, 0) * 28%), transparent);
}
.historico-triangulo th[scope="col"] small { display: block; }

/* Gráficos: SVG inline com as cores do tema. */
.historico-grafico { margin: 4px 0 14px; }
.historico-grafico svg { width: 100%; height: auto; display: block; }
.historico-grafico .grid { stroke: var(--gridline); stroke-width: 1; }
.historico-grafico .base { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }
.historico-grafico .eixo { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.historico-grafico .serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.historico-grafico .serie.capital { stroke: var(--accent); }
.historico-grafico .serie.real { stroke: var(--accent); stroke-dasharray: 4 3; opacity: .7; }
.historico-grafico .serie.cdi { stroke: var(--text-secondary); stroke-width: 1.5; }
.historico-grafico .ponto { fill: var(--surface-1); stroke: var(--accent); stroke-width: 2; }
.historico-grafico .barra { fill: var(--success); opacity: .35; }
.historico-grafico .rotulo { fill: var(--success); font-size: 10px; font-variant-numeric: tabular-nums; }
.historico-grafico .haltere { stroke: var(--baseline); stroke-width: 2; }
.historico-grafico circle.proj { fill: var(--surface-1); stroke: var(--text-secondary); stroke-width: 2; }
.historico-grafico circle.real { fill: var(--accent); }
.historico-grafico rect.renda { fill: var(--success); opacity: .5; }
.historico-grafico figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.historico-grafico figcaption span { display: inline-flex; align-items: center; gap: 6px; }
/* O convite fica no fim da legenda e recua: é instrução, não dado. */
.historico-grafico .historico-dica { margin-left: auto; font-style: italic; opacity: .75; }
.historico-grafico .hit { cursor: pointer; }

/* A linha que o gráfico está apontando. Fundo, e não borda: borda mexeria na
   altura da linha e a tabela inteira dançaria a cada hover. */
.historico-tabela tr.is-apontada td,
.historico-tabela tr.is-apontada th { background: var(--surface-2); }
.historico-grafico .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--accent); }
.historico-grafico .sw.real { background: var(--accent); opacity: .7; }
.historico-grafico .sw.cdi { background: var(--text-secondary); }
.historico-grafico .sw.barra { background: var(--success); opacity: .5; height: 8px; }
.historico-grafico .sw.proj { width: 10px; height: 10px; border-radius: 99px; background: transparent; border: 2px solid var(--text-secondary); }
.historico-grafico .sw.renda { background: var(--success); opacity: .5; height: 8px; width: 6px; }
.historico-grafico figcaption .sw.real { width: 10px; height: 10px; border-radius: 99px; opacity: 1; }

.historico-papel { margin-top: 16px; padding: 18px 20px; }
.historico-sinais {
  margin: 0 0 12px;
  padding: 8px 12px 8px 26px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 12%, var(--surface-1));
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .historico-base { margin-left: 0; white-space: normal; }
  /* Na coluna estreita, rótulo em cima e números embaixo — a barra fica com a
     largura inteira em vez de espremida entre duas colunas de texto. */
  .historico-barra { grid-template-columns: 1fr; gap: 4px; }
  .historico-barra-valores { justify-content: flex-end; }
  .historico-secao-head { align-items: flex-start; }
}

/* ── Histórico v2: narrativa da projeção à evidência ───────────────────── */
.historico-v2 .historico-page { padding-top: 22px; padding-bottom: 0; }
.historico-v2 .page-head { margin-bottom: 18px; }
.historico-v2 .page-head h1 { font-size: 30px; line-height: 1.05; }
.historico-v2 .page-head-actions { align-items: center; }
.historico-data {
  margin-right: 8px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.historico-v2 .historico-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  align-items: end;
  gap: 13px 16px;
  margin-bottom: 0;
  padding: 14px 16px 11px;
  border-radius: 10px 10px 0 0;
  box-shadow: none;
}
.historico-v2 .historico-field { min-width: 0; }
.historico-v2 .historico-field .input { width: 100%; }
.historico-v2 .historico-base {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2px 0 0;
}
.historico-target {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
  margin: -2px 0 2px;
  padding: 2px 0 13px;
  border-bottom: 1px solid var(--border-hairline);
}
.historico-target-copy { min-width: 0; }
.historico-target-copy > span {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.historico-target-copy strong {
  display: block;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 630;
  line-height: 1.35;
}
.historico-target-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.historico-target-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: none;
}
.historico-target-controls .seg > button {
  min-width: 116px;
  min-height: 30px;
}
.historico-target-asset {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.historico-target-asset[hidden] { display: none; }
.historico-target-asset > span {
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.historico-target-asset .input { width: 190px; min-width: 0; }
.historico-toolbar.is-asset-scope .historico-target {
  border-bottom-color: var(--accent-line);
}
.historico-toolbar.is-asset-scope .historico-target-copy strong { color: var(--accent-ink); }

.historico-chapters {
  position: sticky;
  top: 0;
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 2px;
  background: color-mix(in srgb, var(--page-plane) 92%, transparent);
  border-top: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-strong);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
}
.historico-chapters a {
  position: relative;
  padding: 12px 8px 11px;
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}
.historico-chapters a:hover { color: var(--text-primary); background: var(--surface-2); }
.historico-chapters a[aria-current="true"] { color: var(--accent-ink); }
.historico-chapters a[aria-current="true"]::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.historico-v2 #content { gap: 0; }
.historico-v2 .historico-secao {
  gap: 14px;
  padding: 28px 0 30px;
  border-bottom: 1px solid var(--border-strong);
  scroll-margin-top: 54px;
}
.historico-v2 .historico-secao-head { padding-bottom: 0; border-bottom: 0; }
.historico-v2 .historico-secao-head h2,
.historico-summary-block h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -.025em;
}
.historico-section-intro {
  max-width: 84ch;
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}
.historico-kicker {
  margin: 0 0 7px;
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.historico-summary-grid {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 0;
}
.historico-summary-block { min-width: 0; padding: 4px 34px 7px 0; }
.historico-summary-block + .historico-summary-block {
  padding-right: 0;
  padding-left: 34px;
  border-left: 1px solid var(--border-strong);
}
.historico-summary-copy {
  max-width: 55ch;
  min-height: 38px;
  margin: 8px 0 12px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}
.historico-main-number {
  display: block;
  margin: 2px 0 12px;
  color: var(--accent-ink);
  font-size: clamp(38px, 4.2vw, 56px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.05em;
}
.historico-main-number small { font-size: 20px; font-weight: 550; letter-spacing: -.02em; }
.historico-projection-parts { display: flex; gap: 0; margin: 0; }
.historico-projection-parts > div { min-width: 150px; padding-right: 28px; }
.historico-projection-parts > div + div { padding-left: 28px; border-left: 1px solid var(--border-strong); }
.historico-projection-parts dt { color: var(--text-secondary); font-size: 11.5px; }
.historico-projection-parts dd { margin: 3px 0 0; color: var(--success-text); font-size: 20px; font-weight: 620; }
.historico-projection-parts dd small { font-size: 11px; font-weight: 550; }

.historico-evidence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 22px;
  align-items: center;
}
.historico-error-number { display: block; color: var(--accent-ink); font-size: 28px; line-height: 1.15; letter-spacing: -.035em; }
.historico-evidence-row p { margin: 6px 0 0; color: var(--text-secondary); font-size: 12px; }
.historico-sample { padding-left: 22px; border-left: 1px solid var(--border-strong); }
.historico-sample strong { display: block; font-size: 30px; line-height: 1; }
.historico-sample span { display: block; margin-top: 5px; color: var(--text-muted); font-size: 10.5px; line-height: 1.35; }
.historico-error-range { position: relative; height: 35px; margin-top: 8px; }
.historico-error-range .range-line,
.historico-error-range .range-band { position: absolute; top: 7px; height: 5px; border-radius: 99px; }
.historico-error-range .range-line { left: 0; width: 100%; background: var(--surface-3); }
.historico-error-range .range-band { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.historico-error-range i { position: absolute; top: 2px; width: 1px; height: 15px; background: var(--text-muted); }
.historico-error-range .range-median { width: 2px; background: var(--accent-ink); }
.historico-error-range small { position: absolute; top: 19px; color: var(--text-muted); font-size: 9px; transform: translateX(-50%); }
.historico-evidence-note { margin: 11px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.historico-evidence-note b { color: var(--text-secondary); font-weight: 600; }
.historico-context-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 20px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  font-size: 11.5px;
}
.historico-context-note span {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  flex: none;
  border: 1px solid var(--accent-ink);
  border-radius: 50%;
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
}

.historico-chart-with-note { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 28px; align-items: stretch; }
.historico-chart-note {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 0 16px 22px;
  border-left: 1px solid var(--border-strong);
}
.historico-chart-note > strong { font-size: 16px; line-height: 1.45; }
.historico-chart-note > strong span { color: var(--text-primary); }
.historico-chart-note p { margin: 12px 0 0; color: var(--text-muted); font-size: 11.5px; line-height: 1.55; }
.historico-chart-note b { color: var(--text-secondary); }
.historico-v2 #sec-partes .historico-leitura { max-width: 82ch; font-size: 13px; }
.historico-v2 #sec-partes .historico-barras { max-width: 820px; }
.historico-v2 .historico-barra { grid-template-columns: 92px minmax(160px, 1fr) 180px; }

/* A comparação histórica é uma peça de leitura, não só uma tabela escondida.
   O resumo explica o conteúdo antes da abertura e mantém amostra/lente à vista. */
.historico-comparison-detail {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
}
.historico-comparison-detail > summary {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 11px;
  min-height: 62px;
  padding: 10px 13px;
  color: var(--text-primary);
}
.historico-comparison-detail > summary::before {
  width: auto;
  color: var(--accent-ink);
  font-size: 18px;
}
.historico-comparison-detail[open] > summary { border-bottom: 1px solid var(--border-hairline); }
.historico-comparison-detail-copy { min-width: 0; }
.historico-comparison-detail-copy strong {
  display: block;
  font-size: 12.5px;
  font-weight: 620;
  line-height: 1.35;
}
.historico-comparison-detail-copy small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.historico-comparison-detail-meta {
  padding: 4px 8px;
  border-radius: 99px;
  color: var(--text-secondary);
  background: var(--surface-3);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.historico-comparison-detail > .historico-detalhe-corpo { padding: 14px 14px 16px; }
.historico-table-context {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  margin-bottom: 10px;
  padding: 9px 11px;
  border-left: 2px solid var(--accent-ink);
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-size: 11px;
  line-height: 1.45;
}
.historico-table-context strong { color: var(--text-primary); font-size: 11.5px; font-weight: 620; }
.historico-aderencia-fii { min-width: 760px; }
.historico-aderencia-fii th,
.historico-aderencia-fii td { padding: 10px 12px; vertical-align: middle; }
.historico-aderencia-fii thead tr:first-child th { padding-bottom: 7px; }
.historico-aderencia-fii thead tr:last-child th { padding-top: 7px; }
.historico-aderencia-fii tbody th[scope="row"] { font-size: 13.5px; }
.historico-aderencia-fii tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.historico-aderencia-fii .historico-total-realizado { font-weight: 650; }
.historico-table-notes {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(280px, 1.3fr);
  gap: 12px 28px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.historico-table-notes p {
  margin: 0;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.55;
}
.historico-table-notes strong { display: block; margin-bottom: 2px; color: var(--text-secondary); font-weight: 620; }
.historico-table-notes p:nth-child(3) { grid-column: 1 / -1; }

.historico-divisor {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 24px 0 0;
  border-top: 0;
  color: var(--text-muted);
  font-size: 11px;
}
.historico-divisor span { color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.historico-divisor::before { content: ""; width: 34px; height: 2px; background: var(--text-primary); }
.historico-divisor + .historico-nota { margin: 14px 0 0; }

.historico-year-control { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 11px; }
.historico-year-control .input { min-width: 90px; }
.historico-v2 #sec-ano .historico-leitura { max-width: none; font-size: 13px; }
.historico-year-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  gap: 28px;
  align-items: start;
}
.historico-year-table,
.historico-year-chart { min-width: 0; }
.historico-year-chart { padding-left: 26px; border-left: 1px solid var(--border-strong); }
.historico-year-chart h3 { margin: 1px 0 14px; font-size: 12px; font-weight: 600; }
.historico-year-chart .historico-grafico { margin-bottom: 4px; }
.historico-year-table .historico-grade-comparada th,
.historico-year-table .historico-grade-comparada td { padding: 9px 8px; }
.historico-year-table .historico-grade-comparada td strong { font-size: 17px; }
.historico-year-table .historico-rodape { font-size: 10px; }

.historico-year-explore { margin-top: 4px; }
.historico-year-explore-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.historico-year-explore-head h3 { margin: 0; font-size: 13px; font-weight: 620; }
.historico-year-explore-head p { margin: 0; color: var(--text-muted); font-size: 10.5px; }
.historico-year-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.historico-year-detail {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.historico-year-detail:hover {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-2));
}
.historico-year-detail[open] {
  grid-column: 1 / -1;
  background: var(--surface-1);
}
.historico-year-detail:only-child { grid-column: 1 / -1; }
.historico-year-detail > summary {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 58px;
  align-items: center;
  padding: 9px 12px;
  color: var(--text-primary);
}
.historico-year-detail > summary::before {
  width: auto;
  color: var(--accent-ink);
  font-size: 18px;
}
.historico-year-detail[open] > summary { border-bottom: 1px solid var(--border-hairline); }
.historico-year-detail-copy { min-width: 0; }
.historico-year-detail-copy strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.historico-year-detail-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.historico-year-detail-meta {
  padding: 3px 7px;
  border-radius: 99px;
  color: var(--text-secondary);
  background: var(--surface-3);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.historico-year-detail > .historico-detalhe-corpo { padding: 14px 14px 16px; }

.historico-matrix-grid { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 26px; align-items: start; }
.historico-matrix-legend { display: flex; flex-direction: column; gap: 9px; padding: 12px 0 12px 20px; border-left: 1px solid var(--border-strong); color: var(--text-secondary); font-size: 10.5px; }
.historico-matrix-legend strong { margin-bottom: 3px; color: var(--text-primary); font-size: 11px; }
.historico-matrix-legend span { display: flex; align-items: center; gap: 7px; }
.historico-matrix-legend i { width: 12px; height: 12px; border-radius: 2px; background: var(--surface-3); }
.historico-matrix-legend i.is-positive { background: color-mix(in srgb, var(--success) 55%, var(--surface-2)); }
.historico-matrix-legend i.is-negative { background: color-mix(in srgb, var(--danger) 55%, var(--surface-2)); }
.historico-matrix-legend p { margin: 8px 0 0; color: var(--text-muted); line-height: 1.5; }

.historico-limits { margin: 0; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.historico-limits > div { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 12px 14px; }
.historico-limits > div + div { border-top: 1px solid var(--border-hairline); }
.historico-limits dt { color: var(--text-primary); font-size: 11.5px; font-weight: 600; }
.historico-limits dd { margin: 0; color: var(--text-secondary); font-size: 11.5px; line-height: 1.5; }
.historico-v2 .historico-guia { margin: 0; border: 1px solid var(--border-hairline); border-radius: 7px; }

.historico-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  padding: 22px 0 26px;
  border-top: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 10.5px;
}
.historico-footer .brand-name { color: var(--text-primary); font-weight: 650; }
.historico-footer nav { display: flex; gap: 24px; margin-left: auto; }
.historico-footer a:hover { color: var(--text-primary); }

@media (max-width: 1040px) {
  .historico-v2 .historico-toolbar { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .historico-v2 .historico-base { grid-column: 1 / -1; }
  .historico-target { align-items: flex-start; flex-direction: column; gap: 10px; }
  .historico-target-controls { width: 100%; justify-content: flex-start; }
  .historico-summary-grid { grid-template-columns: 1fr; gap: 25px; }
  .historico-summary-block { padding-right: 0; }
  .historico-summary-block + .historico-summary-block { padding: 26px 0 0; border-top: 1px solid var(--border-strong); border-left: 0; }
  .historico-year-grid { grid-template-columns: 1fr; }
  .historico-year-chart { padding: 24px 0 0; border-top: 1px solid var(--border-strong); border-left: 0; }
}

@media (max-width: 760px) {
  .historico-data { display: none; }
  .historico-chapters { display: flex; overflow-x: auto; scrollbar-width: none; }
  .historico-chapters a { flex: 0 0 auto; padding-inline: 14px; white-space: nowrap; }
  .historico-detalhe-corpo, .historico-year-table, .historico-chart-with-note > div { min-width: 0; max-width: 100%; overflow-x: auto; }
  /* `1fr` sozinho ainda deixa a coluna crescer com a tabela de 15 colunas
     dentro dela; `minmax(0, 1fr)` é o que a obriga a caber e rolar por dentro. */
  .historico-chart-with-note,
  .historico-matrix-grid { grid-template-columns: minmax(0, 1fr); }
  .historico-matrix-grid > div { min-width: 0; overflow-x: auto; }
  .historico-chart-note,
  .historico-matrix-legend { padding: 18px 0 0; border-top: 1px solid var(--border-strong); border-left: 0; }
  .historico-limits > div { grid-template-columns: 1fr; gap: 4px; }
  .historico-year-detail-list { grid-template-columns: 1fr; }
  .historico-year-detail[open] { grid-column: auto; }
}

@media (max-width: 640px) {
  .historico-v2 .historico-page { padding-top: 14px; }
  .historico-v2 .page-head { align-items: flex-start; }
  .historico-v2 .historico-toolbar { grid-template-columns: 1fr; border-radius: 10px 10px 0 0; }
  .historico-v2 .historico-base { grid-column: 1; }
  .historico-target-controls { align-items: stretch; flex-direction: column; }
  .historico-target-controls .seg { display: flex; width: 100%; }
  .historico-target-controls .seg > button { flex: 1; min-width: 0; }
  .historico-target-asset { align-items: stretch; flex-direction: column; gap: 4px; }
  .historico-target-asset .input { width: 100%; }
  .historico-target-copy small { white-space: normal; }
  .historico-main-number { font-size: 42px; }
  .historico-projection-parts > div { min-width: 0; flex: 1; padding-right: 16px; }
  .historico-projection-parts > div + div { padding-left: 16px; }
  .historico-evidence-row { grid-template-columns: 1fr 72px; gap: 12px; }
  .historico-error-number { font-size: 23px; }
  .historico-v2 .historico-barra { grid-template-columns: 1fr; }
  .historico-year-grid { gap: 16px; }
  .historico-year-explore-head { display: block; }
  .historico-year-explore-head p { margin-top: 3px; }
  .historico-year-detail > summary { min-height: 54px; }
  .historico-comparison-detail > summary { grid-template-columns: 14px minmax(0, 1fr); }
  .historico-comparison-detail-meta { display: none; }
  .historico-comparison-detail-copy small { white-space: normal; }
  .historico-table-context,
  .historico-table-notes { grid-template-columns: 1fr; gap: 5px; }
  .historico-table-notes p:nth-child(3) { grid-column: auto; }
  .historico-footer { align-items: flex-start; flex-wrap: wrap; }
  .historico-footer nav { width: 100%; margin: 8px 0 0; gap: 18px; }
}

/* ── Histórico: os ciclos ancorados em hoje ─────────────────────────────── */
/* Uma tabela é a página. Linhas: a carteira, cada papel, e embaixo as réguas
   (CDI, IPCA, Ibovespa). Colunas: 5 a 30 anos até a âncora. A cor de cada
   célula responde a pergunta que a pessoa faz ao olhar para ela — passou do
   CDI no mesmo ciclo, contado do mesmo jeito? */
.ciclos-conteudo { display: flex; flex-direction: column; gap: 34px; }
.ciclos-tabela { font-size: 13.5px; }
.ciclos-tabela th[scope="col"] { vertical-align: bottom; }
.ciclos-tabela th[scope="col"] button {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px; width: 100%;
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--text-secondary); text-align: right;
}
.ciclos-tabela th[scope="col"] button small { font-weight: 400; color: var(--text-muted); font-size: 10.5px; }
.ciclos-tabela th[scope="col"] button:hover { color: var(--text-primary); }
.ciclos-tabela th[scope="col"] button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.ciclos-tabela th.is-on button { color: var(--accent-ink); }
.ciclos-tabela td.is-on,
.ciclos-tabela th.is-on { background: var(--accent-soft); }
.ciclos-tabela td { padding-block: 9px; }
.ciclos-tabela td.is-acima { color: var(--success-text); }
.ciclos-tabela td.is-abaixo { color: var(--danger-text); }
.ciclos-tabela td.is-vazio { color: var(--text-muted); cursor: help; }
.ciclos-tabela .ciclos-carteira th,
.ciclos-tabela .ciclos-carteira td { border-bottom: 1px solid var(--border-strong); }
.ciclos-tabela .ciclos-carteira strong { font-size: 15px; }
/* As réguas embaixo, separadas por um fio mais forte e em tom secundário:
   são o termo de comparação, não o objeto. */
.ciclos-tabela .ciclos-referencias tr:first-child th,
.ciclos-tabela .ciclos-referencias tr:first-child td { border-top: 2px solid var(--border-strong); }
.ciclos-tabela .ciclos-referencias td { color: var(--text-secondary); }
.ciclos-tabela .ciclos-referencias tr:first-child td { color: var(--text-primary); font-weight: 600; }

.ciclos-tabela td small { font-weight: 400; }
.ciclos-tabela td small.is-parcial { color: var(--warning); }
/* O piso é número de verdade com uma ressalva: tom mais baixo e sublinhado
   pontilhado, que convida a passar o mouse e ler a ressalva. */
.ciclos-tabela td.is-piso { cursor: help; }
.ciclos-tabela td.is-piso:not(.is-acima) { color: var(--text-secondary); }
.ciclos-tabela td.is-piso > strong,
.ciclos-tabela td.is-piso { text-decoration: underline dotted color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 3px; }
.ciclos-grade { max-width: 860px; }

.ciclos-conta { display: grid; gap: 10px; margin: 0; max-width: 82ch; font-size: 13px; line-height: 1.6; }
.ciclos-conta > div { display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.ciclos-conta dt { color: var(--text-primary); font-weight: 600; }
.ciclos-conta dd { margin: 0; color: var(--text-secondary); }
@media (max-width: 640px) {
  .ciclos-conta > div { grid-template-columns: 1fr; gap: 2px; }
}

/* O acumulado do período, embaixo da taxa ao ano no ciclo aberto. */
.ciclos-grade .ciclos-periodo { display: block; margin-top: 2px; font-size: 11px; font-weight: 500; color: var(--text-muted); }

/* Juro e inflação, mês a mês. A série comparada (Selic, IGP-M) na cor da casa, o IPCA no tom de alerta —
   é o que corrói —, e as faixas de juro real negativo quase apagadas ao fundo:
   contexto, não protagonista. */
.historico-grafico .serie.outra { stroke: var(--accent); }
.historico-grafico .serie.ipca { stroke: var(--danger); stroke-width: 1.5; }
.historico-grafico .serie.fina { stroke-width: 1.1; }
.historico-grafico rect.neg { fill: var(--danger); opacity: .09; }
.historico-grafico .cursor { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; }
.historico-grafico .cursor-ponto { fill: var(--surface-1); stroke-width: 2; }
.historico-grafico .cursor-ponto.outra { stroke: var(--accent); }
.historico-grafico .cursor-ponto.ipca { stroke: var(--danger); }
.historico-grafico .mensal-alvo { cursor: crosshair; }
.historico-grafico .sw.outra { background: var(--accent); }
.historico-grafico .sw.ipca { background: var(--danger); }
.historico-grafico .sw.neg { background: var(--danger); opacity: .18; width: 10px; height: 10px; border-radius: 2px; }
