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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #f0f2f5;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
}

#hdr {
  background: #1a6eb5;
  color: #fff;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  flex-shrink: 0
}

#hdr-title { font-weight: bold; font-size: 15px; flex: 1 }

#hdr-prog {
  font-size: 11px;
  opacity: .85;
  white-space: nowrap;
  text-align: right
}

.hbtn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px
}

#pb-wrap { height: 4px; background: #d1d5db; flex-shrink: 0 }
#pb { height: 4px; background: #22c55e; transition: width .4s }

#map-wrap { flex: 1; position: relative; min-height: 0 }
#map { width: 100%; height: 100% }

#gps-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 11px;
  pointer-events: none;
  white-space: nowrap
}

.fab-btn {
  background: #1a6eb5;
  color: #fff;
  border: none;
  padding: 13px 20px;
  border-radius: 28px;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  cursor: pointer;
  width: 100%
}
.fab-btn:active { filter: brightness(0.9) }

#loading {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 15px;
  color: #555
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: #1a6eb5;
  border-radius: 50%;
  animation: spin .8s linear infinite
}
@keyframes spin { to { transform: rotate(360deg) } }

.panel {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease
}
.panel.up { transform: translateY(100%) }
.panel.open { transform: translate(0,0) !important }

.ph {
  background: #1a6eb5;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  flex-shrink: 0;
  min-height: 50px
}
.ph button {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
  margin: -8px 0 -8px -8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph button svg { pointer-events: none }
.ph span {
  font-size: 14px;
  font-weight: bold;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}
.ph .sub { font-size: 11px; opacity: .8; flex: none; text-align: right }

.sw { padding: 8px; background: #f5f7fa; border-bottom: 1px solid #e4e7eb; flex-shrink: 0 }
.si {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none
}
.si:focus { border-color: #1a6eb5 }

.slist { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch }

.ri {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  gap: 10px
}
.ri:active { background: #eaf4ff }
.rdot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0 }
.rnfo { flex: 1; min-width: 0 }
.rn { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.rs { font-size: 12px; color: #777; margin-top: 2px }
.seta { color: #d1d5db; font-size: 20px }

.ci {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  gap: 10px
}
.ci:active { background: #eaf4ff }
.cck {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold
}
.cck.ok { background: #22c55e; border-color: #22c55e; color: #fff }
.cnfo { flex: 1; min-width: 0 }
.cn { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.cs { font-size: 12px; color: #777; margin-top: 2px }

#det-body { flex: 1; overflow-y: auto; padding: 12px 12px 0; -webkit-overflow-scrolling: touch }
.dr { margin-bottom: 12px }
.dl {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: .5px
}
.dv {
  font-size: 14px;
  color: #374151;
  padding: 9px 11px;
  background: #f9fafb;
  border-radius: 7px;
  word-break: break-all
}
.di {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 14px;
  outline: none
}
.di:focus { border-color: #1a6eb5 }
.di.hydro {
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 3px;
  color: #1a6eb5
}
.di.obrigatorio { border-color: #ef4444 !important; background: #fef2f2 }
.dl .req { color: #ef4444; margin-left: 2px }

.det-btns {
  padding: 12px;
  flex-shrink: 0;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 8px
}
.btn-ok {
  padding: 14px;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  width: 100%
}
.btn-ok:active { background: #16a34a }
.btn-ok.done { background: #dcfce7; color: #15803d; border: 2px solid #86efac }

.btn-save {
  padding: 11px;
  background: #1a6eb5;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  width: 100%
}
.btn-save:active { background: #155a9a }

.btn-undo {
  padding: 9px;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  width: 100%
}

.entg-info {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #15803d;
  line-height: 1.5
}

.sugest {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 8px 14px;
  font-size: 12px;
  color: #92400e;
  flex-shrink: 0;
  display: none
}

.empty { text-align: center; padding: 48px 20px; color: #9ca3af; font-size: 14px }

.err-banner {
  background: #fef2f2;
  border-bottom: 2px solid #fca5a5;
  padding: 8px 12px;
  font-size: 12px;
  color: #dc2626;
  flex-shrink: 0;
  display: none
}

#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 999999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s
}

.filt-btn {
  flex: 1;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
  padding: 6px 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}
.filt-btn.active { background: #1a6eb5; color: #fff; border-color: #1a6eb5 }

.btn-add-fone {
  background: none;
  border: 2px dashed #1a6eb5;
  color: #1a6eb5;
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}
.btn-add-fone:active { background: #eff6ff }

/* ── Tela de acesso ── */
#tela-acesso {
  position: fixed;
  inset: 0;
  background: #1a6eb5;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px;
}
#tela-acesso .logo { font-size: 28px; font-weight: bold; color: #fff; letter-spacing: 1px }
#tela-acesso .sub-logo { font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 8px }
#tela-acesso .card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
#tela-acesso .card label {
  font-size: 12px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .5px;
}
#input-codigo {
  width: 100%;
  padding: 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 6px;
  outline: none;
  color: #1a6eb5;
  transition: border-color .2s;
}
#input-codigo:focus { border-color: #1a6eb5 }
#btn-acessar {
  width: 100%;
  padding: 14px;
  background: #1a6eb5;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: background .2s;
}
#btn-acessar:active { background: #155a9a }
#erro-codigo { font-size: 13px; color: #dc2626; text-align: center; min-height: 18px }

/* ── Fotos ── */
.foto-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px }
.foto-thumb {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block }
.foto-thumb .foto-del {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-foto {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 2px dashed #1a6eb5;
  color: #1a6eb5;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
}
.btn-foto:active { background: #eff6ff }

/* ── Painel de configuração ── */
#panel-config {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .25s ease;
}
#panel-config.open { transform: translateY(0) }

.cfg-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.cfg-label { font-size: 14px; color: #374151 }

.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0 }
.toggle input { opacity: 0; width: 0; height: 0 }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: #1a6eb5 }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px) }

.btn-export {
  padding: 11px;
  background: #fff;
  color: #1a6eb5;
  border: 2px solid #1a6eb5;
  border-radius: 9px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
}
.btn-export:active { background: #eff6ff }
