:root {
  --qe-blue: #1d5da4;
  --qe-navy: #1b1b1d;
  --qe-green: #26b08c;
  --qe-amber: #ff802c;
  --qe-red: #ff430a;
  --qe-red-deep: #991b1b;
  --qe-soil: #7b3f00;
  --qe-water: #0277bd;
  --qe-muted: #6a7282;
  --qe-panel-border: #f3f4f6;
  --qe-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  --qe-sidebar-icon-idle-filter: brightness(0) saturate(100%) invert(45%) sepia(10%) saturate(384%) hue-rotate(184deg) brightness(93%) contrast(89%);
}

.overview-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--qe-navy);
}

/* =======================================================
   F1.2: o carrossel de qualidade do ar saiu (grid de 3 colunas — ver
   card_qualidade_ar.css:.qualidade-cards-row). O bloco antigo (flex +
   scroll-snap + botões de carrossel escopados a .qualidade-ar-section)
   foi removido daqui porque conflitava com o novo layout em grid (mesma
   classe .qualidade-cards-row, mesmo seletor). .carousel-btn/.carousel-track
   "genéricos" (sem escopo de .qualidade-ar-section) continuam em uso por
   OUTRAS páginas (vale_gavea.html, matteo_ricci.html, casa_inovacao.html,
   dados_agua.html) — não tocados.
   ======================================================= */

.overview-carousel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.overview-carousel-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--qe-blue);
}

.overview-carousel-container {
  position: relative;
  width: 100%;
}

.overview-carousel-container .carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: var(--qe-blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.overview-carousel-container .carousel-btn.left {
  left: 6px;
}

.overview-carousel-container .carousel-btn.right {
  right: 6px;
}

.overview-carousel-container .carousel-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.overview-carousel-container .carousel-btn:not(:disabled):hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}

.overview-carousel-container .carousel-track {
  display: flex;
  gap: 16px;
  padding: 8px 48px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.overview-carousel-container .carousel-track::-webkit-scrollbar {
  display: none;
}

.overview-carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.overview-carousel-dots .carousel-dot {
  width: 12px;
  height: 12px;
}

.overview-carousel-loading {
  width: 100%;
  text-align: center;
  padding: 50px 0;
  color: var(--qe-muted);
  font-size: 14px;
}

.overview-card {
  flex: 0 0 clamp(280px, 30vw, 340px);
  scroll-snap-align: start;
  border-radius: 16px;
  border: 2px solid #e5e7eb;
  background: #fff;
  padding: 20px;
  box-shadow: var(--qe-shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  animation: overview-rise 0.45s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.overview-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

.overview-card__top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.overview-card__aqi {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
}

.overview-card__aqi-circle {
  width: 50px;
  height: 50px;
  border-radius: 999px;
  background: #d1d5db;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 22px;
}

.overview-card__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.overview-card__site {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--qe-blue);
}

.overview-card__site a {
  color: inherit;
  text-decoration: none;
}

.overview-card__status {
  font-weight: 600;
  color: var(--qe-navy);
}

.overview-card__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 300;
  color: var(--qe-navy);
}

.overview-card__live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--qe-green);
}

.overview-card__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  font-size: 13px;
  color: var(--qe-navy);
}

.overview-card__metrics > .overview-card__metric:nth-child(even) {
  align-items: flex-end;
  text-align: right;
}

.overview-card__metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overview-card__metric-label {
  font-weight: 600;
}

.overview-card__metric-value {
  font-weight: 300;
}

.overview-card__metric.is-warn .overview-card__metric-label {
  color: var(--qe-red);
}

.overview-card--bom { --status-color: var(--qe-green); }
.overview-card--moderado { --status-color: var(--qe-amber); }
.overview-card--ruim { --status-color: var(--qe-red); }
.overview-card--muito-ruim { --status-color: #e65648; }
.overview-card--pessimo { --status-color: var(--qe-red-deep); }

.overview-card[class*="overview-card--"] {
  border-color: var(--status-color);
}

.overview-card[class*="overview-card--"] .overview-card__aqi-circle {
  background: var(--status-color);
}

@keyframes overview-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.overview-panels {
  --overview-divider-size: 14px;
  --overview-camera-width: 380px;
  --overview-camera-min: 320px;
  --overview-map-min: 420px;
  display: grid;
  grid-template-columns:
    minmax(var(--overview-map-min), 1fr)
    var(--overview-divider-size)
    minmax(var(--overview-camera-min), var(--overview-camera-width));
  /* F1.4 · auditoria AA: fundo ficou hardcoded em #fff desde antes da F1.1
     (nunca migrado para os tokens, ao contrário de .overview-panel/.card
     internos) — no tema escuro o card inteiro (mapa + painel de alertas)
     continuava branco enquanto o texto por dentro já usava cores claras
     de --tx/--mu/--ac do tema escuro, dando pares quase ilegíveis (ex.:
     .alert-item-message ~1.17:1). var(--sf) é idêntico a #fff no tema
     claro (mesma aparência) e passa a acompanhar o escuro corretamente. */
  background: var(--sf);
  border-radius: 16px;
  box-shadow: var(--qe-shadow);
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.panel-divider {
  position: relative;
  background: #f3f4f6;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.panel-divider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 100%;
  transform: translateX(-50%);
  background: #d1d5db;
}

.panel-divider::after {
  content: '\22EE';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 38px;
  border-radius: 999px;
  background: #fff;
  color: #94a3b8;
  font-size: 14px;
  line-height: 38px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.panel-divider:hover::after,
.panel-divider.is-dragging::after {
  color: var(--qe-blue);
}

body.is-resizing-panels,
body.is-resizing-panels * {
  cursor: col-resize !important;
}

.overview-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--qe-panel-border);
  gap: 16px;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  /* F1.4 · auditoria AA: --qe-blue é um token legado fixo (#1d5da4, nunca
     migrado para o sistema de tema) — passava sem problema no claro
     (sobre o fundo branco de .overview-panels), mas ficou 2.54:1 no
     escuro assim que .overview-panels passou a usar --sf de verdade (ver
     index.css, correção do fundo branco fixo). var(--ac) é o token
     equivalente que já adapta por tema (claro = mesmo #1D5DA4, sem
     mudança visual; escuro = #6FAEEA, legível sobre --sf escuro). */
  color: var(--ac);
}

.panel-icon-btn {
  border: none;
  background: #f0f0f0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.panel-icon-btn img {
  width: 16px;
  height: 16px;
}

.map-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* F1.2: pill toggles "Ar · N"/"Solo · N"/"Água · N" sobre os tokens do
   design system (design-tokens.css, F1.1) — dot colorido por tipo de
   sensor (--sn-ar/--sn-solo/--sn-agua) e estado ativo = fundo --as + borda
   --ac (não mais fundo sólido colorido por tipo). Substitui o pill antigo
   (ícone mascarado + fundo colorido sólido), que não usava os tokens.
   As contagens (data-count-for) continuam vindo de camera-switcher.js, a
   partir dos marcadores REAIS do mapa (settings.CAMERAS) — ver decisão em
   docs/RELATORIO-FASE1.md sobre a cobertura parcial dessa fonte (não há
   marcador de água hoje). */
.map-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--bd);
  box-sizing: border-box;
  background: var(--sf);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--mu);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.map-filter:hover {
  transform: translateY(-1px);
}

.map-filter.is-active {
  background: var(--as);
  border-color: var(--ac);
  color: var(--ac);
}

.map-filter__dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.map-filter__dot--air { background: var(--sn-ar); }
.map-filter__dot--soil { background: var(--sn-solo); }
.map-filter__dot--water { background: var(--sn-agua); }

.map-filter__label {
  line-height: 18px;
}

/* F1.4 · auditoria AA: --mu3 sobre --sf dá 2.56:1 — abaixo de 4.5:1, mas
   é o separador "·" puramente visual entre o rótulo e a contagem de cada
   pill do mapa; já marcado aria-hidden="true" no template (index.html) e
   não carrega informação própria (a contagem já está em
   .map-filter__count, lido separadamente pelo leitor de tela). Exceção
   documentada (WCAG permite para conteúdo decorativo) — não corrigido. */
.map-filter__sep {
  color: var(--mu3);
}

.map-filter__count {
  font-weight: 700;
}

.panel-body {
  flex: 1;
  position: relative;
}

.map-body {
  background: #e8ecef;
  overflow: hidden;
}

.map-canvas {
  width: 100%;
  height: 100%;
}

.map-body .leaflet-container {
  width: 100%;
  height: 100%;
  background: #e8ecef;
}

.map-body .leaflet-tile {
  filter: saturate(0.85);
}

.map-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 11px;
  color: #4a5565;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.map-legend-dot.air { background: var(--qe-green); }
.map-legend-dot.soil { background: var(--qe-soil); }
.map-legend-dot.water { background: var(--qe-water); }

.camera-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: var(--qe-muted);
  height: 100%;
}

.camera-body.has-camera {
  padding: 16px;
  gap: 0;
  align-items: stretch;
  justify-content: flex-start;
}

.camera-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 260px;
}

.camera-empty.is-hidden {
  display: none;
}

.camera-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #f3f4f6;
  display: grid;
  place-items: center;
}

.camera-empty-icon img {
  width: 26px;
  height: 26px;
}

.camera-empty-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.camera-empty-text strong {
  color: #364153;
  font-weight: 600;
}

.camera-pane {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #0b0b0b;
  display: none;
  position: relative;
}

.camera-body.has-camera .camera-pane {
  display: block;
  flex: 1;
  aspect-ratio: auto;
  height: 100%;
}

.camera-body.has-camera .camera-summary,
.camera-body.has-camera .camera-empty {
  display: none;
}

.camera-pane.is-visible {
  display: block;
}

.camera-pane #main-camera-player,
.camera-pane #main-camera-iframe {
  width: 100%;
  height: 100% !important;
  display: block;
  object-fit: cover;
  border: 0;
  background: #000;
}

.camera-pane #camera-offline-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  text-align: center;
  padding: 12px;
}

.camera-summary {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.camera-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 500;
}

.camera-summary-item img {
  width: 14px;
  height: 14px;
  filter: var(--qe-sidebar-icon-idle-filter);
}

.camera-summary-air {
  background: #e8f8f4;
  color: var(--qe-green);
}

.camera-summary-soil {
  background: #f5ede6;
  color: var(--qe-soil);
}

.camera-summary-water {
  background: #e3f2fd;
  color: var(--qe-water);
}

@media (max-width: 1200px) {
  .overview-panels {
    grid-template-columns: 1fr;
  }

  .panel-divider {
    display: none;
  }

  .overview-panel {
    min-height: auto;
  }

  .map-body {
    min-height: 360px;
  }
}

body.is-map-expanded {
  overflow: hidden;
}

.overview-panels.is-expanded {
  position: fixed;
  inset: 16px;
  width: auto;
  height: auto;
  z-index: 1200;
}

.overview-panels.is-expanded .overview-panel {
  min-height: 0;
}

@media (max-width: 768px) {
  .overview-carousel-container .carousel-track {
    padding: 8px 36px;
  }

  .overview-card {
    flex: 0 0 85vw;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-filters {
    flex-wrap: wrap;
  }
}
