:root {
  --navy: #0b2545;
  --navy-light: #13345f;
  --green-bg: #e3f6ec;
  --green-text: #1a7a4c;
  --blue-bg: #e5f1fd;
  --blue-text: #1660b0;
  --orange-bg: #fdecdc;
  --orange-text: #b8560f;
  --purple-bg: #efe7fb;
  --border: #dbe2ea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: #f3f5f8;
  color: #1c2733;
}

.topbar {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h1 { font-size: 20px; margin: 0; font-weight: 600; }
.logo { font-size: 24px; }
.user { font-size: 14px; opacity: 0.9; }

.filters {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field label { font-size: 12px; font-weight: 600; color: #556; }
.filter-field select, .filter-field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 200px;
}
.periodo-range { display: flex; align-items: center; gap: 6px; }
.periodo-range input { min-width: 130px; }

#analisar-btn {
  margin-left: auto;
  background: var(--navy);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#analisar-btn:hover { background: var(--navy-light); }

.map-card {
  position: relative;
  margin: 20px 24px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
#map { height: 460px; width: 100%; background: #cfe8f3; }

.map-legend {
  position: absolute;
  top: 14px;
  left: 14px;
  background: white;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 1000;
  font-size: 13px;
}
.legend-title { font-weight: 700; margin-bottom: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.legend-note { color: #778; font-size: 11px; margin-top: 4px; max-width: 170px; }
.swatch { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.swatch.light { background: #7dd3fc; border: 1px solid #0284c7; }
.swatch.dark { background: #1e3a5f; border: 1px solid #0b1f3a; }

.map-status {
  position: absolute;
  bottom: 10px;
  left: 14px;
  background: rgba(255,255,255,0.9);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #445;
  z-index: 1000;
}

.panel-section {
  margin: 20px 24px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: white;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
}
.header-blue { background: var(--blue-bg); }
.header-purple { background: var(--purple-bg); }
.panel-icon { font-size: 22px; }
.panel-header h2 { margin: 0 0 2px 0; font-size: 18px; }
.panel-header p { margin: 0; font-size: 13px; color: #556; }

.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.6fr;
  gap: 16px;
  padding: 18px 20px;
}
.metric-card { border-radius: 8px; padding: 14px 16px; }
.card-green { background: var(--green-bg); }
.card-blue { background: var(--blue-bg); }
.card-orange { background: var(--orange-bg); }
.metric-label { font-size: 13px; font-weight: 600; color: #345; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 700; }
.metric-trend { font-size: 12px; margin-top: 6px; color: #778; }
.metric-trend .arrow-down { color: #1a7a4c; font-weight: 700; }
.metric-trend .arrow-up { color: #c0392b; font-weight: 700; }
.card-green .metric-value { color: var(--green-text); }
.card-blue .metric-value { color: var(--blue-text); }
.card-orange .metric-value { color: var(--orange-text); }

.card-chart {
  background: #fafbfc;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.r-badge {
  background: #eef1f5;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
}
.card-chart canvas { flex: 1; max-height: 160px; }

.panel-meta {
  padding: 0 20px 16px;
  font-size: 12px;
  color: #667;
}

@media (max-width: 900px) {
  .cards-row { grid-template-columns: 1fr 1fr; }
}

/* --- Areas de interesse (AOI) ------------------------------------------- */
.swatch.aoi { background: rgba(180, 83, 9, 0.12); border: 2px solid #b45309; }

.escopo-badge {
  position: absolute;
  bottom: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.94);
  padding: 4px 8px 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: #223;
  z-index: 1000;
  max-width: 60%;
}
.escopo-badge b { font-weight: 700; }
.escopo-limpar {
  border: none;
  background: #eef1f5;
  color: #445;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}
.escopo-limpar:hover { background: #dbe2ea; color: #111; }

/* --- Filtros: dia (espacial) x periodo (temporal) ----------------------- */
.filter-hint { font-weight: 400; color: #8a94a0; }

/* --- Card de grafico duplo (painel temporal) --------------------------- */
.chart-duplo canvas { max-height: 110px; }
.chart-duplo canvas + canvas { margin-top: 6px; }

/* Estado "aguardando selecao" do painel temporal */
.panel-section.aguardando .cards-row { opacity: 0.45; }
.panel-section.aguardando .panel-meta { color: #b45309; font-weight: 600; }
