/* PROFINANCE HUB V53.4 — modal safe-area hotfix
   Mantém o cabeçalho de modais sempre visível e impede que diálogos altos
   abram cortados no topo em desktops/notebooks. */
:root{--pf-modal-safe-top:82px;--pf-modal-safe-bottom:24px}

@media (min-width:721px){
  .overlay:not(.document-viewer-overlay){
    align-items:flex-start!important;
    overflow-y:auto!important;
    padding-top:calc(var(--pf-modal-safe-top) + env(safe-area-inset-top,0px))!important;
    padding-bottom:var(--pf-modal-safe-bottom)!important;
  }
  .overlay:not(.document-viewer-overlay)>.modal{
    max-height:calc(100dvh - var(--pf-modal-safe-top) - var(--pf-modal-safe-bottom) - 8px)!important;
    margin-top:0!important;
    margin-bottom:auto!important;
  }
  .overlay:not(.document-viewer-overlay)>.modal>.modal-header,
  .overlay:not(.document-viewer-overlay)>.modal>.modal-head{
    position:sticky!important;
    top:0!important;
    z-index:30!important;
    background:inherit!important;
  }

  .profile-overlay:not(.hidden),
  .welcome-email-overlay:not(.hidden),
  .access-edit-overlay:not(.hidden){
    align-items:flex-start!important;
    overflow-y:auto!important;
    padding-top:calc(var(--pf-modal-safe-top) + env(safe-area-inset-top,0px))!important;
    padding-bottom:var(--pf-modal-safe-bottom)!important;
  }
  .profile-overlay:not(.hidden)>.profile-panel,
  .welcome-email-overlay:not(.hidden)>.welcome-email-modal,
  .access-edit-overlay:not(.hidden)>.access-edit-modal{
    max-height:calc(100dvh - var(--pf-modal-safe-top) - var(--pf-modal-safe-bottom) - 8px)!important;
    margin-top:0!important;
    margin-bottom:auto!important;
  }
  .profile-modal-head,.welcome-email-head,.access-edit-head{
    position:sticky!important;
    top:0!important;
    z-index:30!important;
  }

  /* Prévia/envio da calculadora: preserva o desenho, mas garante a barra superior. */
  .pdf-modal.open{
    align-items:flex-start!important;
    overflow-y:auto!important;
    padding-top:18px!important;
    padding-bottom:18px!important;
  }
  .pdf-modal.open>.pdf-dialog{
    max-height:calc(100dvh - 36px)!important;
    height:min(92dvh,900px)!important;
    margin-bottom:auto!important;
  }
  .pdf-modal.open>.send-dialog{
    margin-top:0!important;
    margin-bottom:auto!important;
  }
  .pdf-dialog-head{position:sticky!important;top:0!important;z-index:30!important}
}

@media (max-width:720px){
  /* No mobile, deixa o próprio layout responsivo já existente controlar o modal. */
  .overlay:not(.document-viewer-overlay){scroll-padding-top:12px}
}
