/* Protocolos UCI · versão web
   Cores do logótipo da ULS Algarve; aspeto de app iOS. */
:root {
  color-scheme: light dark;
  --fundo: #ffffff;
  --barra: rgba(246, 246, 246, 0.92);
  --texto: #000000;
  --secundario: #6c6c70;
  --separador: #d1d1d6;
  --preenchimento: #e9e9eb;
  --cabecalho: #f2f2f7;
  --folha: #f2f2f7;
  --cartao: #ffffff;
  --acento: #008A3C;
  --cinza: #616161;
  --aviso: #D9770F;
  --destaque: rgba(255, 214, 10, 0.45);
  --fundo-paginas: #e5e5ea;
  --verde: #008A3C; --verde-escuro: #1B6E32; --amarelo: #E0B00A; --laranja: #D9770F;
  --vermelho: #C8191A; --laranja-escuro: #D05018; --oliva: #7FA020;
  --sombra: 0 1px 3px rgba(0, 0, 0, 0.12);
  --topo: env(safe-area-inset-top, 0px);
  --base: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #000000; --barra: rgba(22, 22, 22, 0.92); --texto: #ffffff; --secundario: #98989f;
    --separador: #38383a; --preenchimento: #2c2c2e; --cabecalho: #1c1c1e; --folha: #1c1c1e; --cartao: #2c2c2e;
    --acento: #2DB35C; --cinza: #A8A8A8; --aviso: #F0923A; --fundo-paginas: #1c1c1e;
    --destaque: rgba(255, 214, 10, 0.4);
    --verde: #2DB35C; --verde-escuro: #5DB574; --amarelo: #F0C330; --laranja: #F0923A;
    --vermelho: #E5484A; --laranja-escuro: #EE7040; --oliva: #A3C443;
  }
}

* { box-sizing: border-box; min-width: 0; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fundo); color: var(--texto);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Vistas */
.vista { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--fundo); }
.vista-documento { transition: transform 0.28s cubic-bezier(.2,.8,.2,1); z-index: 2; }
.vista-documento.entrar { transform: translateX(100%); }
@media (prefers-reduced-motion: reduce) { .vista-documento { transition: none; } }

/* Barra superior */
.barra { flex: none; background: var(--barra); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); padding-top: var(--topo); z-index: 3; }
.barra-topo { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px max(12px, env(safe-area-inset-right)) 4px max(12px, env(safe-area-inset-left)); }
.espaco { width: 44px; flex: none; }
.titulo-app { flex: 1; text-align: center; }
.titulo-app h1 { margin: 0; font-size: 17px; font-weight: 600; }
.titulo-app p { margin: 0; font-size: 11px; color: var(--secundario); }
.botao-icone { width: 44px; height: 44px; display: grid; place-items: center; color: var(--acento); flex: none; border-radius: 10px; }
.botao-icone svg { width: 24px; height: 24px; }

.pesquisa { display: flex; align-items: center; gap: 6px; margin: 2px 14px 0; padding: 0 8px; height: 36px; border-radius: 10px; background: var(--preenchimento); color: var(--secundario); }
.pesquisa svg { width: 18px; height: 18px; flex: none; }
.pesquisa input { flex: 1; border: 0; background: none; color: var(--texto); font-size: 16px; height: 100%; outline: none; -webkit-appearance: none; appearance: none; }
.pesquisa input::-webkit-search-cancel-button { display: none; }
.pesquisa input::placeholder { color: var(--secundario); }
.limpar { width: 28px; height: 28px; display: grid; place-items: center; color: var(--secundario); }
.limpar svg { width: 16px; height: 16px; }

.filtros { display: flex; gap: 6px; overflow-x: auto; padding: 9px 14px 8px; scrollbar-width: none; scroll-padding-inline: 14px; }
.filtros::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 99px; background: var(--preenchimento); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip .ponto { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="true"] { background: var(--c); color: var(--ct); }
.chip[aria-pressed="true"] .ponto { display: none; }
.faixa { height: 3px; background: linear-gradient(90deg, var(--verde), var(--amarelo), var(--laranja), var(--vermelho)); }

/* Lista */
.lista { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--base) + 24px); }
.seccao-cabecalho { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 7px; padding: 6px 16px; background: var(--cabecalho); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.seccao-cabecalho .marca { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.seccao-cabecalho .nome { flex: 1; }
.seccao-cabecalho .total { color: var(--secundario); font-variant-numeric: tabular-nums; }
.linha { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 6px 12px 6px 16px; text-align: left; border-bottom: 0.5px solid var(--separador); }
.linha:active { background: var(--preenchimento); }
.linha .barra-cor { width: 4px; height: 28px; border-radius: 2px; background: var(--c); flex: none; }
.linha .textos { flex: 1; }
.linha .t { font-size: 15px; font-weight: 500; line-height: 1.25; }
.linha .s { font-size: 12px; color: var(--secundario); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linha .no-texto { font-size: 11px; color: var(--acento); margin-top: 1px; }
.linha .relogio { color: var(--aviso); width: 16px; height: 16px; flex: none; }
.linha .seta { color: var(--separador); width: 16px; height: 16px; flex: none; }
.vazio { padding: 64px 32px; text-align: center; color: var(--secundario); }
.vazio strong { display: block; color: var(--texto); font-size: 20px; margin-bottom: 6px; }
.estado-indice { position: fixed; left: 0; right: 0; bottom: calc(var(--base) + 8px); margin: 0; text-align: center; font-size: 12px; color: var(--secundario); pointer-events: none; }

/* Documento */
.voltar { display: flex; align-items: center; gap: 0; height: 44px; color: var(--acento); font-size: 17px; flex: none; padding-right: 4px; }
.voltar svg { width: 26px; height: 26px; margin-left: -6px; stroke-width: 2.4; }
.titulo-documento { flex: 1; margin: 0; font-size: 15px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acoes { display: flex; flex: none; }
.acoes .botao-icone { width: 40px; }
@media (max-width: 380px) { .voltar span { display: none; } }
.paginas { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--fundo-paginas); touch-action: pan-x pan-y; outline: none; }
.paginas-conteudo { padding: 12px 10px calc(var(--base) + 80px); transform-origin: 0 0; margin: 0 auto; }
.pagina { position: relative; margin: 0 auto 12px; background: #fff; box-shadow: var(--sombra); }
.pagina canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pagina .destaques { position: absolute; inset: 0; pointer-events: none; }
.pagina .destaques i { position: absolute; background: var(--destaque); border-radius: 2px; mix-blend-mode: multiply; }
.pagina .num { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: #8e8e93; }
.carregar { padding: 48px 24px; text-align: center; color: var(--secundario); }
.zoom { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: calc(var(--base) + 16px); display: flex; align-items: center; background: var(--barra); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 99px; box-shadow: 0 2px 10px rgba(0,0,0,0.18); z-index: 3; }
.zoom button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--acento); }
.zoom .zoom-valor { width: 52px; font-size: 13px; font-weight: 600; color: var(--texto); font-variant-numeric: tabular-nums; }

/* Folha inferior */
.fundo-folha { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 10; }
.folha { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; display: flex; flex-direction: column; background: var(--folha); border-radius: 14px 14px 0 0; z-index: 11; padding-bottom: var(--base); animation: subir 0.25s ease-out; max-width: 640px; margin: 0 auto; }
@keyframes subir { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .folha { animation: none; } }
.folha-cabecalho { display: flex; align-items: center; padding: 14px 16px 8px; }
.folha-cabecalho h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; text-align: center; padding-left: 44px; }
.folha-ok { width: 44px; height: 32px; color: var(--acento); font-weight: 600; font-size: 17px; }
.folha-corpo { overflow-y: auto; padding: 4px 16px 20px; }
.grupo-titulo { margin: 16px 4px 6px; font-size: 12px; text-transform: uppercase; color: var(--secundario); letter-spacing: 0.02em; }
.grupo { background: var(--cartao); border-radius: 10px; overflow: hidden; }
.campo { display: flex; justify-content: space-between; gap: 16px; padding: 11px 14px; border-bottom: 0.5px solid var(--separador); font-size: 15px; }
.campo:last-child { border-bottom: 0; }
.campo span:first-child { color: var(--texto); flex: none; }
.campo span:last-child { color: var(--secundario); text-align: right; }
.nota { padding: 12px 14px; font-size: 14px; line-height: 1.45; color: var(--texto); }
.nota + .nota { border-top: 0.5px solid var(--separador); }
.alerta { margin: 8px 4px 0; font-size: 13px; color: var(--aviso); }
.marca-app { padding: 14px; }
.marca-app strong { font-size: 20px; display: block; }
.marca-app span { color: var(--secundario); font-size: 14px; }
.marca-app .faixa { margin-top: 10px; border-radius: 3px; }

/* Aviso de instalação e notificações */
.aviso-instalar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--base) + 12px); display: flex; align-items: center; gap: 12px; padding: 12px 6px 12px 12px; background: var(--cartao); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); z-index: 9; max-width: 520px; margin: 0 auto; }
.aviso-instalar img { border-radius: 10px; flex: none; }
.aviso-texto { flex: 1; font-size: 14px; line-height: 1.35; }
.aviso-texto strong { display: block; }
.aviso-texto svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--acento); }
.aviso-texto button { margin-top: 6px; padding: 6px 14px; border-radius: 99px; background: var(--acento); color: #fff; font-weight: 600; font-size: 14px; }
.notificacao { position: fixed; left: 50%; bottom: calc(var(--base) + 80px); transform: translateX(-50%); background: rgba(40,40,40,0.92); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 12; max-width: 90vw; text-align: center; }
