/* Frigoexpresso mobile hardening: Escritório + Controlo de Diesel */
#escritorio-app-shell *,#escritorio-app-shell *::before,#escritorio-app-shell *::after,
#diesel-app-shell *,#diesel-app-shell *::before,#diesel-app-shell *::after{box-sizing:border-box}
#escritorio-app-shell,#diesel-app-shell{width:100%;max-width:100%;overflow-x:hidden}
#escritorio-app-shell main,#escritorio-app-shell section,#escritorio-app-shell article,#escritorio-app-shell form,#escritorio-app-shell div,
#diesel-app-shell main,#diesel-app-shell section,#diesel-app-shell article,#diesel-app-shell form,#diesel-app-shell div{min-width:0}
#escritorio-app-shell img,#diesel-app-shell img{max-width:100%;height:auto}

@media (max-width:600px){
  html,body{-webkit-text-size-adjust:100%;text-size-adjust:100%;overflow-x:hidden!important;width:100%!important;max-width:100%!important}

  /*
   * ESCRITÓRIO — regras com maior especificidade porque a app injeta
   * ESCRITORIO_WIDE_CSS depois desta folha. Estas regras precisam ganhar
   * inclusive dos !important existentes no CSS interno.
   */
  html body #root #escritorio-app-shell{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow-x:hidden!important;
  }
  html body #root #escritorio-app-shell>header{
    width:100%!important;
    max-width:100%!important;
    min-height:auto!important;
    padding:10px max(12px,env(safe-area-inset-right)) 10px max(12px,env(safe-area-inset-left))!important;
    flex-direction:column!important;
    align-items:stretch!important;
    gap:8px!important;
  }
  html body #root #escritorio-app-shell>header>div{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
  }
  html body #root #escritorio-app-shell>header>div:last-child{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;
    gap:7px!important;
    align-items:stretch!important;
    justify-content:stretch!important;
  }
  html body #root #escritorio-app-shell>header>div:last-child>span,
  html body #root #escritorio-app-shell>header>div:last-child>button{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:40px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    text-align:center!important;
    white-space:normal!important;
    overflow-wrap:anywhere!important;
  }

  html body #root #escritorio-app-shell>main{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    padding:8px max(8px,env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))!important;
    overflow-x:hidden!important;
  }
  html body #root #escritorio-app-shell>main>section,
  html body #root #escritorio-app-shell>main>div,
  html body #root #escritorio-app-shell main section,
  html body #root #escritorio-app-shell main article,
  html body #root #escritorio-app-shell main form,
  html body #root #escritorio-app-shell main div{
    max-width:100%!important;
    min-width:0!important;
    box-sizing:border-box!important;
  }

  /* Todos os grids financeiros deixam de impor duas ou mais colunas no iPhone. */
  html body #root #escritorio-app-shell main [style*="grid-template-columns"]{
    grid-template-columns:minmax(0,1fr)!important;
  }

  /* Cabeçalhos/painéis que usam space-between passam a empilhar. */
  html body #root #escritorio-app-shell main [style*="justify-content: space-between"],
  html body #root #escritorio-app-shell main [style*="justify-content:space-between"]{
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:flex-start!important;
  }

  /* Cartões principais e hero ficam dentro do viewport. */
  html body #root #escritorio-app-shell main section[style*="background: white"],
  html body #root #escritorio-app-shell main section[style*="background:white"]{
    width:100%!important;
    max-width:100%!important;
    padding:14px!important;
    border-radius:14px!important;
  }
  html body #root #escritorio-app-shell main section[style*="linear-gradient"]{
    width:100%!important;
    max-width:100%!important;
    padding:18px 16px!important;
    border-radius:16px!important;
    align-items:stretch!important;
  }
  html body #root #escritorio-app-shell main section[style*="linear-gradient"] button{
    width:100%!important;
    min-height:44px!important;
  }

  /* Formulários e seletor da viagem. 16px evita zoom automático do Safari iOS. */
  html body #root #escritorio-app-shell input,
  html body #root #escritorio-app-shell select,
  html body #root #escritorio-app-shell textarea{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:44px!important;
    font-size:16px!important;
  }
  html body #root #escritorio-app-shell main [style*="min-width: min"],
  html body #root #escritorio-app-shell main [style*="min-width:min"]{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }

  /* Barras de ações e fecho passam a largura total. */
  html body #root #escritorio-app-shell main button{
    max-width:100%!important;
    min-height:42px!important;
    white-space:normal!important;
    overflow-wrap:anywhere!important;
  }
  html body #root #escritorio-app-shell main [style*="margin-left: auto"],
  html body #root #escritorio-app-shell main [style*="margin-left:auto"]{margin-left:0!important}
  html body #root #escritorio-app-shell main [style*="justify-content: flex-end"],
  html body #root #escritorio-app-shell main [style*="justify-content:flex-end"]{justify-content:flex-start!important}

  /* Valores e textos longos nunca empurram a largura dos cartões. */
  html body #root #escritorio-app-shell main article span,
  html body #root #escritorio-app-shell main article b,
  html body #root #escritorio-app-shell main article strong,
  html body #root #escritorio-app-shell main article div,
  html body #root #escritorio-app-shell main p,
  html body #root #escritorio-app-shell main h1,
  html body #root #escritorio-app-shell main h2,
  html body #root #escritorio-app-shell main h3{
    max-width:100%!important;
    overflow-wrap:anywhere!important;
    word-break:normal!important;
  }
  html body #root #escritorio-app-shell main article strong{
    font-size:clamp(15px,4.5vw,18px)!important;
  }

  /*
   * As tabelas devem deslizar DENTRO do cartão. O CSS interno da app punha
   * table-layout:fixed e min-width:0; aqui isso é explicitamente revertido.
   */
  html body #root #escritorio-app-shell main [style*="overflow-x: auto"],
  html body #root #escritorio-app-shell main [style*="overflow-x:auto"]{
    display:block!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-x:contain!important;
  }
  html body #root #escritorio-app-shell table{
    width:max-content!important;
    min-width:760px!important;
    max-width:none!important;
    table-layout:auto!important;
  }
  html body #root #escritorio-app-shell th,
  html body #root #escritorio-app-shell td{
    white-space:nowrap!important;
    overflow-wrap:normal!important;
    word-break:normal!important;
    padding-left:8px!important;
    padding-right:8px!important;
  }

  /* DIESEL */
  #diesel-app-shell>header{
    min-height:auto!important;
    padding:10px max(12px,env(safe-area-inset-right)) 10px max(12px,env(safe-area-inset-left))!important;
    flex-direction:column!important;
    align-items:stretch!important;
    gap:8px!important;
  }
  #diesel-app-shell>header>div{width:100%!important;min-width:0!important}
  #diesel-app-shell>header>div:last-child{
    display:flex!important;
    flex-wrap:wrap!important;
    justify-content:flex-start!important;
    align-items:center!important;
  }
  #diesel-app-shell main{
    width:100%!important;
    max-width:100%!important;
    padding:8px max(8px,env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))!important;
    margin:0!important;
    overflow-x:hidden!important;
  }
  #diesel-app-shell main [style*="grid-template-columns"]{grid-template-columns:minmax(0,1fr)!important}
  #diesel-app-shell main section,#diesel-app-shell main article,#diesel-app-shell main form{width:100%!important;max-width:100%!important;min-width:0!important}
  #diesel-app-shell main section[style*="background: white"],#diesel-app-shell main form[style*="background: white"]{padding:14px!important;border-radius:14px!important}
  #diesel-app-shell main section[style*="linear-gradient"]{padding:18px 16px!important;border-radius:16px!important;align-items:stretch!important}
  #diesel-app-shell input,#diesel-app-shell select,#diesel-app-shell textarea{width:100%!important;max-width:100%!important;min-width:0!important;font-size:16px!important}
  #diesel-app-shell button{max-width:100%!important;min-height:42px;white-space:normal;overflow-wrap:anywhere}
  #diesel-app-shell main section[style*="linear-gradient"] button{width:100%!important}
  #diesel-app-shell article span,#diesel-app-shell article b,#diesel-app-shell article strong,#diesel-app-shell article div{max-width:100%;overflow-wrap:anywhere}
  #diesel-app-shell [style*="overflow-x: auto"],#diesel-app-shell [style*="overflow-x:auto"]{width:100%!important;max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;overscroll-behavior-x:contain!important}
  #diesel-app-shell table{width:max-content!important;min-width:720px!important;table-layout:auto!important}
  #diesel-app-shell th,#diesel-app-shell td{white-space:nowrap!important}
}

@media (max-width:390px){
  html body #root #escritorio-app-shell>main,#diesel-app-shell main{padding-left:6px!important;padding-right:6px!important}
  html body #root #escritorio-app-shell>header>div:last-child{grid-template-columns:minmax(0,1fr)!important}
  html body #root #escritorio-app-shell main section[style*="background: white"],#diesel-app-shell main section[style*="background: white"]{padding:12px!important}
}
