:root {
  --bg: #0b111a;
  --surface: rgba(15, 23, 36, 0.92);
  --surface-solid: #111927;
  --card: #182334;
  --border: rgba(255, 255, 255, 0.11);
  --text: #f3f6fb;
  --muted: #9aa7bd;
  --fire: #ff5a1f;
  --fire-dark: #dc2626;
  --amber: #f59e0b;
  --green: #10b981;
  --blue: #3b82f6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  background: #0d1520;
}

/* Cabeçalho Flutuante */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  padding: calc(10px + var(--safe-top)) 12px 6px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 10px 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
  overflow: hidden;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulseDot 1.4s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.55; }
}

.btn-193 {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #dc2626;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 12px;
  padding: 8px 11px;
  border-radius: 11px;
  min-height: 36px;
  box-shadow: 0 3px 12px rgba(220, 38, 38, 0.45);
  white-space: nowrap;
}

/* Chips de filtro */
.filter-chips {
  pointer-events: auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.chip.active {
  background: var(--fire);
  border-color: #ff8552;
  color: #fff;
}

/* Controles laterais no mapa */
.map-controls {
  position: fixed;
  right: 12px;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.map-ctrl-btn small {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

.layer-pill {
  position: fixed;
  left: 12px;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 400;
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.emerg-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text);
}

.emerg-card strong { font-size: 15px; display: block; }
.emerg-card small { font-size: 12px; color: var(--muted); }
.emerg-num {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  font-weight: 900;
  font-size: 16px;
  padding: 7px 12px;
  border-radius: 10px;
}

.layer-menu {
  position: fixed;
  right: 68px;
  bottom: calc(94px + var(--safe-bottom));
  z-index: 410;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 175px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.layer-menu.open { display: flex; }

.layer-opt {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.layer-opt.active {
  background: rgba(255, 90, 31, 0.22);
  color: #ff9c75;
}

/* Mira central para escolher ponto no mapa */
.picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 450;
  pointer-events: none;
}
.picker-overlay.active { display: block; }

.picker-banner {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 12px;
  right: 12px;
  pointer-events: auto;
  background: rgba(15, 23, 36, 0.96);
  border: 1px solid rgba(255, 90, 31, 0.65);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
}

.picker-banner strong { display: block; font-size: 14px; }
.picker-banner small { color: var(--muted); font-size: 12px; }

.picker-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 38px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.8));
}
.picker-dot {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5a1f;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(255, 90, 31, 0.35);
}

.picker-footer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + var(--safe-bottom));
  pointer-events: auto;
  display: flex;
  gap: 8px;
}

/* Barra Inferior Fixa (Thumb Zone) */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 17, 26, 0) 0%, rgba(11, 17, 26, 0.92) 38%, rgba(11, 17, 26, 0.98) 100%);
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  gap: 8px;
  align-items: center;
}

.btn-side {
  min-height: 52px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}
.btn-side .ico { font-size: 18px; line-height: 1; }

.btn-report-main {
  min-height: 54px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff6b2b 0%, #e11d48 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(255, 90, 31, 0.52);
}

.btn-report-main:active { transform: scale(0.98); }

/* Marcadores Pulsantes no Mapa */
.fire-marker {
  position: relative;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fire-marker .ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  opacity: 0.7;
  animation: fireRadar 1.8s ease-out infinite;
}

.fire-marker .core {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 2.5px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.fire-marker.status-ativo .core { background: #ef4444; }
.fire-marker.status-ativo .ring { background: rgba(239, 68, 68, 0.55); }
.fire-marker.status-em_atendimento .core { background: #f59e0b; }
.fire-marker.status-em_atendimento .ring { background: rgba(245, 158, 11, 0.5); }
.fire-marker.status-controlado .core { background: #10b981; }
.fire-marker.status-controlado .ring { display: none; }

@keyframes fireRadar {
  0% { transform: scale(0.8); opacity: 0.85; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* Bottom Sheets / Modais */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(4, 8, 15, 0.68);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop.open { display: flex; }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.65);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  margin: 10px auto 4px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.btn-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.sheet-body {
  padding: 14px 16px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* Formulário de Denúncia */
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  padding: 11px 13px;
  font-family: inherit;
}
.textarea { min-height: 82px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--fire);
}

.loc-box {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 14px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loc-coords {
  font-size: 12px;
  color: #bfdbfe;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.loc-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-secondary {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
}

.btn-primary {
  min-height: 52px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff6b2b 0%, #dc2626 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
}

.tipo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tipo-btn {
  min-height: 50px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tipo-btn.active {
  border-color: var(--fire);
  background: rgba(255, 90, 31, 0.2);
  color: #fff;
}

.upload-box {
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  display: block;
}

.upload-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 10px;
  margin-top: 8px;
  display: none;
  object-fit: cover;
}

/* Card de Sigilo / Fogo Criminoso */
.crime-box {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.switch-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--fire);
  flex-shrink: 0;
}

.sigilo-badge {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
  font-size: 12px;
  line-height: 1.4;
  padding: 9px 10px;
  border-radius: 10px;
}

/* Cards de Lista de Focos */
.foco-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
}

.foco-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.badge-ativo { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-em_atendimento { background: rgba(245, 158, 11, 0.22); color: #fcd34d; }
.badge-controlado { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge-demo { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.detail-photo {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.bombeiro-note {
  background: rgba(245, 158, 11, 0.14);
  border-left: 3px solid var(--amber);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: #fde68a;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 900;
  background: #0f172a;
  color: #fff;
  border: 1px solid var(--fire);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  display: none;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
}
.toast.show { display: block; }

/* Ocultar controles padrão do Leaflet que atrapalham o polegar */
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(11, 17, 26, 0.65) !important;
  color: #94a3b8 !important;
  margin-bottom: calc(74px + var(--safe-bottom)) !important;
}
.leaflet-control-attribution a { color: #cbd5e1 !important; }
