* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: #0f172a;
  color: #e5e7eb;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  padding: 16px;
  text-align: center;
  background: #1f2937;
}

header h1 { margin: 0; font-size: 1.5rem; }
header p { margin: 4px 0 0; font-size: 0.85rem; color: #9ca3af; }

main {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
}

section {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: 12px;
  background: #111827;
  border: 1px solid #1f2937;
}

h2 { margin: 0 0 12px; font-size: 1.15rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }

label {
  display: block;
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 10px;
}

input, select, button, textarea {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  font-size: 1rem;
  width: 100%;
}

label input, label select { margin-top: 4px; }
input::placeholder { color: #6b7280; }

button {
  cursor: pointer;
  background: #2563eb;
  border: none;
  font-weight: 600;
}
button:hover:not(:disabled) { background: #1d4ed8; }
button:disabled { background: #374151; color: #9ca3af; cursor: not-allowed; }
button.secundario { background: #1f2937; border: 1px solid #374151; font-weight: 500; }
button.secundario:hover:not(:disabled) { background: #374151; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0 12px;
}

.row { display: flex; gap: 8px; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

.hint { font-size: 0.78rem; color: #6b7280; margin: 6px 0 0; line-height: 1.45; }
.hint.aviso { color: #fbbf24; }

.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.85rem; }
.check input { width: auto; }

/* ---------- câmera ---------- */
.video-wrap {
  position: relative;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #374151;
  background: #020617;
  aspect-ratio: 4 / 3;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cam-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 0.9rem;
}
.cam-msg.hidden { display: none; }

/* ---------- painel do medidor ---------- */
.painel {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0b1120;
  border-left: 3px solid #2563eb;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
}
.painel.vazio { border-left-color: #b45309; color: #fcd34d; }

/* ---------- confirmação ---------- */
.confirm {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: #0b1120;
  border: 1px solid #2563eb;
}

.crop-preview {
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 12px;
  text-align: center;
}
.crop-preview img { max-width: 100%; max-height: 140px; display: inline-block; }

#leituraInput {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
}

.previa {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #111827;
  font-size: 0.88rem;
  line-height: 1.5;
}
.previa.alerta { background: #422006; border: 1px solid #b45309; color: #fcd34d; }

/* ---------- tabela ---------- */
.tabela-wrap { overflow-x: auto; margin-top: 10px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  white-space: nowrap;
}
th, td { padding: 7px 8px; border-bottom: 1px solid #1f2937; text-align: left; }
th { background: #0b1120; color: #9ca3af; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.alerta td { background: #2a1508; }

.acoes { display: flex; gap: 4px; }
.acoes button {
  width: auto;
  padding: 3px 7px;
  font-size: 0.75rem;
  background: #1f2937;
  border: 1px solid #374151;
  font-weight: 500;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: #1e3a8a;
}
.tag.ocr { background: #374151; color: #9ca3af; }
.tag.manual { background: #14532d; color: #86efac; }
.tag.semfoto { background: #422006; color: #fcd34d; }

/* ---------- avisos ---------- */
.banner {
  padding: 10px 16px;
  background: #1d4ed8;
  text-align: center;
  font-size: 0.88rem;
}
.btn-inline {
  width: auto;
  padding: 4px 12px;
  margin-left: 8px;
  background: #0b1120;
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1f2937;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.hidden { display: none !important; }

footer {
  text-align: center;
  padding: 14px;
  font-size: 0.78rem;
  color: #6b7280;
}
