:root {
  /* Cores do logo MecData: azul-marinho, azul royal e laranja */
  --fundo: #0a1330;
  --cartao: #111f45;
  --campo: #1a2b5a;
  --borda: #26396f;
  --texto: #eef2ff;
  --fraco: #9aa8cc;
  --laranja: #ff7a1a;
  --verde: #2fc768;
  --vermelho: #ff4d4f;
  --amarelo: #ffcc33;
  --azul: #3463e6;
  --azul-claro: #6f93ff;
  --roxo: #6f93ff;
  --teal: #3cc4e0;
  --cinza: #8592b5;
  --placa: #fad10d;
  --placa-azul: #003899;
  --topo: calc(env(safe-area-inset-top) + 56px);
  --abas: calc(env(safe-area-inset-bottom) + 64px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--fundo);
  background-image: linear-gradient(180deg, #0d1a42 0%, #0a1330 40%);
  color: var(--texto);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* A página não rola: só a área do meio (main). Assim o topo e as abas ficam sempre
   no mesmo lugar e do mesmo tamanho no iPhone (evita a barra "pular" ao rolar). */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; }

/* ---------- topo e abas ---------- */

#topo {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: var(--topo);
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(11, 22, 56, 0.94);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--borda);
}
#titulo { font-size: 21px; font-weight: 700; letter-spacing: 0.2px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#botao-ajustes { display: flex; color: var(--fraco); text-decoration: none; padding: 8px; margin-right: -8px; }
#botao-ajustes svg { width: 26px; height: 26px; }
.acoes-topo { display: flex; align-items: center; gap: 6px; flex: none; }
#botao-idioma {
  display: flex; gap: 2px; padding: 3px; border: 1px solid var(--borda); border-radius: 999px;
  background: var(--campo); cursor: pointer;
}
#botao-idioma span { font-size: 22px; line-height: 1; padding: 5px 7px; border-radius: 999px; opacity: 0.35; filter: grayscale(0.6); }
#botao-idioma span.ativo { opacity: 1; filter: none; background: var(--borda); }
#topo .voltar { color: var(--azul-claro); text-decoration: none; font-size: 18px; font-weight: 600; padding: 10px 10px 10px 0; }

#abas {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  height: var(--abas); box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
  background: rgba(11, 22, 56, 0.97);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--borda);
}
#abas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--fraco); text-decoration: none; font-size: 12px; font-weight: 600;
}
#abas a svg { width: 26px; height: 26px; }
#abas a.ativa { color: var(--laranja); }

main {
  position: fixed; top: var(--topo); bottom: var(--abas); left: 0; right: 0;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 16px max(16px, calc((100% - 720px) / 2)) 24px;
  display: flex; flex-direction: column; gap: 16px;
}
main > * { flex-shrink: 0; }

/* ---------- botões grandes ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 60px; padding: 0 14px;
  border: 2px solid transparent; border-radius: 14px;
  font: inherit; font-size: 19px; font-weight: 700;
  background: var(--cor, var(--azul)); color: #fff;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.35; }
.btn.contorno {
  background: color-mix(in srgb, var(--cor, var(--azul-claro)) 20%, #16285a);
  color: color-mix(in srgb, var(--cor, var(--azul-claro)) 30%, #ffffff);
  border: 1.5px solid color-mix(in srgb, var(--cor, var(--azul-claro)) 75%, transparent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  font-weight: 700;
}
.btn.pequeno { min-height: 50px; font-size: 16px; }
.btn .ico { display: none; }
.linha-botoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.linha-botoes .btn { padding: 0 4px; font-size: 15px; white-space: nowrap; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 46px; padding: 0 16px; border-radius: 23px; border: 0;
  font: inherit; font-size: 16px; font-weight: 700;
  background: color-mix(in srgb, var(--laranja) 15%, transparent); color: var(--laranja);
}
.chip.ativo { background: var(--laranja); color: #000; }

/* ---------- cartões e textos ---------- */

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cartao > h2 { margin: 0; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--azul-claro); display: flex; align-items: center; gap: 8px; }
.cartao > h2 .dir { margin-left: auto; font-size: 13px; font-weight: 500; }
h3 { margin: 8px 0 0; font-size: 19px; }
.fraco { color: var(--fraco); }
.pequeno-texto { font-size: 13px; overflow-wrap: anywhere; }
.aviso, .resposta { overflow-wrap: anywhere; }
.vazio { text-align: center; color: var(--fraco); padding: 32px 8px; }

.aviso {
  --c: var(--amarelo);
  padding: 12px; border-radius: 12px; font-size: 15px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.aviso.vermelho { --c: var(--vermelho); }
.aviso.azul { --c: var(--azul); }
.aviso.verde { --c: var(--verde); }

.selo {
  align-self: flex-start; padding: 6px 12px; border-radius: 999px;
  background: var(--amarelo); color: #000; font-weight: 900; font-size: 15px;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #000; background: var(--c, var(--cinza)); }
.badge.claro { color: var(--c); background: color-mix(in srgb, var(--c) 22%, transparent); }

/* ---------- placa UK ---------- */

.placa {
  display: flex; height: 78px; border: 3px solid #000; border-radius: 10px; overflow: hidden; background: var(--placa);
}
.placa .uk { width: 44px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--placa-azul); color: #fff; font-weight: 900; font-size: 15px; }
.placa input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #000;
  font: 900 40px/1 "Arial Black", "Helvetica Neue", sans-serif; text-align: center; letter-spacing: 1px; text-transform: uppercase;
}
.placa input::placeholder { color: rgba(0, 0, 0, 0.28); }
.placa .limpar { width: 54px; flex: none; border: 0; background: transparent; font-size: 26px; color: rgba(0, 0, 0, 0.5); }

.placa-mini {
  display: inline-block; padding: 2px 8px; border: 1.5px solid #000; border-radius: 5px;
  background: var(--placa); color: #000; font: 900 16px/1.2 "Arial Black", sans-serif; white-space: nowrap;
}

/* ---------- campos ---------- */

label.campo { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 700; color: var(--fraco); }
input.texto, textarea.texto, select.texto {
  width: 100%; padding: 12px; border: 1px solid transparent; border-radius: 12px;
  background: var(--campo); color: var(--texto); font: inherit; font-size: 19px;
}
input.texto:focus, textarea.texto:focus { border-color: var(--laranja); outline: 0; }
textarea.texto { min-height: 96px; resize: vertical; }
input.busca { font-size: 18px; }

/* ---------- ficha ---------- */

.celula {
  display: flex; flex-direction: column; gap: 6px; text-align: left; min-height: 110px;
  padding: 12px; border: 0; border-radius: 12px; background: var(--campo); color: var(--texto); font: inherit;
}
.celula .rotulo { font-size: 14px; color: var(--fraco); }
.celula .valor { font-size: 20px; font-weight: 800; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.celula .valor.nada { color: var(--fraco); }
.celula .pe { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--fraco); }
.grade-1 { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ---------- status OK / Atenção / Falha ---------- */

.status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status button {
  min-height: 54px; border: 0; border-radius: 12px; font: inherit; font-size: 17px; font-weight: 800;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent);
}
.status button.marcado { background: var(--c); color: #000; }

.item { background: var(--campo); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.item .nome { font-weight: 700; font-size: 18px; }
.item .obs-linha { display: flex; gap: 8px; align-items: flex-start; }
.item .obs-linha textarea { min-height: 50px; font-size: 17px; }
.btn-foto { flex: none; width: 58px; height: 50px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--azul) 22%, transparent); font-size: 24px; }

.resumo { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.resumo b { display: block; font-size: 26px; }

/* ---------- listas ---------- */

.lista { display: flex; flex-direction: column; gap: 10px; }
.linha {
  display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px;
  background: var(--cartao); color: var(--texto); text-decoration: none;
}
.linha .topo-linha { display: flex; align-items: center; gap: 10px; }
.linha .topo-linha b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--fraco); }

/* ---------- fotos ---------- */

.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.fotos img, .foto-item { width: 100%; height: 100px; object-fit: cover; border-radius: 10px; display: block; }
.foto-item { height: 150px; }

/* ---------- cronômetro ---------- */

.relogio { font: 700 52px/1 ui-monospace, "SF Mono", Menlo, monospace; text-align: center; padding: 8px 0; }
.relogio.rodando { color: var(--verde); }

/* ---------- MOT ---------- */

.defeito { display: flex; flex-direction: column; gap: 4px; }
.defeito .tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.repetido { color: var(--laranja); font-size: 13px; font-weight: 800; }
.tabela { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.tabela dt { color: var(--fraco); }
.tabela dd { margin: 0; font-weight: 700; }
.grafico svg { width: 100%; height: 180px; display: block; }

/* ---------- markdown simples ---------- */

.resposta { white-space: pre-wrap; word-break: break-word; font-size: 17px; user-select: text; -webkit-user-select: text; }
pre.bruto { white-space: pre; overflow: auto; max-height: 320px; font-size: 11px; background: #000; padding: 10px; border-radius: 10px; }
details > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

/* ---------- diálogo e aviso flutuante ---------- */

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: 90vh; padding: 0; border: 0; border-radius: 18px;
  background: var(--cartao); color: var(--texto);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog .conteudo-dialogo { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 20px; }
dialog img.grande { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #000; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--abas) + 16px); transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: #333; color: #fff; font-weight: 700; opacity: 0; pointer-events: none; transition: 0.25s;
  z-index: 20;
}
#toast.visivel { opacity: 1; transform: translateX(-50%) translateY(0); }

.carregando { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px; color: var(--fraco); font-weight: 600; }
.carregando::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--borda); border-top-color: var(--laranja); animation: gira 0.8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

/* iPhone: campo de data/hora não pode passar da largura do cartão */
label.campo { min-width: 0; }
input[type="datetime-local"].texto, input[type="date"].texto {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%; text-align: left;
}
input[type="datetime-local"].texto::-webkit-date-and-time-value { text-align: left; }

/* Ficha vazia */
.inicio-ficha { text-align: center; color: var(--fraco); margin: 8px 0 4px; font-size: 16px; }

