/* Nexo — campos mobile sem o zoom automático do Safari.
   Não restringir viewport/user-scalable: zoom manual permanece disponível. */
@media (max-width:800px) {
  html body input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="file"],[type="color"],[type="button"],[type="submit"],[type="reset"]),
  html body textarea,
  html body select,
  html body [contenteditable="true"],
  html body #app#app#app#app#app input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="file"],[type="color"],[type="button"],[type="submit"],[type="reset"]),
  html body #app#app#app#app#app textarea,
  html body #app#app#app#app#app select,
  html body #modal#modal#modal#modal#modal input:not([type="hidden"],[type="checkbox"],[type="radio"],[type="range"],[type="file"],[type="color"],[type="button"],[type="submit"],[type="reset"]),
  html body #modal#modal#modal#modal#modal textarea,
  html body #modal#modal#modal#modal#modal select {
    font-size:16px!important;
  }
  /* A mesma progressão do menu lateral, iniciada junto da abertura.
     O blur acontece no conteúdo real, não surge atrasado no ::backdrop. */
  html body > .shell,
  html body > .mobile-dock {
    transition:filter var(--overlay-time,310ms) var(--expand-ease,cubic-bezier(.22,.72,.24,1));
  }
  html body:has(> dialog#modal[open]) > .shell,
  html body:has(> dialog#modal[open]) > .mobile-dock,
  html body:has(> dialog#nexo-feedback[open]) > .shell,
  html body:has(> dialog#nexo-feedback[open]) > .mobile-dock,
  html body:has(> dialog.category-overview-dialog[open]) > .shell,
  html body:has(> dialog.category-overview-dialog[open]) > .mobile-dock,
  html body:has(> dialog#about-nexo[open]) > .shell,
  html body:has(> dialog#about-nexo[open]) > .mobile-dock,
  html body:has(> dialog#install-nexo[open]) > .shell,
  html body:has(> dialog#install-nexo[open]) > .mobile-dock {
    filter:blur(var(--overlay-blur,9px));
  }
  /* A mesma gaveta de 70% de Nova Transação para formulários centrais:
     Família, Metas, Dívidas, Cadastros e demais formulários compartilhados.
     A área interna rola; a página de fundo não recebe mudanças de layout. */
  html body dialog#modal#modal[open]:not(:has(#form[data-finance-type="transaction"])),
  html body dialog#nexo-feedback#nexo-feedback[open],
  html body dialog#about-nexo#about-nexo[open],
  html body dialog#install-nexo#install-nexo[open],
  html body dialog.category-overview-dialog[open] {
    position:fixed!important;
    inset:auto 0 0 0!important;
    box-sizing:border-box!important;
    display:block!important;
    width:min(100%,560px)!important;
    min-width:0!important;
    max-width:100%!important;
    height:70dvh!important;
    min-height:0!important;
    max-height:calc(100dvh - 20px)!important;
    margin:0 auto!important;
    padding:26px 20px calc(22px + env(safe-area-inset-bottom,0px))!important;
    border:0!important;
    border-radius:27px 27px 0 0!important;
    background:#fff!important;
    box-shadow:0 -14px 45px rgba(30,45,64,.10)!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
    scrollbar-width:thin;
  }
  html body dialog#modal#modal[open]:not(:has(#form[data-finance-type="transaction"]))::before {
    content:"";
    display:block;
    width:36px;
    height:4px;
    border-radius:999px;
    background:#c8d5e0;
    margin:-14px auto 19px;
  }
  /* Exceção: o filtro mobile já tem animação e visual aprovados. */
  html body > dialog:is(#modal,#nexo-feedback,#about-nexo,#install-nexo,.category-overview-dialog)[open]::backdrop {
    background:rgba(34,60,83,.12)!important;
    -webkit-backdrop-filter:none!important;
    backdrop-filter:none!important;
  }
}
@media (max-width:800px) and (prefers-reduced-motion:no-preference) ,(max-width:800px) and (min-width:801px) {
  html body dialog#modal#modal[open]:not(:has(#form[data-finance-type="transaction"])),
  html body dialog#nexo-feedback#nexo-feedback[open],
  html body dialog#about-nexo#about-nexo[open],
  html body dialog#install-nexo#install-nexo[open],
  html body dialog.category-overview-dialog[open] {
    animation:nexo-mobile-sheet-rise 310ms cubic-bezier(.22,.72,.24,1) both!important;
  }
  html body > dialog:is(#modal,#nexo-feedback,#about-nexo,#install-nexo,.category-overview-dialog)[open]::backdrop {
    animation:nexo-mobile-backdrop-fade 310ms cubic-bezier(.22,.72,.24,1) both!important;
  }
  @keyframes nexo-mobile-sheet-rise {
    from { transform:translateY(100%);opacity:.96; }
    to { transform:translateY(0);opacity:1; }
  }
  @keyframes nexo-mobile-backdrop-fade {
    from {opacity:0}
    to {opacity:1}
  }
}
@media (max-width:800px) and (prefers-reduced-motion:reduce)  and (max-width:800px){
  html body dialog#modal#modal[open]:not(:has(#form[data-finance-type="transaction"])),
  html body dialog#nexo-feedback#nexo-feedback[open],
  html body dialog#about-nexo#about-nexo[open],
  html body dialog#install-nexo#install-nexo[open],
  html body dialog.category-overview-dialog[open] {
    animation:none!important;
  }
  html body > .shell,html body > .mobile-dock {transition:none!important}
}
@media (max-width:800px) and ((prefers-reduced-transparency:reduce) or (prefers-contrast:more)) {
  html body:has(> dialog#modal[open]) > .shell,
  html body:has(> dialog#nexo-feedback[open]) > .shell,
  html body:has(> dialog.category-overview-dialog[open]) > .shell {
    filter:none!important;
  }
  html body > dialog:is(#modal,#nexo-feedback,#about-nexo,#install-nexo,.category-overview-dialog)[open]::backdrop {
    background:rgba(34,60,83,.30)!important;
  }
}

/* Mobile sheet select/date menus must occupy their own place in the form flow.
   Fixed viewport coordinates were wrong inside the animated (transformed)
   70dvh dialog, placing "Parentesco" over E-mail and transaction choices
   over unrelated fields. The dialog and options each remain independently scrollable. */
@media (max-width:800px) {
  html body dialog#modal#modal#modal[open] #form#form .universal-picker.universal-picker > .control-menu.control-menu,
  html body dialog#modal#modal#modal[open] #form#form[data-finance-type] .universal-picker.universal-picker > .control-menu.control-menu,
  html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-picker.date-picker > .date-menu.control-menu {
    position:static!important;
    inset:auto!important;
    top:auto!important;
    bottom:auto!important;
    left:auto!important;
    right:auto!important;
    display:block!important;
    box-sizing:border-box!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    max-height:min(43dvh,350px)!important;
    margin:7px 0 0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
    float:none!important;
    clear:both!important;
  }
  html body dialog#modal#modal#modal[open] #form#form .universal-picker.universal-picker > .control-menu.control-menu > .control-options,
  html body dialog#modal#modal#modal[open] #form#form[data-finance-type] .universal-picker.universal-picker > .control-menu.control-menu > .control-options {
    box-sizing:border-box!important;
    max-height:min(31dvh,250px)!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }
  /* The opened picker expands its own grid row, moving following fields down. */
  html body dialog#modal#modal#modal[open] #form#form .universal-picker.universal-picker[open] {
    min-width:0!important;
    width:100%!important;
    height:auto!important;
    max-height:none!important;
    overflow:visible!important;
  }
}
/* All finance-form calendars match Nova Transação: content-fit without empty square space. */
@media(max-width:800px){
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-picker.date-picker>.date-menu.control-menu{
  display:grid!important;
  grid-template-rows:auto auto auto auto!important;
  aspect-ratio:auto!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  overflow:visible!important;
  gap:8px!important;
  padding:10px!important;
  animation:none!important;
 }
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-menu>.date-days{
  display:grid;
  grid-template-columns:repeat(7,minmax(0,1fr));
  grid-auto-rows:40px!important;
  min-height:0!important;
  gap:4px!important;
 }
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-days>button[data-date-value]{
  width:40px!important;
  height:40px!important;
  min-height:40px!important;
  padding:0!important;
  margin:auto!important;
 }
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-menu>.period-bottom{
  margin:0!important;
  padding:10px 12px 4px!important;
  align-items:center!important;
 }
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-picker>summary.control-trigger{align-items:center!important}
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-picker>summary.control-trigger>.period-indicator{
  display:flex!important;align-items:center!important;justify-content:center!important;align-self:center!important;margin:0!important;
 }
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-picker>summary.control-trigger>.period-indicator>svg.nexo-icon{
  display:block!important;margin:0!important;vertical-align:middle!important;transform:none!important;
 }
}
@media(max-width:360px){
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-menu>.date-days{grid-auto-rows:34px!important;gap:2px!important}
 html body dialog#modal#modal#modal#modal[open] #form#form#form[data-finance-type] .date-days>button[data-date-value]{width:34px!important;height:34px!important;min-height:34px!important}
}
