:root {
  --terra: #4c1800;
  --terra-700: #6b2e12;
  --verde: #1f7f45;
  --verde-claro: #35b562;
  --azul: #4f7fe0;
  --roxo: #7261fa;
  --dourado: #d99b1f;
  --dourado-claro: #edba57;
  --vermelho: #b3261e;
  --creme: #fbf8f3;
  --areia: #f2e9dd;
  --areia-escura: #e3d5c3;
  --tinta: #2a1a11;
  --tinta-suave: #5f4d41;
  --raio: 14px;
  --sombra: 0 2px 10px rgba(76, 24, 0, .08);
  --altura-barra: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--creme); color: var(--tinta);
  font-size: 16px; line-height: 1.55;
  padding-bottom: calc(var(--altura-barra) + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; color: var(--terra); }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
a { color: var(--verde); }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; border-radius: 6px; }

/* ---------- Cabeçalho ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  background: var(--terra); color: #fff;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem;
  display: flex; align-items: center; gap: .8rem;
}
.topo img { height: 34px; width: auto; background: #fff; border-radius: 8px; padding: 3px 6px; }
.topo__titulo { font-weight: 600; font-size: 1rem; flex: 1; min-width: 0; }
.topo__titulo small { display: block; font-weight: 400; font-size: .78rem; opacity: .8; }
.topo__estado {
  font-size: .72rem; padding: .22rem .6rem; border-radius: 999px;
  background: rgba(255,255,255,.16); white-space: nowrap;
}
.topo__estado[data-online="false"] { background: var(--dourado); color: #3a2600; }

.tela { padding: 1rem 1rem 1.5rem; max-width: 640px; margin-inline: auto; }
.tela[hidden] { display: none; }

/* ---------- Cartões / listas ---------- */
.cartao {
  background: #fff; border: 1px solid var(--areia-escura); border-radius: var(--raio);
  padding: 1rem; margin-bottom: .85rem; box-shadow: var(--sombra);
}
.cartao--aviso { background: #fff7e8; border-color: var(--dourado-claro); }
.cartao--erro { background: #fdecea; border-color: #f0b4ae; }

.acoes-principais { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.2rem; }
.acao {
  display: flex; flex-direction: column; align-items: flex-start; gap: .35rem;
  background: #fff; border: 1px solid var(--areia-escura); border-left: 5px solid var(--verde-claro);
  border-radius: var(--raio); padding: .95rem .9rem; text-align: left;
  font: inherit; color: var(--terra); cursor: pointer; box-shadow: var(--sombra);
  transition: transform .12s ease;
}
.acao:active { transform: scale(.97); }
.acao:nth-child(2) { border-left-color: var(--azul); }
.acao:nth-child(3) { border-left-color: var(--dourado-claro); }
.acao:nth-child(4) { border-left-color: var(--roxo); }
.acao b { font-size: 1rem; }
.acao span { font-size: .8rem; color: var(--tinta-suave); font-weight: 400; }
.acao__icone { font-size: 1.5rem; line-height: 1; }

.resumo { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.2rem; }
.resumo div { background: var(--areia); border-radius: var(--raio); padding: .7rem .5rem; text-align: center; }
.resumo b { display: block; font-size: 1.5rem; color: var(--terra); line-height: 1.1; }
.resumo span { font-size: .72rem; color: var(--tinta-suave); }

/* ---------- Formulários ---------- */
.campo { margin-bottom: .95rem; }
.campo label { display: block; font-weight: 600; font-size: .9rem; color: var(--terra); margin-bottom: .3rem; }
.campo .ajuda { font-size: .78rem; color: var(--tinta-suave); margin: .25rem 0 0; }
input, select, textarea, button { font: inherit; font-size: 16px; }
input[type=text], input[type=number], input[type=tel], input[type=date],
input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--areia-escura);
  border-radius: 10px; background: #fff; color: var(--tinta);
}
textarea { min-height: 6.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--verde); outline: none; box-shadow: 0 0 0 3px rgba(53,181,98,.18); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--vermelho); }
.dupla { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
fieldset { border: 1px solid var(--areia-escura); border-radius: var(--raio); padding: .9rem; margin: 0 0 1rem; background: #fff; }
legend { font-weight: 600; color: var(--terra); font-size: .9rem; padding: 0 .35rem; }

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.2rem; border-radius: 999px; border: 2px solid transparent;
  font-weight: 600; cursor: pointer; width: 100%;
}
.botao--primario { background: var(--verde); color: #fff; }
.botao--primario:active { background: var(--verde-claro); }
.botao--terra { background: var(--terra); color: #fff; }
.botao--contorno { background: transparent; color: var(--terra); border-color: var(--terra); }
.botao--perigo { background: transparent; color: var(--vermelho); border-color: var(--vermelho); }
.botao--pequeno { width: auto; padding: .5rem .9rem; font-size: .85rem; }
.botao[disabled] { opacity: .5; pointer-events: none; }
.linha-botoes { display: flex; gap: .6rem; margin-top: 1.2rem; }

/* ---------- GPS e fotos ---------- */
.gps {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem;
  border-radius: 10px; background: var(--areia); font-size: .86rem; color: var(--tinta-suave);
}
.gps[data-estado="ok"] { background: #e6f6ec; color: #14562f; }
.gps[data-estado="erro"] { background: #fdecea; color: #8c211a; }
.gps b { color: inherit; }

.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .55rem; margin-top: .7rem; }
.foto { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--areia-escura); }
.foto img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.foto button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.62); color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}
.entrada-foto { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Participantes ---------- */
.participante { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: start; margin-bottom: .6rem; }
.participante .dados { display: grid; gap: .4rem; }
.participante button { border: 0; background: var(--areia); border-radius: 10px; padding: .55rem .7rem; cursor: pointer; color: var(--vermelho); font-weight: 600; }

/* ---------- Registros salvos ---------- */
.registro {
  background: #fff; border: 1px solid var(--areia-escura); border-left: 5px solid var(--verde-claro);
  border-radius: var(--raio); padding: .85rem .9rem; margin-bottom: .7rem;
}
.registro[data-tipo="veiculo"] { border-left-color: var(--azul); }
.registro[data-tipo="abastecimento"] { border-left-color: var(--dourado-claro); }
.registro[data-tipo="presenca"] { border-left-color: var(--roxo); }
.registro__topo { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.registro__topo b { color: var(--terra); font-size: .96rem; }
.registro__data { font-size: .76rem; color: var(--tinta-suave); white-space: nowrap; }
.registro p { margin: .3rem 0 0; font-size: .87rem; color: var(--tinta-suave); }
.registro__rodape { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.etiqueta { font-size: .72rem; padding: .18rem .55rem; border-radius: 999px; background: var(--areia); color: var(--terra-700); font-weight: 600; }
.etiqueta--pendente { background: #fff2d6; color: #7a5200; }
.etiqueta--enviado { background: #e6f6ec; color: #14562f; }

.vazio { text-align: center; padding: 2.5rem 1rem; color: var(--tinta-suave); }
.vazio span { font-size: 2.4rem; display: block; margin-bottom: .5rem; }

/* ---------- Barra inferior ---------- */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--areia-escura);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra button {
  background: none; border: 0; padding: .55rem .2rem .6rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  font-size: .7rem; color: var(--tinta-suave); font-weight: 600;
}
.barra button span { font-size: 1.25rem; line-height: 1; }
.barra button[aria-current="true"] { color: var(--terra); }
.barra button[aria-current="true"] span { transform: translateY(-1px); }

/* ---------- Avisos ---------- */
.aviso {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--altura-barra) + 14px + env(safe-area-inset-bottom));
  background: var(--terra); color: #fff; padding: .7rem 1.1rem; border-radius: 999px;
  font-size: .88rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 50; max-width: 90vw; text-align: center;
}
.aviso[data-tipo="erro"] { background: var(--vermelho); }
.aviso[data-tipo="ok"] { background: var(--verde); }
.aviso[hidden] { display: none; }

.processando { text-align: center; padding: 1rem; color: var(--tinta-suave); font-size: .9rem; }

/* ---------- Utilidades ---------- */
.oculto { display: none !important; }
.discreto { font-size: .82rem; color: var(--tinta-suave); }
.separador { border: 0; border-top: 1px solid var(--areia-escura); margin: 1.3rem 0; }
.centro { text-align: center; }
