/* Viva Design System — tokens adapted from the brand's styles.css.
   Existing variable names are kept as aliases so the rest of this
   stylesheet doesn't need a line-by-line rewrite; .topbar/.tabbar (the
   "menu de cima") are intentionally left as literal hex values below,
   untouched by this token swap. */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500&family=Jost:wght@400;500;600&display=swap');

:root {
  /* Brand constants — identical in both themes, never swapped */
  --navy: #0B1B2E;
  --terracota: #C45A3D;
  --ocre: #D4A574;
  --green: #3D6B4E;
  --red: #A4453A;
  --radius: 6px;
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Surface/text tokens — DARK is the default (see #theme-toggle in app.js);
     [data-theme="light"] below overrides these for the light alternative.
     Dark mode reuses the brand's own "superfície inversa" (navy ground +
     creme-on-navy text scale) — not an invented palette. */
  --bg: #0B1B2E;
  --panel: #142943;
  --panel-strong: #1c3a5c;
  --panel-strong-text: #F4F3F0;
  --border: rgba(244, 243, 240, 0.16);
  --border-hairline: rgba(244, 243, 240, 0.09);
  --text: rgba(244, 243, 240, 0.92);
  --muted: rgba(244, 243, 240, 0.58);
  --hover-bg: rgba(244, 243, 240, 0.06);
  --active-fill: var(--terracota);
  --active-text: #ffffff;
  --input-bg: #0f2136;
  --active-tint-bg: rgba(196, 90, 61, 0.14);
  --blue: var(--active-fill); /* legacy alias — many rules below still reference var(--blue) */
}

:root[data-theme="light"] {
  --bg: #F4F3F0;
  --panel: #ffffff;
  --panel-strong: var(--navy);
  --panel-strong-text: #ffffff;
  --border: rgba(11, 27, 46, 0.14);
  --border-hairline: rgba(11, 27, 46, 0.08);
  --text: rgba(11, 27, 46, 0.88);
  --muted: rgba(11, 27, 46, 0.55);
  --hover-bg: rgba(11, 27, 46, 0.04);
  --active-fill: var(--navy);
  --active-text: #ffffff;
  --input-bg: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

/* "Menu de cima" (topbar + tabbar): frozen to its original literal colors —
   intentionally NOT wired to the Viva Design System tokens below, per
   request ("esse está bonito do jeito que está"). */
.topbar {
  background: #0b0f2b;
  color: white;
  padding: 18px 28px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.brand { font-weight: 700; font-size: 20px; }
.brand span { font-weight: 400; opacity: 0.75; }
.subtitle { color: #9aa3d9; font-size: 14px; }
.filters-toggle {
  margin-left: auto;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.tabbar {
  background: #141a3d;
  display: flex;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.tab-btn {
  border: none;
  background: transparent;
  color: #b7bce0;
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: white; }
.tab-btn.active { color: white; border-bottom-color: #2f5bff; }

.theme-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.theme-bar-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.theme-bar .segmented { width: auto; }
.theme-bar .seg-btn { flex: none; padding: 5px 14px; font-size: 12px; }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  align-items: start;
}
.content { min-width: 0; }
.table-scroll { max-width: 100%; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sub-abas (2º nível) — Análises e Emissor agrupam páginas que antes eram
   abas de 1º nível soltas. Visual mais discreto que o .tabbar principal,
   pra deixar claro que é um nível abaixo. */
.subtabbar {
  display: flex;
  gap: 4px;
  margin: -4px 0 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.subtab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.subtab-btn:hover { color: var(--text); }
.subtab-btn.active { color: var(--text); border-bottom-color: var(--terracota); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* Nível 3 (2026-09-18, a pedido — menu do Emissor estava carregado):
   Databases e Conferências agrupam várias sub-abas antigas debaixo de 1
   só, com esta navegação aninhada dentro do subtab-panel delas. Mesmo
   visual do nível 2, só um pouco mais discreto/recuado — classe própria
   (não reaproveita .subtab-btn/.subtab-panel) porque o listener global
   de clique do nível 2 (activateTab, ligado em .subtab-btn no boot) não
   pode disparar pra esses botões — eles têm sua própria lógica isolada
   (databasesGroup/conferenciasGroup), sem tocar em TAB_GROUPS/state.tab. */
.subsubtabbar {
  display: flex;
  gap: 4px;
  margin: 0 0 16px 2px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.subsubtab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.subsubtab-btn:hover { color: var(--text); }
.subsubtab-btn.active { color: var(--text); border-bottom-color: var(--terracota); }
.subsubtab-panel { display: none; }
.subsubtab-panel.active { display: block; }

/* Emissor — em construção, badge vermelho no próprio botão do menu. */
.wip-badge {
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Emissor > Report_DB_Short — tabela raw com filtro por coluna estilo Excel. */
.raw-table-scroll { max-height: 65vh; overflow: auto; position: relative; }
/* table.outlier-table (mais abaixo) tem "overflow: hidden" pra arredondar
   canto — mas isso vira o "contexto de scroll" do sticky do cabeçalho
   (th.raw-th abaixo), quebrando o freeze (achado pelo usuário, 2026-09-12:
   cabeçalho "congelado" não congelava de verdade). Sobrescreve aqui, com 2
   classes (maior especificidade que ".outlier-table" sozinho) — só afeta
   os raw viewers, que já rolam dentro de .raw-table-scroll mesmo. */
table.outlier-table.raw-table { overflow: visible; }
table.raw-table { font-size: 12px; white-space: nowrap; table-layout: fixed; }
table.raw-table th, table.raw-table td { overflow: hidden; text-overflow: ellipsis; }
table.raw-table th.raw-th { cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel-strong); color: var(--panel-strong-text); z-index: 1; padding-right: 14px; }
table.raw-table th.raw-th:hover { filter: brightness(1.15); }
table.raw-table th.raw-th-filtered { background: var(--terracota); }
table.raw-table th .sort-arrow { font-size: 9px; margin-left: 4px; opacity: 0.75; }
#re-conta-row { margin: 0 0 14px; }
.raw-th-filter-icon { opacity: .6; font-size: 10px; margin-left: 3px; }
.raw-pagination { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

/* Manutenção (Emissor) — tabela bespoke (não usa .raw-table, precisa de
   quebra de linha normal em Detalhes, que às vezes tem 2-3 linhas de
   explicação). Todo alinhamento à esquerda, exceto Custo/Custo Repassado
   (.col-num) — a pedido. */
table.manut-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.manut-table th, table.manut-table td { padding: 7px 9px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); white-space: normal; }
table.manut-table thead th { position: sticky; top: 0; background: var(--panel-strong); color: var(--panel-strong-text); z-index: 1; }
table.manut-table th.col-num, table.manut-table td.col-num { text-align: right; font-variant-numeric: tabular-nums; }
table.manut-table tr.empty-row td { text-align: center; color: var(--muted); padding: 18px 9px; }

/* Barrinha de redimensionar coluna (arrastar) — mesmo padrão do repo
   omie-viva (docs/pagadoria.html, #ledgerResultTable). */
.col-resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: col-resize; user-select: none; touch-action: none; z-index: 2; }
.col-resizer:hover, .col-resizer.resizing { background: rgba(255, 255, 255, 0.35); }

.raw-filter-panel {
  position: absolute;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 360px;
  max-height: calc(65vh - 20px);
  overflow-y: auto;
}
.raw-filter-panel-title { font-weight: 600; margin-bottom: 8px; font-size: 13px; }
.raw-filter-search { width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 6px 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--input-bg); color: var(--text); }
.raw-filter-options { max-height: 220px; overflow-y: auto; border: 1px solid var(--border-hairline); border-radius: var(--radius); padding: 4px 8px; margin-bottom: 8px; }
.raw-filter-option { display: block; font-size: 12.5px; padding: 3px 0; white-space: nowrap; }
.raw-filter-numeric { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.raw-filter-numeric input { width: 110px; padding: 6px 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--input-bg); color: var(--text); }
.raw-filter-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.raw-filter-panel-actions .print-btn { padding: 5px 10px; font-size: 12px; }

/* Painel lateral de reservas (Emissor > Report_DB_Short) — abre ao clicar em
   Receita de Acomodação / Receita de Limpeza / Total / OTAs Fee, mostrando as
   reservas do Database Revenue que compõem aquela célula (unidade+mês). Só
   uma instância global, mesmo padrão de "abrir painel lateral a partir de uma
   célula" usado no cash flow do repo omie-viva. */
.raw-cell-clickable { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.raw-cell-clickable:hover { background: var(--hover-bg); }
.reservas-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 60;
}
.reservas-backdrop.open { display: block; }
.reservas-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  max-width: 92vw;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
  z-index: 61;
  transition: right 0.2s ease;
  display: flex;
  flex-direction: column;
}
.reservas-panel.open { right: 0; }
.reservas-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.reservas-panel-title { font-weight: 700; font-size: 15px; }
.reservas-panel-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.reservas-panel-body { padding: 16px; overflow-y: auto; flex: 1; }
.reservas-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.reservas-table th, .reservas-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-hairline); text-align: left; }
.reservas-table th { background: var(--bg); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.reservas-table td.num, .reservas-table th.num { text-align: right; }
.reservas-table tr.reservas-total td { font-weight: 700; background: var(--panel-strong); color: var(--panel-strong-text); }

.page-toolbar {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.field.inline { margin-bottom: 0; min-width: 200px; }

/* Filtros rápidos (Building/Unidade/Proprietário/Tipo Contrato/Code) — só
   em Report_DB_Short, Database Revenue e Database Custos Operacionais, a
   pedido (2026-09-12): "os mais utilizados", em ADIÇÃO ao filtro por
   coluna estilo Excel já existente (que continua igual, célula a célula).
   Cada select aqui só reaproveita filters[col] internamente — mesmo
   mecanismo, UI mais rápida pros 5 campos mais usados. */
.quick-filters { display: flex; gap: 12px; flex-wrap: wrap; margin: -4px 0 14px; }
.quick-filters .field.inline { min-width: 160px; }
.quick-filters label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.quick-filters select { width: 100%; padding: 6px 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font-size: 13px; }

.filters.dimmed { opacity: 0.35; pointer-events: none; }
.filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.filters h2 { margin: 0 0 12px; font-family: var(--font-body); font-weight: 600; font-size: 10px; color: var(--terracota); text-transform: uppercase; letter-spacing: .25em; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .count { font-weight: 400; color: var(--muted); }

select, input[type="text"] {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
}
input[type="text"] { margin-bottom: 6px; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg-btn {
  flex: 1; padding: 8px 16px; border: none; background: var(--panel); cursor: pointer; font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.seg-btn:not(:last-child) { border-right: 1px solid var(--border); }
.seg-btn.active { background: var(--blue); color: var(--active-text); border-color: var(--blue); }

.multiselect { display: flex; flex-wrap: wrap; gap: 6px; }
.multiselect.scroll { max-height: 160px; overflow-y: auto; flex-wrap: nowrap; flex-direction: column; }
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.multiselect.scroll .chip { border-radius: 6px; text-align: left; }
.chip.active { background: var(--blue); border-color: var(--blue); color: var(--active-text); }
/* Chip "excluído" (Saldos de Implantação e Exit) — inverso do .active: aqui
   marcado significa "tirado da análise", não "incluído". Visual bem
   diferente (esmaecido + riscado) pra não confundir com o padrão do resto
   do site. */
.chip.excluded { background: transparent; border-color: var(--border-hairline); color: var(--muted); text-decoration: line-through; opacity: 0.65; }

.clear-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.clear-btn:hover { background: var(--hover-bg); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.stat .value { font-family: var(--font-display); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; }
.stat .delta { font-size: 12px; margin-top: 2px; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--red); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.meta-row { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.section-title { font-family: var(--font-body); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .25em; color: var(--terracota); margin: 26px 0 10px; }
.hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }

/* Fonte dos dados (2026-09-18, a pedido) — linha discreta, estilo código,
   em toda página do site: qual JSON/CSV alimenta a tela, pra facilitar a
   comunicação via chat ("de qual tabela estamos falando"). Sempre logo
   abaixo do .hint de descrição (ou do título, quando não há .hint) e
   acima da toolbar/tabela — mesma posição em toda página, sem exceção.
   Fonte monoespaçada do sistema (sem carregar Google Font extra) —
   ui-monospace cobre San Francisco Mono no Mac, Segoe UI Mono no Windows. */
.data-source-tag { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 11px; font-style: italic; color: var(--muted); opacity: 0.65; margin: 2px 0 14px; }
.data-source-tag code { background: var(--input-bg); padding: 1px 5px; border-radius: 3px; font-style: normal; }

/* Aba Releases (2026-09-16): central de PDFs mensais de resultado, um card
   por release, agrupados por tipo (Institucional/Individual/...). */
.releases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 8px; }
.release-card {
  display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: inherit; transition: border-color .15s, background .15s;
}
.release-card:hover { border-color: var(--active-fill); background: var(--hover-bg); }
.release-title { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.release-desc { font-size: 12px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; }
.release-meta { font-size: 10.5px; color: var(--terracota); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

.dre-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.dre-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-hairline);
  cursor: default;
}
.dre-row:last-child { border-bottom: none; }
.dre-row:hover { background: var(--hover-bg); }

.dre-row.subtotal {
  background: var(--panel-strong);
  color: var(--panel-strong-text);
  font-weight: 700;
  font-size: 15px;
}
.dre-row.subtotal:hover { filter: brightness(1.15); }

.dre-row.detail { padding-left: 36px; font-size: 13px; color: var(--muted); }
.dre-row.perf .amount { color: var(--blue); font-weight: 600; }
.dre-row.perf .label { color: var(--blue); }
.dre-row.light { background: var(--hover-bg); }

.dre-row .label { display: flex; align-items: center; gap: 6px; }
.dre-row .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.dre-row.detail .amount { font-weight: 500; }

.info-dot {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: .55;
}

.breakdown-toggle {
  font-size: 11.5px; color: var(--blue); cursor: pointer; margin-left: 8px; text-decoration: underline;
}
.sub-breakdown {
  padding: 4px 20px 8px 44px;
  font-size: 12px;
  color: var(--muted);
  display: none;
  background: var(--hover-bg);
}
.sub-breakdown.open { display: block; }

.tooltip {
  position: fixed;
  max-width: 280px;
  background: var(--navy);
  color: #e8eaf7;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .1s ease;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tooltip.show { opacity: 1; }

.footnote {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}
.footnote a { color: var(--blue); }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* Evolução Mensal / Comparativo tables */
.table-scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
/* Congela a linha de cabeçalho (meses) ao rolar a tabela — pedido 2026-09-16.
   `thead th { position: sticky; top: 0 }` já existia, mas só "gruda" de
   verdade dentro de um contêiner que realmente rola (overflow-y: auto +
   altura limitada) — sem isso, .table-scroll cresce pra caber tudo e quem
   rola é a página inteira, então o cabeçalho sobe junto. Classe própria (não
   a .table-scroll genérica) pra não mudar o comportamento das outras
   tabelas que reusam essa classe. */
.table-scroll-sticky-header { max-height: 70vh; overflow-y: auto; }

/* Y-o-Y (Evolução Mensal, 2026-09-16): tabela da esquerda (Indicador + mês de
   referência) e tabela da direita (comparações Y-o-Y) lado a lado, com um
   espaço visual entre as duas — duas tabelas de verdade, não uma coluna
   vazia dentro de uma tabela só (pedido explícito do usuário). Quebra pra
   coluna única em telas estreitas, já que lado a lado não cabe. */
.evo-yoy-wrap { display: flex; align-items: flex-start; gap: 32px; }
.evo-yoy-wrap .table-scroll { flex: 0 0 auto; }
.evo-yoy-left { min-width: 320px; }
.evo-yoy-right th, .evo-yoy-right td { text-align: right; }
.evo-yoy-right td.yoy-up { color: var(--green); }
.evo-yoy-right td.yoy-down { color: var(--red); }
@media (max-width: 900px) {
  .evo-yoy-wrap { flex-direction: column; }
}
table.evo-table, table.cmp-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}
.evo-table th, .evo-table td, .cmp-table th, .cmp-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-hairline);
}
.evo-table th:first-child, .evo-table td:first-child,
.cmp-table th:first-child, .cmp-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--panel);
  min-width: 220px;
  z-index: 1; /* fica acima das células normais do corpo, mas abaixo do cabeçalho */
}
.evo-table thead th, .cmp-table thead th {
  background: var(--panel-strong);
  color: var(--panel-strong-text);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2; /* acima das células da 1ª coluna do corpo quando ambos ficam "sticky" na mesma área visível */
}
/* Canto superior-esquerdo (sticky nos dois eixos ao mesmo tempo) precisa do
   maior z-index de todos — senão a 1ª coluna do corpo (z-index:1) desenha
   por cima do cabeçalho (z-index:2 já cobre isso, mas o canto herdaria só
   um dos dois sem essa regra explícita, causando ele "sumir" atrás da 1ª
   coluna ao rolar verticalmente — bug relatado 2026-09-16). */
.evo-table thead th:first-child, .cmp-table thead th:first-child { background: var(--panel-strong); z-index: 3; }
.evo-table td.avg-col, .evo-table th.avg-col { border-left: 2px solid var(--blue); background: var(--active-tint-bg); font-weight: 700; }
.evo-table tr.subtotal td { background: var(--panel-strong); color: var(--panel-strong-text); font-weight: 700; }
.evo-table tr.subtotal td:first-child { background: var(--panel-strong); }
.evo-table tr.detail td:first-child { padding-left: 28px; color: var(--muted); font-weight: 400; }
.evo-table tr.group td:first-child { font-weight: 700; }
.evo-table tr.section-gap td { border-bottom: none; padding: 8px 0; }
.evo-table tr.evo-expandable { cursor: pointer; }
.evo-table tr.evo-expandable:hover td { background: var(--hover-bg); }

.cmp-table tr.lvl-city td:first-child { font-weight: 700; }
.cmp-table tr.lvl-building td:first-child { padding-left: 26px; }
.cmp-table tr.lvl-unit td:first-child { padding-left: 46px; color: var(--muted); font-size: 12.5px; }
.cmp-table .expand-toggle, .evo-table .expand-toggle { cursor: pointer; margin-right: 6px; display: inline-block; width: 14px; color: var(--blue); font-weight: 700; }
.cmp-table tr.hidden { display: none; }

.chart-legend { display: flex; gap: 18px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }

/* Sidebar de filtros: visibilidade controlada via JS (style.display inline),
   igual em qualquer largura de tela — ver #filters-toggle em app.js. Aqui só
   o layout/posicionamento muda por breakpoint. */
.layout.filters-collapsed { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 880px) {
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .tabbar { padding: 0 8px; }
  .tab-btn { padding: 12px 12px; font-size: 12.5px; }

  .layout { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 14px; }
  body { overflow-x: hidden; }

  .filters { position: static; max-height: none; }

  .stat-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .stat .value { font-size: 17px; }

  .page-toolbar { gap: 12px; }
  .field.inline { min-width: 140px; }

  .dre-row { padding: 10px 14px; font-size: 13px; flex-wrap: wrap; }
  .dre-row.detail { padding-left: 26px; }
  .dre-row.subtotal { font-size: 13.5px; }
  .dre-row.subtotal .label { flex-basis: 100%; }
  .dre-row.subtotal .amount { width: 100%; text-align: right; margin-top: 2px; }
  .stat .label { font-size: 12px; }

  table.evo-table, table.cmp-table { font-size: 12px; }
  .evo-table th, .evo-table td, .cmp-table th, .cmp-table td { padding: 6px 9px; }
  .evo-table td:first-child, .cmp-table td:first-child,
  .evo-table th:first-child, .cmp-table th:first-child { min-width: 150px; }

  .chart-wrap { padding: 8px; }
}

/* Despesas Real Estate (Análises) */
.hint-inline { font-size: 12.5px; font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: normal; }

.outlier-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 8px;
}
.outlier-grid > div { min-width: 0; }
.outlier-subtitle { font-size: 13px; margin: 0 0 8px; }
.outlier-subtitle.up { color: var(--red); }
.outlier-subtitle.down { color: var(--green); }

/* Precisa vir DEPOIS da regra base acima — @media não aumenta especificidade
   CSS, então se essa regra viesse antes (como estava, dentro do bloco de
   breakpoint no topo do arquivo) a regra base sempre ganhava e a grade
   nunca colapsava para 1 coluna no mobile, em nenhuma largura de tela. */
@media (max-width: 880px) {
  .outlier-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Receita Viva (Take Rate) — seções em acordeão, todas fechadas por padrão */
.trs-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.trs-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.trs-header:hover { background: var(--hover-bg); }
.trs-chevron { color: var(--terracota); transition: transform .15s ease; font-size: 13px; }
.trs-section.open .trs-chevron { transform: rotate(180deg); }
.trs-body { display: none; padding: 0 20px 20px; }
/* ">" (filho direto), não descendente — com subseção aninhada
   (.trs-subsection dentro do .trs-body da seção-mãe), o seletor descendente
   "vazava": a seção-mãe aberta forçava TODA .trs-body aninhada a aparecer,
   inclusive a da subseção fechada. Achado pelo usuário em Despesas Real
   Estate (2026-09-11) — IPTU/Energia/etc. não recolhiam ao clicar. */
.trs-section.open > .trs-body { display: block; }

/* Subseção (ex.: Despesas Real Estate > Internet/Energia/IPTU/...) — mesmo
   acordeão, só recuado e com cabeçalho mais discreto pra marcar o nível. */
.trs-subsection { margin: 0 0 10px; border-style: dashed; }
.trs-subsection .trs-header { padding: 10px 16px; font-size: 13.5px; font-weight: 600; }
.trs-subsection .trs-body { padding: 0 16px 16px; }

.r2-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 12px;
}

/* Resultados - PropCo: um bloco de tabela por variável */
.propco-category-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  color: var(--text);
  margin: 32px 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.propco-category-title:first-child { margin-top: 8px; }
.propco-var-block { margin-bottom: 22px; }
.propco-var-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  margin: 0 0 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.propco-var-unit { font-size: 11.5px; color: var(--muted); font-weight: 400; text-transform: none; }
.cmp-table tr.lvl-total td { background: var(--panel-strong); color: var(--panel-strong-text); font-weight: 700; }
.cmp-table tr.lvl-total td:first-child { background: var(--panel-strong); }
.cmp-table tr.empty-row td { text-align: center; color: var(--muted); padding: 18px; }

.propco-detail-toggle {
  font-size: 12.5px;
  color: var(--blue);
  cursor: pointer;
  margin: 0 0 10px;
  display: inline-block;
}
.propco-detail-group { display: none; padding-left: 16px; border-left: 2px solid var(--border); margin-bottom: 14px; }
.propco-detail-group.open { display: block; }
.propco-detail-group .propco-var-title { font-size: 12.5px; color: var(--muted); }

/* Conferências — badge de status no cabeçalho de cada check, visível sem
   precisar abrir a seção. */
.check-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-left: 10px;
}
.check-badge.ok { background: rgba(61, 107, 78, 0.15); color: var(--green); }
.check-badge.warn { background: rgba(164, 69, 58, 0.15); color: var(--red); }
.check-badge.attention { background: rgba(212, 165, 116, 0.22); color: var(--ocre); }
.check-description { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.conf-status-filter { margin-top: -4px; }

/* Emissor > Índice — Etapas de Emissão (lista numerada) e Lembretes por
   Prédio (bullets dentro do acordeão .trs-section reaproveitado). */
.etapas-list { margin: 0 0 26px; padding-left: 22px; }
.etapas-list li { margin-bottom: 8px; line-height: 1.5; }
.bldnote-list { margin: 0; padding-left: 20px; }
.bldnote-list li { margin-bottom: 10px; line-height: 1.5; }
.bldnote-list li:last-child { margin-bottom: 0; }
.bldnote-list code { background: var(--input-bg); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.bldnote-list ul { margin: 8px 0 0; padding-left: 18px; }
.bldnote-list ul li { margin-bottom: 6px; }
/* Tabela "Unidades emitidas por Prédio" — agrupada por cidade (2026-09-14). */
.units-city-header td { font-weight: 600; color: var(--ocre); background: var(--hover-bg); padding-top: 10px; cursor: pointer; user-select: none; }
.units-city-header .trs-chevron { display: inline-block; transition: transform 0.15s; }
.units-city-header:not(.open) .trs-chevron { transform: rotate(-90deg); }
.units-subtotal td { font-weight: 600; border-top: 1px solid var(--border); }
.units-grandtotal td { font-weight: 700; color: var(--terracota); border-top: 2px solid var(--border); }

/* Conferências — checks "grouped" (Novas Unidades, Top Line = Zero) mostram
   uma subtabela por mês dentro da mesma seção. */
.conf-group { margin-bottom: 18px; }
.conf-group:last-child { margin-bottom: 0; }
.conf-group-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--ocre);
  margin: 0 0 8px;
}
.conf-group-footer {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  margin: 8px 0 0;
}
/* Total geral do check (não por subtabela) — Saldos de Implantação e Exit
   soma o Saldo em Aberto de todos os Tipos de Operação juntos. */
.conf-grand-footer {
  font-size: 14px;
  font-weight: 700;
  color: var(--ocre);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 16px;
}

table.outlier-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.outlier-table th, .outlier-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}
.outlier-table th:first-child, .outlier-table td:first-child,
.outlier-table th:nth-child(2), .outlier-table td:nth-child(2) { text-align: left; }
.outlier-table thead th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 12px; }
.outlier-table tbody tr:last-child td { border-bottom: none; }
.outlier-table tbody tr:hover { background: var(--hover-bg); }
.outlier-table .unit-cell { color: var(--muted); font-size: 12px; }
.dev-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}
.dev-chip.up { background: rgba(164, 69, 58, 0.12); color: var(--red); }
.dev-chip.down { background: rgba(61, 107, 78, 0.12); color: var(--green); }
.empty-row td { text-align: center; color: var(--muted); padding: 18px; }

/* Versão Impressão (PDF) */
.print-btn {
  padding: 8px 16px;
  border: 1px solid var(--active-fill);
  background: var(--active-fill);
  color: var(--active-text);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.print-btn:hover:not(:disabled) { filter: brightness(1.12); }
.print-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#print-hint { margin-top: -6px; margin-bottom: 12px; }
#print-hint.ok { color: var(--green); }

#print-area { display: none; }

@media print {
  /* Chrome/Safari/Firefox descartam cor de fundo e imagens ao imprimir por
     padrão ("economia de tinta"), a menos que a página peça explicitamente
     para manter — sem isso o PDF sai todo branco/preto, sem nenhum traço do
     brandbook (creme de fundo, faixa navy do subtotal, badge terracota,
     marca d'água), mesmo com as cores certas definidas no CSS abaixo. */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html, body { background: #F4F3F0 !important; }
  body > *:not(#print-area) { display: none !important; }
  .tooltip { display: none !important; }
  #print-area { display: block !important; }

  @page { size: A4; margin: 14mm 16mm; }

  /* Versão Impressão — Viva Design System aplicado (creme de fundo, navy
     estrutural, Newsreader para o título, Jost pro resto), sempre nesses
     tons independente do tema claro/escuro escolhido no app. */
  .print-page {
    position: relative;
    font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #0B1B2E;
    background: #F4F3F0 !important;
  }
  .print-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 70%;
    max-width: 480px;
    transform: translate(-50%, -50%) rotate(-12deg);
    opacity: 0.05;
    z-index: -1;
  }
  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 0.5px solid rgba(11, 27, 46, 0.2);
  }
  .print-logo { height: 30px; width: auto; }
  .print-title { text-align: right; }
  .print-title h1 { font-family: 'Newsreader', Georgia, serif; font-weight: 400; font-size: 19px; margin: 0; color: #0B1B2E; }
  .print-title p { font-size: 11px; color: rgba(11, 27, 46, 0.55); margin: 3px 0 0; letter-spacing: .02em; }
  .print-scope-badge {
    display: inline-block;
    font-family: 'Jost', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #C45A3D !important;
    margin-bottom: 14px;
    letter-spacing: .25em;
    text-transform: uppercase;
  }
  table.print-dre { width: 100%; border-collapse: collapse; font-size: 12px; }
  table.print-dre td { padding: 5px 6px; border-bottom: 0.5px solid rgba(11, 27, 46, 0.15); }
  table.print-dre td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
  table.print-dre tr.subtotal td { background: #0B1B2E !important; color: #F4F3F0 !important; font-weight: 500; }
  table.print-dre tr.detail td:first-child { padding-left: 18px; color: rgba(11, 27, 46, 0.6); font-weight: 400; }
  table.print-dre tr.detail td:last-child { font-weight: 400; }
  table.print-dre tr.detail-sub td:first-child { padding-left: 30px; color: rgba(11, 27, 46, 0.5); font-size: 11px; }
  table.print-dre tr.detail-sub td:last-child { font-size: 11px; font-weight: 400; }

  /* Versão Detalhada: mais linhas (Outros aberto + grade de KPIs) — tudo
     precisa caber numa folha só, então a tabela encolhe um pouco mais que a
     Versão Limpa pra abrir espaço pros indicadores no fim da página. */
  .print-page-detailed table.print-dre { font-size: 10.5px; }
  .print-page-detailed table.print-dre td { padding: 3px 6px; }
  .print-page-detailed table.print-dre tr.detail-sub td:first-child,
  .print-page-detailed table.print-dre tr.detail-sub td:last-child { font-size: 9.5px; }

  .print-kpis-title {
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: rgba(11, 27, 46, 0.55);
  }
  .print-kpis-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .print-kpi {
    border: 0.5px solid rgba(11, 27, 46, 0.15);
    border-radius: 4px;
    padding: 5px 7px;
  }
  .print-kpi-label { font-size: 8px; color: rgba(11, 27, 46, 0.55); line-height: 1.25; margin-bottom: 2px; }
  .print-kpi-value { font-family: 'Newsreader', Georgia, serif; font-size: 13px; font-weight: 500; color: #0B1B2E; }

  /* Relatório de Manutenção — mesmo Design System do print-dre acima, só
     com uma tabela larga (Unidade/Tipo/Especificidade/Fornecedor/Custo/
     Detalhes) em vez do resumo de 2 colunas. Detalhes sempre por último e
     com mais largura de propósito — texto às vezes com 2-3 linhas de
     explicação, table-layout:fixed junto com o <colgroup> do JS garante
     que essa largura extra realmente sobra pra ela em vez de encolher. */
  .print-manut-meta { display: flex; gap: 28px; margin-bottom: 14px; }
  .print-manut-meta > div { display: flex; flex-direction: column; gap: 2px; }
  .print-manut-meta span { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: rgba(11, 27, 46, 0.5); }
  .print-manut-meta strong { font-family: 'Newsreader', Georgia, serif; font-weight: 500; font-size: 14px; color: #0B1B2E; }
  table.print-manut { width: 100%; border-collapse: collapse; font-size: 10.5px; table-layout: fixed; }
  table.print-manut th, table.print-manut td { padding: 5px 6px; text-align: left; vertical-align: top; border-bottom: 0.5px solid rgba(11, 27, 46, 0.15); word-wrap: break-word; white-space: pre-wrap; }
  table.print-manut thead th { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: rgba(11, 27, 46, 0.55); font-weight: 600; border-bottom: 1px solid rgba(11, 27, 46, 0.3); }
  table.print-manut th.num, table.print-manut td.num { text-align: right; font-variant-numeric: tabular-nums; }
  table.print-manut tfoot td { border-top: 1px solid rgba(11, 27, 46, 0.3); border-bottom: none; font-weight: 600; padding-top: 7px; }

  .print-footer {
    position: absolute;
    bottom: -8mm;
    left: 0;
    right: 0;
    font-size: 9px;
    color: rgba(11, 27, 46, 0.45);
    text-align: center;
    letter-spacing: .04em;
    border-top: 0.5px solid rgba(11, 27, 46, 0.15);
    padding-top: 6px;
  }
}

/* Dropdown multi-select (Prédio) — compact combobox instead of a wall of chips */
.dropdown-ms { position: relative; }
.dropdown-ms-toggle {
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input-bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.dropdown-ms-toggle::after { content: "▾"; float: right; color: var(--muted); }
.dropdown-ms-toggle:hover { border-color: var(--active-fill); }
.dropdown-ms-panel {
  display: none;
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 260px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 8px;
}
.dropdown-ms-panel.show { display: block; }
.dropdown-ms-search {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 6px;
  background: var(--input-bg);
  color: var(--text);
}
.dropdown-ms-options { max-height: 240px; overflow-y: auto; }
.dropdown-ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.dropdown-ms-option:hover { background: var(--hover-bg); }
.dropdown-ms-option input { accent-color: var(--active-fill); }
