/* Diário de Pressão — 25.8.1.1 | Hotfix estrutural mobile
   Fonte: capturas iPhone com cards em 3 colunas e cabeçalho sticky sobre conteúdo.
   Apenas apresentação; sem alterações em schema, Sync ou regras clínicas. */
@media screen and (max-width: 699px) {
  /* 1. Navegação contextual PARTICIPA DO FLUXO; não sobrepõe cartões rolados. */
  html.context-nav-visible #screenHead.show,
  #screenHead.show {
    position:relative!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important;
    transform:none!important;inset:auto!important;
    display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;
    align-items:center!important;justify-content:space-between!important;
    width:100%!important;min-width:0!important;max-width:100%!important;
    margin:0 0 12px!important;padding:11px 12px!important;
    min-height:66px!important;height:auto!important;
    border-radius:17px!important;z-index:1!important;
    overflow:visible!important;isolation:isolate!important;
  }
  html.context-nav-visible main.app {padding-top:16px!important}
  #screenHead>div:first-child {min-width:0!important;max-width:100%!important;overflow:hidden!important}
  #screenHead #screenKicker {
    display:block!important;max-width:100%!important;overflow:hidden!important;text-overflow:ellipsis!important;
    white-space:nowrap!important;font-size:.61rem!important;line-height:1.3!important;margin:0 0 3px!important;
  }
  #screenHead #screenTitle {display:block!important;max-width:100%!important;white-space:normal!important;overflow-wrap:normal!important;word-break:normal!important;font-size:1.18rem!important;line-height:1.18!important}
  #screenHead .nav-stack-actions {
    display:flex!important;flex-flow:row nowrap!important;align-items:center!important;justify-content:flex-end!important;
    flex:0 0 auto!important;gap:5px!important;width:auto!important;max-width:none!important;
    min-width:0!important;margin:0 0 0 6px!important;
  }
  #screenHead .nav-stack-actions>button:not([hidden]) {
    display:inline-flex!important;flex:0 0 39px!important;justify-content:center!important;align-items:center!important;
    width:39px!important;height:42px!important;min-width:39px!important;max-width:39px!important;
    min-height:42px!important;padding:0!important;margin:0!important;
    font-size:1.05rem!important;line-height:1!important;border-radius:12px!important;white-space:nowrap!important;
  }
  #screenHead .nav-stack-actions>button[hidden] {display:none!important}
  #screenHead .nav-back-label,#screenHead #goHome>span {display:none!important}
  /* Títulos e componentes nunca ficam sob a barra contextual. */
  main.app .app-page {scroll-margin-top:12px!important}
  main.app .grid {margin-top:0!important;align-items:start!important}
  main.app #settingsHub, main.app #historyHub {margin-top:0!important}

  /* 2. Histórico: UMA coluna real, cartão horizontal legível. */
  html body #historyHub .section-hub .section-hub-grid {
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-auto-flow:row!important;
    grid-auto-columns:minmax(0,1fr)!important;gap:9px!important;width:100%!important;max-width:100%!important;
    align-items:stretch!important;margin:0!important;padding:0!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button {
    display:grid!important;grid-template-columns:48px minmax(0,1fr) 14px!important;grid-template-rows:auto!important;
    align-items:center!important;justify-items:stretch!important;column-gap:12px!important;
    width:100%!important;min-width:0!important;max-width:100%!important;
    min-height:78px!important;height:auto!important;padding:12px 13px!important;
    text-align:left!important;border-radius:15px!important;overflow:visible!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button::after {
    content:'›'!important;display:block!important;position:static!important;
    color:var(--ui-muted,#737282)!important;font-size:1.55rem!important;line-height:1!important;justify-self:end!important;
    transform:none!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button>.section-hub-icon {
    grid-column:1!important;grid-row:1!important;
    display:grid!important;place-items:center!important;
    width:48px!important;height:48px!important;min-width:48px!important;max-width:48px!important;
    margin:0!important;padding:0!important;flex:none!important;border-radius:13px!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button>.section-hub-icon svg {
    width:23px!important;height:23px!important;max-width:23px!important;min-width:23px!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button>span:last-of-type {
    grid-column:2!important;grid-row:1!important;display:block!important;
    min-width:0!important;width:auto!important;max-width:100%!important;
    overflow:visible!important;white-space:normal!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button strong {
    display:block!important;min-width:0!important;max-width:100%!important;
    margin:0!important;color:var(--ui-text-strong,#2C2330)!important;
    font-size:.96rem!important;line-height:1.28!important;font-weight:850!important;
    white-space:normal!important;word-break:normal!important;overflow-wrap:normal!important;
    hyphens:none!important;letter-spacing:-.014em!important;
  }
  html body #historyHub .section-hub-grid>.section-hub-button>span:last-of-type>span {
    display:block!important;margin-top:4px!important;
    color:var(--ui-muted,#757587)!important;font-size:.74rem!important;line-height:1.4!important;
    white-space:normal!important;word-break:normal!important;overflow-wrap:normal!important;
  }
  #historyHub .section-hub {padding:0!important;background:transparent!important;border:0!important;box-shadow:none!important}
  #historyHub {overflow:visible!important}

  /* 3. Ajustes: lista de grupos com fluxo vertical sem camadas sobrepostas. */
  html body #settingsHub .settings-hub-grid,
  html body #settingsHub .v254-settings-grid {
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-auto-flow:row!important;
    align-items:start!important;gap:13px!important;width:100%!important;max-width:100%!important;
    margin:0!important;padding:0!important;
  }
  html body #settingsHub .settings-hub {background:transparent!important;border:0!important;padding:0!important;box-shadow:none!important}
  /* Título de Ajustes já aparece no cabeçalho contextual: sem duplicação. */
  html.context-nav-visible #settingsHub > h2 {display:none!important}
  #settingsHub .ui-settings-group {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:6px!important;min-width:0!important}
  #settingsHub .ui-settings-group-list {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:7px!important}
  #settingsHub .ui-settings-group h3 {margin:8px 2px 2px!important;font-size:.7rem!important;line-height:1.3!important;letter-spacing:.08em!important}
  html body #settingsHub .settings-hub-button {
    display:grid!important;grid-template-columns:42px minmax(0,1fr) 16px!important;gap:11px!important;
    align-items:center!important;width:100%!important;min-width:0!important;max-width:100%!important;
    min-height:70px!important;height:auto!important;margin:0!important;padding:11px 12px!important;
    border-radius:15px!important;overflow:visible!important;
  }
  #settingsHub .settings-hub-button>.settings-hub-icon {
    width:42px!important;height:42px!important;min-width:42px!important;max-width:42px!important;
    margin:0!important;border-radius:12px!important;display:grid!important;place-items:center!important;
  }
  #settingsHub .settings-hub-button>span:nth-child(2) {width:auto!important;min-width:0!important;overflow:visible!important}
  #settingsHub .settings-hub-button strong {font-size:.9rem!important;line-height:1.28!important;word-break:normal!important;overflow-wrap:normal!important;white-space:normal!important}
  #settingsHub .settings-hub-button>span:nth-child(2)>span {font-size:.72rem!important;line-height:1.38!important;word-break:normal!important;overflow-wrap:normal!important;white-space:normal!important}
  #settingsHub .v254-settings-search {display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;gap:8px!important;max-width:100%!important;margin-bottom:12px!important}
  #settingsHub .v254-settings-search>.field {min-width:0!important}

  /* 4. Rodapé: controles compactos, safe area somada uma só vez. */
  :root {--premium-nav-row:calc(60px + min(env(safe-area-inset-bottom),20px))}
  .app-shell-frame {grid-template-rows:auto minmax(0,1fr) var(--premium-nav-row)!important}
  .bottom-nav {
    grid-row:3!important;height:var(--premium-nav-row)!important;min-height:var(--premium-nav-row)!important;
    max-height:var(--premium-nav-row)!important;
    padding:3px max(4px,env(safe-area-inset-right)) min(env(safe-area-inset-bottom),20px) max(4px,env(safe-area-inset-left))!important;
    display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;align-items:start!important;
  }
  .bottom-nav a {height:54px!important;min-height:54px!important;max-height:54px!important;padding:3px 1px!important}
  .bottom-nav .nav-icon-box {width:31px!important;height:30px!important;min-height:30px!important}
  .bottom-nav .nav-label {font-size:.57rem!important;line-height:1.1!important;white-space:nowrap!important;word-break:normal!important}
  /* Evita falsos vazios criados por altura mínima herdada de containers móveis. */
  #settingsHub,#historyHub,.settings-hub-grid,.section-hub-grid {min-height:0!important}
  #settingsHub.active,#historyHub.active {height:auto!important}
}
@media screen and (max-width:359px) {
  #screenHead .nav-stack-actions>button:not([hidden]) {flex-basis:36px!important;min-width:36px!important;max-width:36px!important;width:36px!important;height:40px!important}
  #screenHead .nav-stack-actions {gap:3px!important}
  html body #historyHub .section-hub-grid>.section-hub-button {grid-template-columns:42px minmax(0,1fr) 12px!important;column-gap:9px!important;padding:10px!important}
  html body #historyHub .section-hub-grid>.section-hub-button>.section-hub-icon {width:42px!important;height:42px!important;min-width:42px!important}
}
@media screen and (min-width:700px) and (max-width:1023px) {
  /* iPad não pode herdar a grade de 3 colunas de desktop estreito. */
  html body #historyHub .section-hub-grid {grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:12px!important}
  html body #historyHub .section-hub-button {min-width:0!important}
}
