/* ==========================================================================
   Tema noturno global (phase-3) — paleta do Diário aplicada a TODAS as rotas.
   O Diário já acerta porque seu CSS roda dentro do shadow DOM. Aqui levamos
   o mesmo tratamento ao light DOM. Carrega por último (index.html) e usa
   !important para vencer as cores escuras do approvedExact.css/identity.css.

   NUNCA mexer no login: o fundo dele é forçado claro em toda fase.
   NUNCA inverter .nav, .button primário ou .pill: já são claros sobre escuro.
   ========================================================================== */

/* 1) Tokens: corrige de uma vez todo componente que já consome variáveis. */
#app.phase-3 {
  --locali-ink:#f4f5e9;
  --locali-muted:#e2ebdf;
  --locali-paper:#122c3a;
  --pet-deep:#f4f5e9;
  
  --exact-copy:#f4f5e9;
  --exact-forest:#f4f5e9;
  --exact-navy:#f4f5e9;
  
  --position-ink:#f4f5e9;
  --position-muted:#e2ebdf;
}

/* 2) Títulos, eyebrows e rótulos sobre o céu escuro. */
#app.phase-3 .approved-heading>span,
#app.phase-3 .approved-heading h1,
#app.phase-3>main.approved-route-protecao .approved-heading>span,
#app.phase-3>main.approved-route-protecao .approved-heading h1,
#app.phase-3 .protection-assets-heading h2,
#app.phase-3 .shell[data-locali-route] .title,
#app.phase-3 .shell[data-locali-route] .page-heading h1,
#app.phase-3 .shell[data-locali-route] > h1,
#app.phase-3 .shell[data-locali-route] .section-title,
#app.phase-3 .pet-privacy-screen .page-heading h1 { color:#f4f5e9!important; }

/* 3) Parágrafos, contagens e notas de rodapé. */
#app.phase-3 .approved-heading p,
#app.phase-3>main.approved-route-protecao .approved-heading p,
#app.phase-3 .protection-assets-count,
#app.phase-3 .shell[data-locali-route] .page-heading .muted,
#app.phase-3 .shell[data-locali-route] .title + .muted,
#app.phase-3 .shell[data-locali-route] .footnote,
#app.phase-3 .pet-privacy-screen > .page-heading .muted { color:#e2ebdf!important; }

/* 4) Marca / wordmark (Diário: texto #f4f5e9, "care" #bacbbb). */
#app.phase-3 .top .brand,
#app.phase-3 .pet-privacy-screen .brand { color:#f4f5e9!important; }
#app.phase-3 .brand em { color:#bacbbb!important; }

/* 5) Posição / cards de ativo. */
#app.phase-3 .position-card-body,
#app.phase-3 .position-card-body>.pet-home-name,
#app.phase-3 .position-register-copy,
#app.phase-3 .position-register-copy strong { color:#f4f5e9!important; }
#app.phase-3 .position-meta-row,
#app.phase-3 .position-meta-row>.line-icon,
#app.phase-3 .position-register-copy small { color:#e2ebdf!important; }
#app.phase-3 .position-asset-card>.card-arrow,
#app.phase-3 .position-register-arrow { color:#ffffff!important; }
#app.phase-3 .position-asset-card,
#app.phase-3 .position-register-toggle { background:rgba(12,38,50,.62)!important; }

/* 6) Proteção. */
#app.phase-3 .protection-asset-card,
#app.phase-3 .protection-card,
#app.phase-3 .pet-identity,
#app.phase-3 .protection-history,
#app.phase-3 .pet-profile-details {
  background:rgba(12,38,50,.62)!important;
  border-color:rgba(255,255,255,.22)!important;
}
#app.phase-3 .protection-asset-copy strong,
#app.phase-3 .protection-asset-photo,
#app.phase-3 .pet-details-heading h2,
#app.phase-3 .pet-details-row strong,
#app.phase-3 .pet-identity-copy h2 { color:#f4f5e9!important; }
#app.phase-3 .protection-asset-copy small,
#app.phase-3 .protection-asset-arrow,
#app.phase-3 .pet-identity-copy .muted,
#app.phase-3 .pet-details-row span,
#app.phase-3 .pet-details-heading p { color:#e2ebdf!important; }

/* 7) Perfil / Configurações — bloco consolidado com alta especificidade.
   O approvedExact.css força cards brancos opacos (!important) e fontes
   mistas. Aqui usamos #app + .shell.pet-glass-profile para vencer e
   padronizar TUDO: mesma paleta do Diário e a fonte única (--font-ui). */
#app.phase-3 #app>.shell.pet-glass-profile[data-locali-route="configuracoes"],
#app.phase-3 .shell.pet-glass-profile[data-locali-route] {
  --profile-ink:#f4f5e9;
  --profile-muted:#e2ebdf;
  --profile-glass:rgba(12,38,50,.62);
  color:#f4f5e9!important;
  font-family: var(--font-ui);
}

/* TODOS os cards/agrupamentos do Perfil: fundo escuro uniforme. */
#app.phase-3 .approved-route-perfil .approved-controls .profile-card.exact-profile-main,
#app.phase-3 .approved-route-perfil .approved-controls :is(.settings-row,.card),
#app.phase-3 .shell.pet-glass-profile[data-locali-route] > .card,
#app.phase-3 .shell.pet-glass-profile[data-locali-route] :is(.profile-preferences,.profile-account) > .card,
#app.phase-3 .approved-route-perfil .approved-controls :is(.card,.profile-card,.profile-preferences,.profile-notifications,.profile-account,.settings-row){
  background:rgba(12,38,50,.62)!important;
  border:1px solid rgba(255,255,255,.22)!important;
  box-shadow:0 6px 20px rgba(0,0,0,.18)!important;
  color:#f4f5e9!important;
  font-family: var(--font-ui);
}

/* Texto: mesma cor e fonte em qualquer título, rótulo, valor ou ajuda. */
#app.phase-3 .shell.pet-glass-profile[data-locali-route] :is(h1,h2,h3,h4,p,label,strong,small,span,summary,.title,.profile-group-title),
#app.phase-3 .approved-route-perfil .approved-controls :is(h2,h3,p,label,strong,small,span,summary),
#app.phase-3 .approved-route-perfil .approved-controls>.profile-notifications .notif-copy strong,
#app.phase-3 .approved-route-perfil .approved-controls>.profile-account label,
#app.phase-3 .profile-card.exact-profile-main>div strong,
#app.phase-3 .settings-copy strong,
#app.phase-3 .notif-copy strong,
#app.phase-3 h2.profile-group-title,
#app.phase-3 .profile-preferences label,
#app.phase-3 .profile-account label,
#app.phase-3 .profile-photo-details>summary,
#app.phase-3 .shell.pet-glass-profile[data-locali-route] .title{
  color:#f4f5e9!important;
  font-family: var(--font-ui);
}

/* Textos secundários (ajudas, metadados, muted). */
#app.phase-3 .shell.pet-glass-profile[data-locali-route] :is(.muted,p,.profile-card .muted,.page-heading .muted),
#app.phase-3 .profile-card .muted,
#app.phase-3 .profile-preferences p,
#app.phase-3 .settings-copy small,
#app.phase-3 .notif-copy small,
#app.phase-3 .profile-photo-details small{
  color:#e2ebdf!important;
  font-family: var(--font-ui);
}

/* Campos de formulário: fundo escuro + texto claro, sem sumir. */
#app.phase-3 .approved-route-perfil .approved-controls :is(input,select,.field),
#app.phase-3 .shell.pet-glass-profile[data-locali-route] :is(input,select,.field){
  background:rgba(255,255,255,.10)!important;
  color:#f4f5e9!important;
  border-color:rgba(255,255,255,.28)!important;
  font-family: var(--font-ui);
}
#app.phase-3 .approved-route-perfil .approved-controls input::placeholder{color:#cbd9d2!important}

/* Links e ícones de ação do Perfil. */
#app.phase-3 .approved-route-perfil .approved-controls>.profile-account .settings-row .line-icon{
  color:#7fe0b8!important;
}
#app.phase-3 .shell.pet-glass-profile[data-locali-route] a,
#app.phase-3 .approved-route-perfil .approved-controls a{
  color:#7fe0b8!important;
}

/* 8) Mapa: escurece toolbar/card e clareia o texto junto. */
#app.phase-3 .unified-map-toolbar,
#app.phase-3 .unified-map-sheet {
  background:rgba(12,38,50,.82)!important;
  border-color:rgba(255,255,255,.22)!important;
}
#app.phase-3 .unified-map-label,
#app.phase-3 .unified-map-filter,
#app.phase-3 .unified-map-reset,
#app.phase-3 .unified-map-sheet-copy strong,
#app.phase-3 .unified-map-sheet-copy small,
#app.phase-3 .unified-map-sheet-action,
#app.phase-3 .unified-map-sheet-arrow,
#app.phase-3 .unified-map-empty { color:#f4f5e9!important; }

/* 9) Privacidade: botão Voltar sobre o céu escuro. */
#app.phase-3 .pet-privacy-screen > .button.secondary {
  color:#f4f5e9!important;
  background:rgba(12,38,50,.55)!important;
  border-color:rgba(255,255,255,.35)!important;
}

/* 10) Pistas: manter cabeçalho próprio claro, clarear só texto sobre vidro. */
#app.phase-3 .shell[data-locali-route="pistas"]{
  --clue-ui-deep:#f4f5e9;
  --clue-ui-muted:#e2ebdf;
  --clue-ui-glass:rgba(12,38,50,.62);
  --clue-ui-border:rgba(255,255,255,.22);
}
#app.phase-3 .shell[data-locali-route="pistas"] :is(.clue-control,.clue-metric small,.clue-evidence time,.clue-evidence p,.clue-evidence small,.clue-summary p,.clue-map-status,.clue-map-caption,.clue-print-status){color:#e2ebdf!important;}

/* 11) Rodapés / assinaturas. */
#app.phase-3 .pettycare-footer-brand,
#app.phase-3 .pettycare-footer-brand strong,
#app.phase-3 .pettycare-signature,
#app.phase-3 .pettycare-signature span { color:#f4f5e9!important; }

/* 12) Botões secundários (exceto login, que é claro). */
#app.phase-3:not(:has(.login-react-host)):not(:has(.admin-shell)) .button.secondary {
  color:#f4f5e9!important;
  background:rgba(12,38,50,.5)!important;
  border-color:rgba(255,255,255,.35)!important;
}

/* 13) Gráficos, barras e números — legíveis sobre cartões escuros. */
#app.phase-3 .bar { color:#e2ebdf!important; }
#app.phase-3 .bars {
  background-image:repeating-linear-gradient(to top,transparent 0,transparent 39px,rgba(255,255,255,.10) 40px)!important;
}
#app.phase-3 .bar i,
#app.phase-3 .shell[data-locali-route="painel"] .bar i { background:linear-gradient(#7fd9c2,#2fa28f)!important; }
#app.phase-3 .stat strong,
#app.phase-3 .pet-ntc-latest,
#app.phase-3 .diary-chart-reading,
#app.phase-3 .pet-hourly-selection { color:#f4f5e9!important; }
#app.phase-3 .pet-ntc-grid-line { stroke:rgba(255,255,255,.22)!important; }
#app.phase-3 .pet-ntc-axis-label,
#app.phase-3 .diary-axis-label,
#app.phase-3 .pet-hourly-label { fill:#e2ebdf!important; }
#app.phase-3 .pet-ntc-point,
#app.phase-3 .diary-signal-bar,
#app.phase-3 .pet-hourly-bar { fill:#3aa78f!important;stroke:#f4f5e9!important; }
#app.phase-3 .pet-ntc-details,
#app.phase-3 .pet-ntc-note { color:#e2ebdf!important; }
#app.phase-3 .diary-ntc-dot { fill:#e8a06a!important; }
#app.phase-3 .diary-bar-count { fill:#f4f5e9!important; }

/* FIM — login permanece intencionalmente de fora. */


/* Perfil noturno: as opções de Aparência e Conta não são cartões
   independentes; pertencem ao mesmo painel, como Notificações por e-mail.
   Mantém o céu automático e os textos claros da fase noturna. */
#app.phase-3 .shell.pet-glass-profile[data-locali-route] .profile-react-host>.profile-settings-panel>details.card{
  background:transparent!important;
  background-image:none!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  -webkit-backdrop-filter:none!important;
  backdrop-filter:none!important;
}
#app.phase-3 .shell.pet-glass-profile[data-locali-route] .profile-react-host>.profile-settings-panel>details.card+details.card{
  border-top:1px solid rgba(255,255,255,.18)!important;
}
#app.phase-3 .shell.pet-glass-profile[data-locali-route] .profile-react-host>.profile-settings-panel>details.card>summary.settings-row{
  background:transparent!important;
  border:0!important;
  box-shadow:none!important;
  -webkit-backdrop-filter:none!important;
  backdrop-filter:none!important;
}
#app.phase-3 .shell.pet-glass-profile[data-locali-route] .profile-react-host>.profile-settings-panel>.profile-group-title{
  color:#f4f5e9!important;
}

/* 10) Card grande do ativo no Mapa: segue o tema do sistema.
   De dia permanece o vidro claro de approvedExact.css; à noite adota a
   mesma superfície escura dos outros cards do mapa, com texto legível. */
#app.phase-3>main.unified-map-page .asset-detail-sheet{
  background:rgba(12,38,50,.92)!important;
  border-color:rgba(255,255,255,.22)!important;
  color:#f4f5e9!important;
}
#app.phase-3>main.unified-map-page .asset-detail-sheet :is(
  .asset-detail-name,.asset-detail-address,.asset-detail-times,
  .asset-detail-battery,.asset-detail-tag,.asset-detail-stats strong,
  .asset-detail-stats small,.asset-detail-activity,.asset-detail-prefs,
  .asset-detail-state,.asset-detail-timeline li,.asset-detail-tech li,
  .asset-detail-alerts li,.asset-detail-section h3,
  .asset-detail-loading,.pettilove-toggle,.pettilove-body,
  .pettilove-summary,.pettilove-note,.pettilove-finding span,
  .pettilove-finding small,.pettilove-limitations li,
  .pettilove-recommendations li,.pettilove-period
){color:#f4f5e9!important}
#app.phase-3>main.unified-map-page .asset-detail-sheet .muted,
#app.phase-3>main.unified-map-page .asset-detail-sheet :is(
  .asset-detail-address,.asset-detail-times,.asset-detail-stats small,
  .asset-detail-activity,.asset-detail-prefs,.asset-detail-state
){color:#e2ebdf!important}
#app.phase-3>main.unified-map-page .asset-detail-sheet :is(
  .asset-detail-head-actions button,.asset-detail-actions button,
  .pettilove-refresh
){
  background:rgba(255,255,255,.1)!important;
  color:#dff0e8!important;
  border-color:rgba(255,255,255,.28)!important;
}
#app.phase-3>main.unified-map-page .asset-detail-sheet .asset-detail-section{
  border-top-color:rgba(255,255,255,.18)!important;
}
#app.phase-3>main.unified-map-page .asset-detail-sheet .asset-detail-grab{
  background:rgba(223,240,232,.4)!important;
}
/* reduced-transparency: sólido escuro consistente na noite */
@media(prefers-reduced-transparency:reduce){
  #app.phase-3>main.unified-map-page .asset-detail-sheet{background:#122c3a!important}
}

/* Cards claros compartilhados, inclusive portais montados fora de #app. */
html body:is(body,#pettycare-card-theme) :is(#app [aria-modal="true"],.asset-detail-sheet,.positions-map-card,dialog[open]) .positions-simulation-controls{
 background:#f8fcfc!important;color:#204956!important;
}
html body:is(body,#pettycare-card-theme) :is(#app [aria-modal="true"],.asset-detail-sheet,.positions-map-card,dialog[open]) :is(.asset-detail-close,.lost-dialog-close){
 box-sizing:border-box!important;appearance:none!important;display:grid!important;place-items:center!important;
 width:44px!important;min-width:44px!important;max-width:44px!important;height:44px!important;min-height:44px!important;
 flex:0 0 44px!important;padding:0!important;margin:0!important;border:0!important;border-radius:50%!important;
 background:#e5efef!important;color:#204956!important;font:500 22px/1 'DM Sans',sans-serif!important;box-shadow:none!important;
}
html body:is(body,#pettycare-card-theme) :is(#app [aria-modal="true"],.asset-detail-sheet,.positions-map-card,dialog[open]) :is(.asset-detail-close,.lost-dialog-close):focus:not(:focus-visible){outline:none!important}
html body:is(body,#pettycare-card-theme) :is(#app [aria-modal="true"],.asset-detail-sheet,.positions-map-card,dialog[open]) :is(.asset-detail-close,.lost-dialog-close):focus-visible{outline:2px solid #247c70!important;outline-offset:3px!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .positions-simulation-controls{background:#f8fcfc!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .unified-protection-detail>.page-heading p,
html body:is(body,#pettycare-card-theme) #app.phase-3 .unified-protection-detail>.approved-heading p,
html body:is(body,#pettycare-card-theme) #app.phase-3 .unified-protection-detail>.pet-chooser :is(span,small),
html body:is(body,#pettycare-card-theme) #app.phase-3 .unified-protection-detail>.muted{color:#edf6f5!important}
/* Preserve readable text on white surfaces and on the night sky separately. */
html body:is(body,#pettycare-card-theme) #app.phase-3 main .approved-heading p{color:#edf6f5!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 main:is(.unified-protection-detail,.unified-protection-page)>.page-heading :is(p,.muted),
html body:is(body,#pettycare-card-theme) #app.phase-3 main:is(.unified-protection-detail,.unified-protection-page) .pet-chooser-item :is(span,small){color:#edf6f5!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 main.unified-protection-detail>.pet-context :is(p,span){color:#edf6f5!important}
/* Secondary route actions always sit on the light route panel. */
html body:is(body,#pettycare-card-theme) :is(#app [aria-modal="true"],.asset-detail-sheet) .asset-detail-route-result button{color:#204956!important;background:#fff!important;border:1px solid #a9c6c1!important;opacity:1!important}
/* Avoid transformed/backdrop-containing blocks moving the iOS input caret. */
html body:is(body,#pettycare-card-theme) #app .positions-map-card:focus-within{transform:none!important;left:16px!important;right:16px!important;top:max(12px,env(safe-area-inset-top))!important;bottom:auto!important;width:auto!important;margin:0 auto!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;max-height:calc(100dvh - 24px)!important}
html body:is(body,#pettycare-card-theme) #app .positions-simulation-point input{box-sizing:border-box!important;line-height:1.4!important;min-height:44px!important;caret-color:#204956!important;scroll-margin:20px!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .shell[data-locali-route="pistas"] :is(.clue-summary,.clue-metric,.clue-selected-asset,.card){background:#f8fcfc!important;color:#204956!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .shell[data-locali-route="pistas"] :is(.clue-summary,.clue-metric,.clue-selected-asset,.card) :is(h2,h3,p,small,strong,span){color:#204956!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .shell[data-locali-route="pistas"] .clue-paper{background:#f8fcfc!important;color:#204956!important}
html body:is(body,#pettycare-card-theme) #app.phase-3 .shell[data-locali-route="pistas"] .clue-paper :is(h2,h3,p,small,strong,span){color:#204956!important}
