/* ── BUG-01 fix: remove padding-top fantasma e gap de phantoms ────────
   Causa: 7 stElementContainers height:0 + gap nativo 16px do
   stVerticalBlock flex-column = 112px + padding .stMainBlockContainer
   ~48px = ~160px de espaço preto antes da topbar.
   Solução canônica KB streamlit-native-reference §5.1 + §2.
   Testid estável até Streamlit 1.55 (ref: KB §4).
   NOTA: Emotion cache .st-emotion-cache-* define padding via classe com
   especificidade (0,1,0). Nosso seletor duplo (classe + testid) = (0,2,0)
   vence sem depender de nome de classe frágil. */
.stMainBlockContainer[data-testid="stMainBlockContainer"] {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  /* #2 fix: remove padding lateral p/ topbar sticky ocupar 100% do viewport.
     Streamlit emotion injeta padding:6rem 1rem 10rem no .block-container —
     esse recuo lateral impede o <header.arh-topnav> de atingir as bordas da tela.
     O conteúdo de página recupera o espaçamento via .arh-page-content (padding:24px 20px). */
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ── SP-01 v4 (fix definitivo 2026-05-09): gap zero canônico no rootVBlock ──
   HISTÓRICO DE FALHAS:
   - SP-01 v1/v2: `iframe[height="0"]` — Streamlit 1.55 NÃO escreve atributo
     height no DOM (getAttribute retorna null). Seletor nunca casava. KB §3.
   - SP-01 v3: `:has([height="0"])` — mesmo problema: atributo inexistente no DOM.
     Lógica invertida também falhou: stVerticalBlock raiz NÃO tem filhos com
     height="0" explícito → nenhuma regra aplicava, gap 16px persistia,
     gerando 7×16=112px de gap fantasma acima da topbar.
   SOLUÇÃO CANÔNICA: zerar gap direto no rootVBlock.
   Gap entre componentes de conteúdo é provido por padding interno de cada
   wrapper de página (.arh-page-content: padding 24px 20px; mon-wrapper, dir-*,
   cfg-* têm seus próprios espaçamentos internos).
   Ref: KB streamlit-native-reference.md §5.1 aprovado rh-manager 2026-05-04. */
.block-container > [data-testid="stVerticalBlock"] {
  gap: 0 !important;
}

/* ── T-01 fix (terceiro loop 2026-05-08): canvas surface-base em TODAS as camadas DOM ──
   Problema: .stApp + .stAppViewContainer cobertos mas stMain + stMainBlockContainer
   recebem background de [data-baseweb] rules com especificidade maior — light mode
   exibia fundo #0a1320 (dark) em 87-93% das telas (V-02 gate reprovado).
   Fix: cobrir todas as 4 camadas Streamlit (ref: INVENTARIO-MASTER §ANEXO-B).
   Dark: #111C28 | Light: #F8F7F4 (tokens canônicos design_tokens.py).
   Topbar invariante #16202E: NÃO é afetada (topbar usa --topbar-bg, não stApp).
   body adicionado no quinto loop (2026-05-08): garante cobertura em path direto /bi
   (sessão nova via bookmark) onde config.toml escreve rgb(10,19,32) no body antes
   do inject_main_styles() do app_shell.py:115 ser aplicado. */
body,
[data-testid="stApp"],
[data-testid="stAppViewContainer"],
[data-testid="stMain"],
[data-testid="stMainBlockContainer"] {
  background: var(--surface-base) !important;
  color: var(--text-primary) !important;
}

/* stHeader oculto — substituído pelo topnav Onda 2 (FIX-2 Story 1.1) */
[data-testid="stHeader"],
header[data-testid="stHeader"],
div[data-testid="stHeader"],
.stApp > header { display: none !important; }

/* ── STATUS-KILL: suprime o running man (stStatusWidget) nativo em TODOS os reruns ──
   O boot screen (_render_loading_screen, boot.py) já escondia o running man no boot;
   esta regra estende a supressão ao app shell — nos reruns o boneco reaparecia porque
   a regra não vinha no CSS principal (o legacy app.py:264-300 a tinha). Reusa o modelo
   de carregamento JÁ DEFINIDO na refundação. NÃO inclui div[role="status"] (bate em
   arh-toast-global / loading-bar do monitoramento) nem stSpinner (loading v2). */
[data-testid="stStatusWidget"],
[data-testid="stStatusWidgetContainer"],
[data-testid="stStatusWidgetRunning"],
[data-testid="stRunningWidget"],
.stApp [class*="StatusWidget"],
.stApp [class*="RunningIcon"],
.stApp [class*="stRunning"],
.stRunningGif,
.stRunningGifBicycle,
button[title="Stop"] { display: none !important; visibility: hidden !important; pointer-events: none !important; }

/* ── NAV-01: Ocultar sidebar nativa Streamlit ──────────────────────────
   Navegação via topnav customizada (.arh-topnav). Sidebar não faz parte
   do design aprovado — nunca foi discutida nem modelada.
   Streamlit 1.55 multipage gera sidebar com testid stSidebarNav* automaticamente
   mesmo com st.navigation(position='hidden'). Cobertura ampliada 2026-05-09. */
[data-testid="stSidebar"],
[data-testid="stSidebarNav"],
[data-testid="stSidebarNavItems"],
[data-testid="stSidebarNavLink"],
[data-testid="stSidebarNavSeparator"],
[data-testid="stSidebarHeader"],
[data-testid="stSidebarContent"],
[data-testid="stSidebarUserContent"],
[data-testid="stSidebarCollapseButton"],
[data-testid="stSidebarCollapsedControl"],
[data-testid="collapsedControl"],
section[data-testid*="Sidebar" i],
section[data-testid*="sidebar" i],
.stSidebar {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
}

/* Garante que o conteúdo principal ocupe 100% sem deslocamento da sidebar */
[data-testid="stAppViewContainer"] > .main,
[data-testid="stAppViewContainer"] > section.main,
.main {
  margin-left: 0 !important;
  width: 100% !important;
}

/* ── ANTI-SCROLL-HORIZONTAL: fullbleed 100vw × scrollbar clássica ──────
   PROBLEMA (report Matias 2026-07-14 — notebook empresa 1366×768): barra de
   rolagem horizontal em resoluções menores. CAUSA RAIZ: o topnav
   (pages/_internal/topnav.py L70) usa a técnica fullbleed canônica
   `width:100vw; margin-left:calc(50% - 50vw)`. `100vw` INCLUI a largura da
   scrollbar vertical; em sistemas com scrollbar CLÁSSICA (Windows — não
   overlay), a área útil encolhe ~17px e a borda direita do topnav ultrapassa
   o scroller → barra horizontal fantasma. NÃO é bug de conteúdo (0 offenders
   genuínos no Painel BI). NÃO é específico de 1366 — atinge qualquer sistema
   com scrollbar clássica; 1366×768 só expõe mais (menos altura → scroll
   vertical quase sempre presente).

   Confirmado em runtime 2026-07-14: stMain (o scroller real, overflow:auto)
   fica com scrollWidth 1361 > clientWidth 1356 = 5px de bleed do topnav
   SEMPRE presente, mesmo em overlay (invisível no dev, visível no Windows).

   FIX GERAL (independente de resolução — NÃO calibrado p/ 1366): clipar o
   overflow HORIZONTAL no scroller (stMain) e nos ancestrais full-width. O
   vertical (overflow-y:auto) e o position:sticky do topnav ficam INTACTOS —
   stMain segue sendo o scroll container. Tabelas largas usam overflow-x:auto
   PRÓPRIO (containers aninhados) → continuam roláveis internamente.
   Compatível com scroll-lock do calendário (calendario_ui.py: seletor
   html.arh-cal-open [data-testid=stMain] tem especificidade maior e vence).
   Validado runtime: sticky OK (top=0 @scroll400), vertical OK, scrollbar
   horizontal eliminada, topnav full-bleed sem regressão. */
[data-testid="stMain"] {
  overflow-x: hidden !important;
}
[data-testid="stApp"],
[data-testid="stAppViewContainer"] {
  overflow-x: clip;
}

/* ── SCROLLBAR-ABAIXO-DO-MENU (Matias 2026-07-16) ─────────────────────
   REPORT: a barra de rolagem VERTICAL da página corria por cima do topnav.
   CAUSA: o scroller real é o stMain (overflow-y:auto), e seu box ia de y:0→vh;
   o topnav (.arh-topnav) ficava DENTRO do stMain, preso via wrapper sticky
   (topnav.py L81-84). Logo a scrollbar do stMain ocupava a altura toda —
   inclusive atrás do menu (y:0→56).
   PEDIDO: a barra deve NASCER ABAIXO do menu, sem cruzá-lo.
   FIX: tirar o topnav do fluxo de scroll (sticky→fixed, pinado no topo do
   viewport) e baixar o TOPO do stMain em 56px (= altura fixa do topnav,
   topnav.py L52), reduzindo a altura na mesma medida. Assim a scrollbar do
   stMain passa a ocupar só y:56→vh. Supersede o sticky do topnav.py (o
   wrapper sticky vira container 0-height inofensivo no topo do stMain).
   Pré-condição verificada em runtime 2026-07-16: nenhum ancestral do topnav
   tem transform/filter/perspective → position:fixed pina no viewport (não
   vira ancestral-relativo). topnav opaco (--topbar-bg) cobre o conteúdo que
   rola por baixo. Validado runtime: Geral (overflow 120) → scrollbar em y:56,
   topnav estável @scroll, conteúdo em y:56 sem corte; 27" idêntico (só muda
   ONDE a barra começa, não a geometria). !important vence o topnav.py (que
   injeta DEPOIS no DOM mas usa position:sticky SEM !important em .arh-topnav).
   ⚠ Se a altura do topnav mudar (topnav.py L52 = 56px), atualizar os 56px aqui. */
.arh-topnav {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  margin-left: 0 !important;
  z-index: 1000 !important;
}
[data-testid="stMain"] {
  margin-top: 56px !important;
  height: calc(100vh - 56px) !important;
  max-height: calc(100vh - 56px) !important;
}

/* ── Layout: Page content wrapper (proto-A linhas 238-243) ─────────── */
.arh-page-content {
  font-family: var(--font-sans);
  color: var(--text-primary);
  padding: 24px 20px;
  max-width: 1400px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.5;
}

/* Page header com breadcrumb (proto-A linhas 246-271) */
.arh-page-header {
  margin-bottom: 20px;
}
.arh-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.arh-breadcrumb span {
  color: var(--text-primary);
  font-weight: 500;
}
.arh-breadcrumb-sep {
  color: var(--text-muted);
  user-select: none;
}
.arh-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.arh-page-title-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--state-success);
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.20);
}
.arh-page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Kicker (label discreto sobre títulos) — não está no proto-A,
   mas é padrão presente no projeto (KB §5.2 :has marker pattern) */
.arh-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Page transition — fade-in ao navegar entre abas (Story 2.4.3)
   Final Touch #1 · design-system-final.md §1
   150ms ease-out: sweet spot entre perceptível (100ms) e lentidão (200ms).
   opacity-only: evita jitter com reflow nativo do Streamlit. ── */
@keyframes arhPageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.main .block-container {
  animation: arhPageFadeIn 150ms ease-out;
}

/* Respeita prefers-reduced-motion (AC7 · WCAG 2.3.3 AAA) */
@media (prefers-reduced-motion: reduce) {
  .main .block-container {
    animation: none;
  }
}

/* NO-TITLE: Oculta heading nativo Streamlit — topbar pill identifica a tela (decisão 2026-05-09) */
[data-testid="stHeadingWithActionElements"] {
  display: none !important;
}
