:root {
  --azul: #1f3a5f;
  --azul-2: #2f5687;
  --azul-claro: #e8eef6;
  --fundo: #f3f5f8;
  --cartao: #ffffff;
  --texto: #1d2733;
  --suave: #5a6676;
  --borda: #d3dae4;
  --perigo: #b00020;
  --alerta: #8a5300;
  --alerta-fundo: #fff4e0;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }

.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  background: var(--azul); color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  min-height: 56px;
}
.topo h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo .icone { width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; color: #fff; font-size: 22px; cursor: pointer; flex: none; }
.topo .icone:active { background: rgba(255,255,255,.15); }
.marca { font-weight: 800; letter-spacing: .5px; padding: 0 8px; font-size: 15px; background: #fff; color: var(--azul); border-radius: 6px; margin-left: 4px; }

.abas {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 15;
  display: flex; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--borda);
  scrollbar-width: none;
}
.abas::-webkit-scrollbar { display: none; }
.abas button {
  flex: none; border: 0; background: none; padding: 13px 14px; font-size: 15px; color: var(--suave);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.abas button.ativa { color: var(--azul); font-weight: 700; border-bottom-color: var(--azul); }

.conteudo { padding: 12px 12px 96px; max-width: 860px; margin: 0 auto; }
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.cartao h3 { margin: 0 0 10px; font-size: 15px; color: var(--azul); text-transform: uppercase; letter-spacing: .3px; }
.ajuda { color: var(--suave); font-size: 14px; margin: 4px 2px 12px; }

.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.campo { display: flex; flex-direction: column; gap: 4px; position: relative; min-width: 0; }
.campo.largo { grid-column: 1 / -1; }
.campo > label { font-size: 13px; color: var(--suave); font-weight: 600; }
.campo small { font-size: 12px; color: var(--suave); }
.campo input, .campo select, .campo textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px;
  background: #fff; font-size: 16px;
}
.campo textarea { resize: vertical; min-height: 96px; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--azul-2); outline-offset: -1px; border-color: var(--azul-2); }
.campo .prefixo { position: absolute; left: 12px; bottom: 12px; color: var(--suave); pointer-events: none; }
.campo label + .prefixo { bottom: 12px; }
.campo input.com-prefixo { padding-left: 40px; }
.campo.check, label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; min-height: 46px; }
.check input { width: 22px; height: 22px; accent-color: var(--azul); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center; text-decoration: none;
  min-height: 46px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--azul);
  background: var(--azul); color: #fff; font-weight: 600; cursor: pointer;
}
.btn.sec { background: #fff; color: var(--azul); }
.btn.perigo { background: #fff; color: var(--perigo); border-color: var(--perigo); }
.btn.grande { width: 100%; min-height: 54px; font-size: 17px; margin-bottom: 10px; }
.btn:active { filter: brightness(.92); }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.acoes.coluna { flex-direction: column; }
.acoes.coluna .btn { width: 100%; }

.item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--borda); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.item b { font-size: 16px; }
.item span { color: var(--suave); font-size: 14px; }
.item .rodape-item { font-size: 13px; }
.item .rodape-item b { color: var(--azul); font-size: 14px; }
.item.excluida { opacity: .6; border-style: dashed; }
.item:active { background: var(--azul-claro); }
.busca { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--borda); border-radius: 23px; margin-bottom: 12px; font-size: 16px; }
.vazio { text-align: center; color: var(--suave); padding: 28px 12px; }

.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
  border: 0; border-radius: 28px; padding: 16px 22px; background: var(--azul); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 18px rgba(31,58,95,.35); cursor: pointer;
}

.fator { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.fator:last-child { border-bottom: 0; }
.fator input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--azul); }
.fator span { display: flex; flex-direction: column; }
.fator small { color: var(--suave); font-size: 13px; }
.coef { margin-bottom: 14px; }
.coef h4 { margin: 6px 0; font-size: 14px; }
.coef label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.coef input { width: 96px; min-height: 42px; padding: 8px; text-align: right; border: 1px solid var(--borda); border-radius: 8px; font-size: 16px; }

.valor { background: var(--azul); color: #fff; border-radius: 14px; padding: 18px 16px; margin-bottom: 12px; text-align: center; }
.valor small { letter-spacing: 1px; opacity: .85; }
.valor strong { display: block; font-size: 30px; margin: 4px 0; }
.valor em { display: block; font-size: 14px; opacity: .9; }
.graus { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.avisos { background: var(--alerta-fundo); color: var(--alerta); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.avisos p { margin: 4px 0; }
.resumo { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.resumo dt { color: var(--suave); }
.resumo dd { margin: 0; text-align: right; font-weight: 600; }
.rolar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
.tab th { background: var(--azul); color: #fff; padding: 6px 8px; text-align: right; }
.tab td { padding: 6px 8px; border-bottom: 1px solid #eef1f5; text-align: right; }
.tab th:first-child, .tab td:first-child, .tab td:last-child { text-align: left; }
.tab tr.descartada td { color: var(--perigo); text-decoration: line-through; }
.tab tr.descartada td:last-child { text-decoration: none; }

.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.foto { margin: 0; background: #fff; border: 1px solid var(--borda); border-radius: 10px; overflow: hidden; }
.foto img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.foto input { width: 100%; border: 0; border-top: 1px solid var(--borda); padding: 10px; font-size: 15px; }
.mini { display: flex; border-top: 1px solid var(--borda); }
.mini button { flex: 1; border: 0; background: #fff; padding: 10px 4px; color: var(--azul); cursor: pointer; font-size: 14px; }
.mini button + button { border-left: 1px solid var(--borda); }
.foto-amostra, .logo { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 8px; }
.logo { background: #fff; border: 1px solid var(--borda); padding: 8px; }

.qr { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.qr-img { width: 124px; height: 124px; border: 1px dashed var(--borda); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--suave); font-size: 13px; background: #fff; }
.qr-img img { width: 116px; height: 116px; image-rendering: pixelated; }
.vu { background: var(--azul-claro); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,25,40,.45); display: flex; align-items: flex-end; justify-content: center; }
.folha {
  background: #fff; width: 100%; max-width: 560px; max-height: 85vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.folha h3 { margin: 0 0 8px; color: var(--azul); }
.folha p { overflow-wrap: anywhere; }
.menu { display: flex; flex-direction: column; }
.menu button { border: 0; background: none; text-align: left; padding: 15px 8px; font-size: 16px; border-bottom: 1px solid #eef1f5; cursor: pointer; }
.menu button:last-child { color: var(--suave); border-bottom: 0; }
.lista-check { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.lista-check label { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid #eef1f5; font-size: 14px; }
.lista-check input { width: 22px; height: 22px; flex: none; }
.carregando { text-align: center; color: var(--suave); padding: 24px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60;
  background: #1d2733; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px; max-width: 90vw; text-align: center;
}

@media (max-width: 380px) {
  .grade { grid-template-columns: 1fr; }
}
@media (min-width: 700px) {
  .modal { align-items: center; }
  .folha { border-radius: 16px; }
}
