/* ==========================================================================
 * styles.css — App OPA & VST (Engecom)
 * Identidade: grafite + branco (logo Engecom) com acentos coloridos variados.
 * ========================================================================== */
:root {
  --ink: #243027;        /* grafite esverdeado (header/texto) */
  --ink-2: #2b3530;
  --bg: #f2f4f3;         /* fundo do app (neutro) */
  --card: #ffffff;
  --linha: #e3e8e5;
  --texto: #1f2a24;
  --suave: #6b7770;

  --azul: #3a6285;       /* OPA — azul-petróleo sóbrio */
  --verde: #1f7a53;      /* VST / segurança (verde corporativo) */
  --verde-cl: #3a9b6e;
  --laranja: #a16207;    /* histórico — âmbar sóbrio */
  --roxo: #52606e;       /* cadastros — cinza-azulado */
  --vermelho: #b91c1c;
  --amarelo: #a16207;

  --radius: 16px;
  --sombra: 0 2px 10px rgba(20,25,40,.08);
  --sombra-2: 0 6px 20px rgba(20,25,40,.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- App bar ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  box-shadow: var(--sombra);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.logo-img { height: 30px; width: auto; display: block; }
.brand .sub { font-size: 11px; color: var(--suave); font-weight: 600; letter-spacing: .3px; }
#netStatus { font-size: 12px; font-weight: 600; background: #eafaf2; color: #0f9d63; padding: 5px 10px; border-radius: 20px; }
#netStatus.offline { background: #fdeaea; color: var(--vermelho); }
.accent-bar { height: 3px; background: linear-gradient(90deg, #155c3e, var(--verde), var(--verde-cl)); }

main#view { max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; }

/* ---------- Home ---------- */
.home-hero { margin: 2px 0 16px; }
.home-hero h1 { font-size: 20px; margin: 0 0 2px; }
.home-hero p { margin: 0; color: var(--suave); font-size: 13px; }

.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.home-btn {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px 16px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; color: #fff; cursor: pointer;
  box-shadow: var(--sombra-2); text-align: left; overflow: hidden; min-height: 112px;
  justify-content: space-between;
}
.home-btn .ic { font-size: 32px; line-height: 1; }
.home-btn .lbl { font-size: 16px; }
.home-btn .desc { font-size: 11px; font-weight: 500; opacity: .9; }
.home-btn.opa  { background: linear-gradient(135deg, #4a749a, #3a6285); }
.home-btn.vst  { background: linear-gradient(135deg, #2a9168, #1f7a53); }
.home-btn.hist { background: linear-gradient(135deg, #b07d1e, #a16207); }
.home-btn.cad  { background: linear-gradient(135deg, #647280, #52606e); }
.home-btn:active { transform: scale(.98); }

.indicadores { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin: 18px 0; }
.ind {
  background: var(--card); border-radius: var(--radius); padding: 16px 8px; text-align: center;
  box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--suave); font-weight: 600;
}
.ind .ind-ic { font-size: 18px; }
.ind-num { font-size: 26px; font-weight: 800; color: var(--ink); }
.ind.pend .ind-num { color: var(--laranja); }

.btn-sync {
  width: 100%; padding: 13px; border: 1px solid var(--linha); background: var(--card);
  border-radius: var(--radius); font-size: 15px; cursor: pointer; color: var(--texto); font-weight: 600;
  box-shadow: var(--sombra);
}

/* ---------- Cabeçalho de subtelas ---------- */
.form-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-header h2 { font-size: 19px; margin: 0; }
.btn-back {
  border: none; background: var(--card); padding: 9px 13px; border-radius: 10px;
  box-shadow: var(--sombra); cursor: pointer; font-size: 14px; font-weight: 600;
}

/* ---------- Form ---------- */
.form fieldset {
  border: none; border-radius: var(--radius);
  margin: 0 0 16px; padding: 6px 16px 16px; background: var(--card); box-shadow: var(--sombra);
}
.form legend {
  font-weight: 800; color: var(--ink); padding: 12px 0 4px; font-size: 14px;
  display: flex; align-items: center; gap: 7px; letter-spacing: .2px;
}
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; color: var(--suave); margin-bottom: 5px; font-weight: 600; }
.field input, .field textarea, .filtros input, .filtros select, .ss-input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--linha);
  border-radius: 11px; font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus, .ss-input:focus {
  outline: none; border-color: var(--verde); box-shadow: 0 0 0 3px rgba(31,122,83,.18);
}
.field textarea { resize: vertical; }
.field .readonly { background: #f5f7fa; color: var(--suave); }

/* ---------- Fotos / Evidências ---------- */
.btn-foto, .btn-gps {
  display: inline-block; margin-top: 6px; padding: 11px 16px; border: 1px dashed var(--azul);
  background: #eef3fe; color: var(--azul); border-radius: 11px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn-gps { width: 100%; text-align: center; border-color: var(--verde); background: #eafaf3; color: #0f9d63; }
.fotos-galeria { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.foto-thumb { position: relative; width: 86px; height: 86px; border-radius: 10px; overflow: hidden; box-shadow: var(--sombra); }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-del {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: none;
  background: rgba(239,68,68,.92); color: #fff; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1;
}

/* ---------- Choice (Positiva/Negativa) ---------- */
.choice-grupo { display: flex; gap: 10px; }
.choice-btn {
  flex: 1; padding: 12px; border: 1px solid var(--linha); background: #fff;
  border-radius: 11px; font-size: 15px; cursor: pointer; color: var(--texto); font-weight: 600;
}
.choice-btn.sel { color: #fff; border-color: transparent; }
.choice-grupo .choice-btn:nth-child(1).sel { background: var(--verde); }
.choice-grupo .choice-btn:nth-child(2).sel { background: var(--vermelho); }

/* ---------- Search-select ---------- */
.ss-wrap { position: relative; }
.ss-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: #fff; border: 1px solid var(--linha); border-radius: 11px;
  max-height: 240px; overflow-y: auto; box-shadow: var(--sombra-2);
}
.ss-option { padding: 11px 13px; cursor: pointer; font-size: 14px; }
.ss-option:hover { background: #f1f5fb; }
.ss-empty { padding: 11px 13px; color: var(--suave); font-size: 13px; }

/* ---------- Botões ação ---------- */
.form-actions, .msg-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.btn-primary {
  background: linear-gradient(135deg, #2a9168, var(--verde)); color: #fff; border: none; padding: 15px;
  border-radius: var(--radius); font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(31,122,83,.28);
}
.btn-secondary {
  background: #fff; color: var(--verde); border: 2px solid var(--verde); padding: 13px;
  border-radius: var(--radius); font-size: 15px; font-weight: 700; cursor: pointer;
}

/* ---------- Mensagem ---------- */
.hint { font-size: 13px; color: var(--suave); margin: 4px 0 12px; }
.msg-box {
  white-space: pre-wrap; background: var(--card); border: 1px solid var(--linha);
  border-radius: var(--radius); padding: 16px; font-size: 13.5px; line-height: 1.55; box-shadow: var(--sombra);
  font-family: inherit; overflow-x: auto;
}

/* ---------- Histórico ---------- */
.filtros { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 14px; }
@media (min-width: 520px) { .filtros { grid-template-columns: 2fr 1fr 1fr; } }
.lista { display: flex; flex-direction: column; gap: 11px; }
.reg-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--sombra); border-left: 4px solid var(--linha); }
.reg-card.t-opa { border-left-color: var(--azul); }
.reg-card.t-vst { border-left-color: var(--verde); }
.reg-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; color: #fff; }
.b-opa { background: var(--azul); }
.b-vst { background: var(--verde); }
.status { font-size: 12px; margin-left: auto; font-weight: 600; }
.s-pend { color: var(--laranja); }
.s-ok { color: var(--verde); }
.reg-sub { font-size: 13px; color: var(--suave); margin: 7px 0 11px; }
.reg-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.reg-actions button {
  border: 1px solid var(--linha); background: #fff; padding: 8px 11px;
  border-radius: 9px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.reg-actions button.danger { color: var(--vermelho); border-color: #f3c2c2; }
.vazio { text-align: center; color: var(--suave); padding: 36px 0; }

/* ---------- Cadastros ---------- */
.cad-nuvem { margin-bottom: 16px; }
.cad-manual { background: var(--card); border: 1px solid var(--linha); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.cad-manual summary { cursor: pointer; font-weight: 700; color: var(--suave); font-size: 14px; }
.cad-manual[open] summary { margin-bottom: 8px; }
.cad-listas { display: flex; flex-direction: column; gap: 10px; }
.cad-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--sombra);
}
.cad-info { display: flex; flex-direction: column; gap: 3px; }
.cad-info span { font-size: 12px; }
.cad-info .ok { color: var(--verde); font-weight: 600; }
.cad-info .pend { color: var(--laranja); font-weight: 600; }
.btn-import {
  background: var(--roxo); color: #fff; padding: 10px 15px; border-radius: 10px;
  font-size: 14px; cursor: pointer; white-space: nowrap; font-weight: 600;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 24px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90%; box-shadow: var(--sombra-2);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
