/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
  --brand-900: #0a2e14;
  --brand-800: #0f3d1c;
  --brand-700: #165a28;
  --brand-600: #1b7a35;
  --brand-500: #22963f;
  --brand-400: #34d058;
  --brand-300: #6ede8a;
  --brand-200: #b7efc5;
  --brand-100: #e3f9e5;
  --brand-50:  #f0fdf4;

  --n-950: #0c0f12;
  --n-900: #111827;
  --n-800: #1e293b;
  --n-700: #334155;
  --n-600: #475569;
  --n-500: #64748b;
  --n-400: #94a3b8;
  --n-300: #cbd5e1;
  --n-200: #e2e8f0;
  --n-100: #f1f5f9;
  --n-50:  #f8fafc;
  --white: #ffffff;

  --accent: #3b82f6;
  --accent-light: #dbeafe;

  --surface-0: #ffffff;
  --surface-1: #f8fafc;
  --surface-2: #f1f5f9;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-panel: -1px 0 0 var(--n-200), 0 0 30px rgba(0,0,0,0.04);

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-normal: 250ms;

  --header-h: 56px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--surface-1);
  color: var(--n-800);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-container {
  display: grid;
  grid-template-columns: 1fr 520px;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "header header"
    "map    panel";
  height: 100vh;
  width: 100%;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  grid-area: header;
  background: var(--brand-900);
  color: var(--white);
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-400), var(--accent), var(--brand-400));
  opacity: 0.4;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.logo-img {
  height: 34px;
  width: auto;
  border-radius: var(--r-md);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.3px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.logo-text span {
  font-weight: 400;
  opacity: 0.5;
  font-size: 0.9em;
}

.logo-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  margin: 0 var(--sp-2);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.meta-info {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: rgba(255,255,255,0.75);
  font-variant-numeric: tabular-nums;
}

.meta-window-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: var(--r-full);
  background: rgba(255, 200, 100, 0.18);
  color: #ffd28a;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ============================================================
   FILTRO TEMPORAL — header
   ============================================================ */
.temporal-filter {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-full);
}

.tf-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--dur-fast) var(--ease-out);
  min-width: 32px;
  justify-content: center;
}

.tf-btn:hover {
  background: rgba(255,255,255,0.10);
  color: var(--white);
}

.tf-btn.active {
  background: rgba(76, 175, 152, 0.25);
  color: #c8f0e2;
  box-shadow: inset 0 0 0 1px rgba(76, 175, 152, 0.45);
}

.tf-btn-custom svg {
  opacity: 0.75;
}

.tf-window-info {
  margin-left: 8px;
  padding: 0 8px;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Popover do filtro personalizado */
.tf-popover {
  position: fixed;
  z-index: 1500;
  width: 280px;
  background: #1b2530;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  padding: 14px;
  color: rgba(255,255,255,0.85);
  font-size: 0.78rem;
}

.tf-popover[hidden] { display: none; }

.tf-popover-header {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  color: var(--white);
}

.tf-popover-hint {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.35;
  margin-bottom: 10px;
}

.tf-popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.tf-popover-row label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  min-width: 110px;
}

.tf-popover-row input,
.tf-popover-row select {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--white);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-family: inherit;
}

/* O dropdown nativo do <select> renderiza o <option> com cores do SO.
   Quando o trigger tem fundo escuro e cor branca, o dropdown abre com
   letra branca em fundo branco. Forçamos contraste explícito. */
.tf-popover-row select option {
  background-color: #1a2331;
  color: #ffffff;
  font-weight: 500;
}

.tf-popover-row select option:checked,
.tf-popover-row select option:hover {
  background-color: #4caf98;
  color: #062018;
}

.tf-popover-row select:disabled,
.tf-popover-row input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tf-popover-row input:focus,
.tf-popover-row select:focus {
  outline: none;
  border-color: rgba(76, 175, 152, 0.6);
  background: rgba(76, 175, 152, 0.08);
}

.tf-popover-divider {
  position: relative;
  text-align: center;
  margin: 12px 0 8px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.4);
}

.tf-popover-divider::before,
.tf-popover-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.tf-popover-divider::before { left: 0; }
.tf-popover-divider::after { right: 0; }

.tf-popover-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.tf-pop-btn-cancel,
.tf-pop-btn-apply,
.tf-pop-btn-clear {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease-out);
  border: 1px solid transparent;
}

.tf-pop-btn-clear {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.12);
  margin-right: auto;
}

.tf-pop-btn-clear:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}

.tf-pop-btn-cancel {
  background: transparent;
  color: rgba(255,255,255,0.6);
  border-color: rgba(255,255,255,0.15);
}

.tf-pop-btn-cancel:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

.tf-pop-btn-apply {
  background: #4caf98;
  color: #062018;
}

.tf-pop-btn-apply:hover {
  background: #6bc5ad;
}

.tf-pop-btn-apply:disabled,
.tf-pop-btn-apply.disabled {
  background: rgba(76, 175, 152, 0.25);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
}

.tf-pop-btn-apply:disabled:hover,
.tf-pop-btn-apply.disabled:hover {
  background: rgba(76, 175, 152, 0.25);
}

.tf-popover-msg {
  margin-top: 10px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.65);
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  line-height: 1.35;
}

.tf-popover-msg.error {
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.12);
}

.btn-reload {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--dur-fast) var(--ease-out);
}

.btn-reload:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
  color: var(--white);
}

.btn-reload:active {
  transform: scale(0.97);
}

/* ============================================================
   MAP
   ============================================================ */
.map-container {
  grid-area: map;
  position: relative;
  background: var(--n-200);
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-control-zoom a {
  font-family: var(--font-sans) !important;
  background: var(--white) !important;
  color: var(--n-700) !important;
  border-color: var(--n-200) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
  box-shadow: var(--shadow-sm) !important;
  transition: all var(--dur-fast) ease !important;
}

.leaflet-control-zoom a:hover {
  background: var(--n-50) !important;
  color: var(--n-900) !important;
}

.leaflet-control-zoom {
  border: none !important;
  border-radius: var(--r-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
}

/* ============================================================
   MAP LEGEND
   ============================================================ */
.leaflet-control-custom-legend {
  background: var(--white);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--n-200);
  line-height: 1.9;
}

.leaflet-control-custom-legend > div:first-child {
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--n-600);
  margin-bottom: var(--sp-1);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--n-100);
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.06);
}

/* ============================================================
   SIDE PANEL
   ============================================================ */
.app-panel {
  grid-area: panel;
  background: var(--white);
  border-left: 1px solid var(--n-200);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-panel);
}

.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--n-400);
  gap: var(--sp-5);
  height: 100%;
}

.panel-empty svg {
  opacity: 0.3;
  stroke-width: 1;
}

.panel-empty p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--n-500);
}

.panel-empty p strong {
  color: var(--n-700);
  font-weight: 600;
}

.panel-content {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  animation: panelSlideIn 0.35s var(--ease-out);
}

/* ============================================================
   STATION HEADER CARD
   ============================================================ */
.station-header {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  border: 1px solid var(--n-200);
  position: relative;
  overflow: hidden;
}

.station-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-600), var(--brand-400));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.station-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--n-900);
  letter-spacing: -0.3px;
  margin-bottom: var(--sp-1);
}

.station-coords {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--n-400);
  margin-bottom: var(--sp-3);
}

.station-meta-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.class-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: var(--r-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.iec-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--n-600);
  background: var(--white);
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--n-200);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   MONTH SELECTOR
   ============================================================ */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
}

.month-selector label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--n-400);
}

select.month-picker {
  background: var(--white);
  border: 1px solid var(--n-200);
  border-radius: var(--r-md);
  padding: 7px 32px 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--n-900);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--dur-fast) ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* Força contraste dentro do dropdown — alguns navegadores/SOs renderizam
   o <option> com cores do tema e ficam letra-fundo iguais. */
select.month-picker option {
  background-color: #ffffff;
  color: #111827;
  font-weight: 500;
}

select.month-picker option:checked,
select.month-picker option:hover {
  background-color: var(--brand-100);
  color: var(--brand-900);
}

select.month-picker:hover {
  border-color: var(--n-300);
}

select.month-picker:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(34,150,63,0.1);
}

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.kpi-card {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-3);
  text-align: center;
  transition: all var(--dur-normal) var(--ease-out);
  border: 1px solid var(--n-100);
}

.kpi-card:hover {
  border-color: var(--n-200);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--n-600);
  margin-bottom: var(--sp-2);
  line-height: 1.2;
  min-height: 2em;
}

.kpi-label .label-friendly {
  color: var(--n-700);
  letter-spacing: 0;
}

.kpi-label .label-tech {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--n-400);
  text-transform: none;
  letter-spacing: 0.3px;
  display: block;
  width: 100%;
}

.kpi-label .info-tip {
  color: var(--n-400);
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--n-900);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.kpi-unit {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--n-400);
  margin-left: 1px;
}

/* ============================================================
   INTERPRETATION BOX
   ============================================================ */
.interpret-box {
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  padding-left: calc(var(--sp-5) + 8px);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--n-700);
  position: relative;
}

.interpret-box::before {
  content: '';
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
  width: 3px;
  bottom: var(--sp-4);
  background: var(--brand-400);
  border-radius: var(--r-full);
  opacity: 0.6;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 3px;
  border: 1px solid var(--n-100);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 8px var(--sp-4);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--n-500);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
}

.tab-btn.active {
  color: var(--n-900);
  background: var(--white);
  box-shadow: var(--shadow-xs);
}

.tab-btn:hover:not(.active) {
  color: var(--n-700);
  background: rgba(255,255,255,0.5);
}

.tab-pane {
  display: none;
  animation: tabFadeIn 0.3s var(--ease-out);
}

.tab-pane.active {
  display: block;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
  margin-bottom: var(--sp-6);
}

.chart-container:last-child {
  margin-bottom: 0;
}

.chart-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--n-700);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  line-height: 1.3;
}

.chart-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--brand-500);
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.chart-title .label-friendly {
  color: var(--n-800);
  font-weight: 600;
}

.chart-title .label-tech {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--n-400);
  text-transform: none;
  letter-spacing: 0.3px;
  margin-left: auto;
}

.chart-wrapper {
  height: 180px;
  position: relative;
  background: var(--surface-1);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-2) var(--sp-1) 0;
  border: 1px solid var(--n-100);
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--n-200);
  background: var(--white);
  box-shadow: var(--shadow-xs);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--n-100);
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: inherit;
  font-weight: 600;
  padding-left: var(--sp-4);
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: var(--sp-4);
}

.data-table th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--n-600);
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--n-200);
}

.data-table tr.current-month {
  background: var(--brand-50);
}

.data-table tbody tr {
  transition: background var(--dur-fast) ease;
}

.data-table tbody tr:hover {
  background: var(--n-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .class-badge {
  font-size: 0.58rem;
  padding: 2px 8px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
.app-panel::-webkit-scrollbar {
  width: 6px;
}

.app-panel::-webkit-scrollbar-track {
  background: transparent;
}

.app-panel::-webkit-scrollbar-thumb {
  background: var(--n-200);
  border-radius: var(--r-full);
}

.app-panel::-webkit-scrollbar-thumb:hover {
  background: var(--n-300);
}

/* ============================================================
   FRIENDLY UI — INFO TIPS, GLOSSARY, INTERPRETATION
   ============================================================ */

/* Ícone "ℹ" inline ao lado de rótulos */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--r-full);
  color: var(--n-400);
  cursor: help;
  transition: all var(--dur-fast) ease;
  background: var(--n-100);
  flex-shrink: 0;
}

.info-tip:hover,
.info-tip:focus-visible {
  color: var(--brand-600);
  background: var(--brand-100);
  outline: none;
}

.info-tip svg {
  pointer-events: none;
}

/* Tooltip flutuante (posicionado por JS) */
.floating-tip {
  position: absolute;
  z-index: 10000;
  max-width: 260px;
  background: var(--n-900);
  color: #f1f5f9;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out);
  pointer-events: none;
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.floating-tip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Botão no cabeçalho: "Entender indicadores" */
.btn-glossary {
  background: rgba(52, 208, 88, 0.14);
  border: 1px solid rgba(52, 208, 88, 0.28);
  cursor: pointer;
  color: #b7efc5;
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--dur-fast) var(--ease-out);
}

.btn-glossary:hover {
  background: rgba(52, 208, 88, 0.25);
  border-color: rgba(52, 208, 88, 0.45);
  color: #e3f9e5;
}

.btn-glossary:active {
  transform: scale(0.97);
}

/* Botão discreto "Entender os indicadores" no painel */
.btn-link-help,
.btn-link-help-small {
  background: none;
  border: 1px dashed var(--n-300);
  color: var(--brand-700);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-full);
  transition: all var(--dur-fast) ease;
}

.btn-link-help {
  margin-top: var(--sp-2);
  padding: 8px 16px;
  font-size: 0.78rem;
}

.btn-link-help-small {
  padding: 4px 10px;
  font-size: 0.7rem;
}

.btn-link-help:hover,
.btn-link-help-small:hover {
  background: var(--brand-50);
  border-color: var(--brand-400);
  border-style: solid;
  color: var(--brand-800);
}

/* Título do resumo em linguagem simples */
.interpret-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--brand-700);
  margin-bottom: var(--sp-2);
}

.interpret-box {
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
}

.interpret-box b {
  color: var(--n-900);
  font-weight: 700;
}

/* Seção de KPIs com cabeçalho */
.kpi-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.kpi-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--n-500);
}

/* Badge IEC no cabeçalho da estação */
.iec-value {
  cursor: help;
}

/* Tabela: cabeçalhos com sigla técnica pequena */
.data-table th .th-tech {
  display: block;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.56rem;
  color: var(--n-400);
  text-transform: none;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.data-table th {
  cursor: help;
}

.table-hint {
  font-size: 0.72rem;
  color: var(--n-500);
  margin-bottom: var(--sp-3);
  font-style: italic;
}

/* Legenda do mapa — títulos amigáveis */
.leaflet-control-custom-legend .legend-title {
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--n-800);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 2px;
  padding-bottom: 0;
  border: none;
}

.leaflet-control-custom-legend .legend-subtitle {
  font-size: 0.62rem;
  color: var(--n-500);
  font-weight: 400;
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--n-100);
}

.leaflet-control-custom-legend > div:first-child {
  /* sobrescreve estilo antigo */
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--n-800);
  border: none;
  padding: 0;
  margin-bottom: 0;
}

/* ============================================================
   SPEI CHART — taller to fit integrated legend
   ============================================================ */
.chart-wrapper-tall {
  height: 220px;
}

/* SPEI inline legend — compact color-coded grid */
.spei-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: var(--sp-2);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--n-100);
}

.spei-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--surface-1);
  border-right: 1px solid var(--n-100);
  border-bottom: 1px solid var(--n-100);
}

/* Remove right border on last column */
.spei-legend-item:nth-child(4n) {
  border-right: none;
}

/* Remove bottom border on last row */
.spei-legend-item:nth-child(n+5) {
  border-bottom: none;
}

.spei-leg-color {
  width: 8px;
  height: 24px;
  border-radius: 3px;
  flex-shrink: 0;
}

.spei-leg-text {
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--n-600);
  font-weight: 500;
  white-space: normal;
  min-width: 0;
}

.spei-leg-range {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--n-400);
}

/* SPEI legend color assignments */
.spei-leg-extwet  .spei-leg-color { background: #1565c0; border: 1px solid #0d47a1; }
.spei-leg-verywet .spei-leg-color { background: #2196f3; border: 1px solid #1976d2; }
.spei-leg-wet     .spei-leg-color { background: #90caf9; border: 1px solid #64b5f6; }
.spei-leg-normal  .spei-leg-color { background: #f5f5f5; border: 1px solid #cbd5e1; }
.spei-leg-dry     .spei-leg-color { background: #ffcdd2; border: 1px solid #ef9a9a; }
.spei-leg-verydry .spei-leg-color { background: #ef5350; border: 1px solid #d32f2f; }
.spei-leg-extdry  .spei-leg-color { background: #c62828; border: 1px solid #b71c1c; }

/* Stack legend on narrow screens */
@media (max-width: 600px) {
  .spei-legend {
    grid-template-columns: repeat(2, 1fr);
  }
  .spei-legend-item:nth-child(4n) {
    border-right: 1px solid var(--n-100);
  }
  .spei-legend-item:nth-child(2n) {
    border-right: none;
  }
  .spei-legend-item:nth-child(n+5) {
    border-bottom: 1px solid var(--n-100);
  }
  .spei-legend-item:nth-child(n+7) {
    border-bottom: none;
  }
  .spei-leg-color {
    width: 6px;
    height: 18px;
  }
}

/* ============================================================
   MODAL — GLOSSÁRIO "ENTENDA OS INDICADORES"
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 46, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  animation: fadeIn 0.2s var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--white);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0,0,0,0.24);
  overflow: hidden;
  animation: slideUp 0.28s var(--ease-out);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--n-100);
  background: var(--surface-1);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--n-900);
  letter-spacing: -0.2px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--n-500);
  padding: 6px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  transition: all var(--dur-fast) ease;
}

.modal-close:hover {
  background: var(--n-100);
  color: var(--n-800);
}

.modal-body {
  padding: var(--sp-5) var(--sp-6);
  overflow-y: auto;
  flex: 1;
}

.modal-body h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--brand-700);
  margin-top: var(--sp-5);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--n-100);
}

.modal-body h3:first-of-type {
  margin-top: 0;
}

.modal-intro {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--n-600);
  margin-bottom: var(--sp-5);
  padding: var(--sp-4);
  background: var(--brand-50);
  border-radius: var(--r-md);
  border-left: 3px solid var(--brand-400);
}

.modal-subintro {
  font-size: 0.8rem;
  color: var(--n-600);
  margin-bottom: var(--sp-3);
  line-height: 1.5;
}

.gloss-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.gloss-item {
  background: var(--surface-1);
  border: 1px solid var(--n-100);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  transition: border-color var(--dur-fast) ease;
}

.gloss-item:hover {
  border-color: var(--brand-200);
}

.gloss-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  flex-wrap: wrap;
}

.gloss-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--n-900);
}

.gloss-tech {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--n-500);
  background: var(--white);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--n-200);
}

.gloss-help {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--n-600);
}

/* Scrollbar do modal */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--n-200);
  border-radius: var(--r-full);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "map"
      "panel";
    grid-template-rows: var(--header-h) 1fr auto;
  }

  .app-panel {
    max-height: 55vh;
    border-left: none;
    border-top: 1px solid var(--n-200);
    box-shadow: 0 -4px 15px rgba(0,0,0,0.06);
  }

  .header-tools .meta-info {
    display: none;
  }

  .logo-divider {
    display: none;
  }

  /* Em telas estreitas: esconde a info da janela e o texto do botão "Personalizar" */
  .tf-window-info { display: none; }
  .tf-btn-custom span { display: none; }
  .tf-btn-custom { padding: 4px 8px; position: relative; }

  /* Quando o filtro custom está ativo em mobile, mostra um ponto verde
     pra avisar que tem algo aplicado (já que o texto fica escondido). */
  .tf-btn-custom.active::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6bc5ad;
    box-shadow: 0 0 0 2px var(--brand-900);
  }

  .tf-popover {
    width: calc(100vw - 24px);
    right: 12px !important;
    left: 12px;
  }

  /* Em telas estreitas, esconde texto dos botões — fica só o ícone */
  .btn-glossary .btn-text,
  .btn-reload .btn-text {
    display: none;
  }

  .btn-glossary,
  .btn-reload {
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0 var(--sp-4);
  }

  .panel-content {
    padding: var(--sp-4);
  }

  .kpi-grid {
    gap: var(--sp-2);
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  .modal-card {
    max-height: 90vh;
  }

  .modal-header,
  .modal-body {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }

  .chart-title .label-tech {
    margin-left: 0;
  }
}

@media (min-width: 360px) and (max-width: 480px) {
  .app-header {
    flex-direction: row;
    gap: var(--sp-3);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  .logo-text span{
    display: none;
  }

  .temporal-filter-label{
    display: none;
  }

  .splash-title {
    font-size: 1.8rem;
  }

  .splash-subtitle {
    font-size: 0.75rem;
    letter-spacing: 2px;
  }

  .splash-progress-wrap {
    width: 100%;
  }
}

@media (max-width: 1024px){
  .app-header {
    flex-direction: row;
    gap: var(--sp-3);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
  }
  .logo-text span {
    display: none;
  }
  .meta-info {
    display: none;
  }

}

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
#splash {
  position: fixed;
  inset: 0;
  background: var(--brand-900);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s var(--ease-out), visibility 0.6s var(--ease-out);
  font-family: var(--font-sans);
}

#splash::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(34,150,63,0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 30%, rgba(59,130,246,0.08) 0%, transparent 50%);
  animation: splashBg 4s ease-in-out infinite alternate;
}

@keyframes splashBg {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

#splash.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  animation: splashFadeIn 0.8s var(--ease-out);
  position: relative;
  z-index: 1;
}

.splash-logo {
  width: 100px;
  height: auto;
  margin-bottom: var(--sp-6);
  border-radius: var(--r-xl);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.splash-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.5px;
  margin-bottom: var(--sp-1);
}

.splash-subtitle {
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(255,255,255,0.45);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: var(--sp-10);
}

.splash-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top: 2px solid var(--brand-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--sp-4);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.splash-loading-text {
  color: rgba(255,255,255,0.35);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ---- Barra de progresso ---- */
.splash-progress-wrap {
  width: 320px;
  max-width: 80vw;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: var(--sp-6) auto var(--sp-3);
  position: relative;
}
.splash-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-400), #6ee7a3);
  border-radius: 999px;
  transition: width 0.35s ease-out;
  box-shadow: 0 0 12px rgba(110,231,163,0.35);
}
.splash-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 320px;
  max-width: 80vw;
  margin: 0 auto var(--sp-6);
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.55);
}
.splash-progress-meta #splashProgressPercent {
  color: var(--brand-400);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.splash-progress-meta #splashProgressLabel {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 1.2px;
  opacity: 0.7;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Lista de etapas ---- */
.splash-steps {
  list-style: none;
  padding: 0;
  margin: var(--sp-4) auto 0;
  width: 320px;
  max-width: 80vw;
  text-align: left;
  font-size: 0.78rem;
}
.splash-steps li {
  position: relative;
  padding: var(--sp-2) 0 var(--sp-2) 22px;
  color: rgba(255,255,255,0.35);
  transition: color 0.25s ease;
}
.splash-steps li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: transparent;
  transition: all 0.25s ease;
}
.splash-steps li.active {
  color: rgba(255,255,255,0.92);
}
.splash-steps li.active::before {
  border-color: var(--brand-400);
  background: var(--brand-400);
  box-shadow: 0 0 0 4px rgba(52,208,88,0.18);
  animation: stepPulse 1.4s ease-in-out infinite;
}
.splash-steps li.done {
  color: rgba(255,255,255,0.55);
}
.splash-steps li.done::before {
  border-color: var(--brand-400);
  background: var(--brand-400);
  box-shadow: none;
  animation: none;
}
.splash-steps li.done::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  width: 5px;
  height: 8px;
  border-right: 1.5px solid #0a2e14;
  border-bottom: 1.5px solid #0a2e14;
  transform: translateY(-65%) rotate(45deg);
}
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(52,208,88,0.18); }
  50%      { box-shadow: 0 0 0 8px rgba(52,208,88,0.05); }
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TEMPERATURE KPI GRID (3 columns)
   ============================================================ */
.kpi-grid-3 {
  grid-template-columns: repeat(3, 1fr) !important;
}

.kpi-card-temp {
  background: var(--surface-1) !important;
  border-left: 3px solid var(--n-300) !important;
  border-right: none !important;
}

.kpi-value-cool {
  color: #1976d2 !important;
}

.kpi-value-warm {
  color: #d84315 !important;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes panelSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DYNAMIC KPI CARDS — cor por indicador
   ============================================================ */
.kpi-card-dyn {
  position: relative;
  padding-bottom: calc(var(--sp-4) + 18px);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.kpi-card-dyn .kpi-value {
  /* a cor é injetada via style inline — sobrescreve a regra genérica */
  transition: color var(--dur-normal) var(--ease-out);
}

.kpi-card-dyn .kpi-unit {
  color: inherit;
  opacity: 0.65;
}

.kpi-badge {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--r-full);
  white-space: nowrap;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.kpi-card-dyn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* IEC pill no cabeçalho: borda colorida via inline style */
.iec-value {
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 2px 10px;
  transition: color var(--dur-normal) var(--ease-out),
              border-color var(--dur-normal) var(--ease-out);
}


/* ============================================================
   FILTRO TEMPORAL — agora com label "Período analisado"
   ============================================================ */
.temporal-filter-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.temporal-filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  cursor: help;
}
.tf-window-info {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   CARD-RESUMO DA JANELA (no painel de detalhe)
   ============================================================ */
.resumo-janela {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.resumo-janela-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
}
.resumo-janela-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.resumo-janela-periodo {
  font-size: 0.72rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

/* Caixa de "extremo detectado" — chama atenção se a janela tem um pico */
.resumo-extremo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-left: 3px solid;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #334155;
  margin-top: 4px;
}
.resumo-extremo-icon {
  font-size: 1rem;
  line-height: 1;
}
.resumo-extremo-text {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Versão pequena do badge para uso inline */
.class-badge-sm {
  font-size: 0.66rem;
  padding: 1px 7px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: var(--r-full);
  color: #ffffff;
  white-space: nowrap;
}

/* ============================================================
   "Mês em destaque" — bloco que substitui o seletor simples
   ============================================================ */
.month-selector-block {
  background: rgba(46, 125, 50, 0.04);
  border: 1px solid rgba(46, 125, 50, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
  margin: var(--sp-3) 0;
}
.month-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.month-selector-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.info-tip-inline {
  display: inline-flex;
  vertical-align: middle;
  cursor: help;
  color: #94a3b8;
}
.info-tip-inline:hover { color: #64748b; }

.mes-destaque-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.78rem;
  color: #475569;
}
.mes-destaque-label {
  color: #94a3b8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mes-destaque-iec {
  color: #64748b;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  font-size: 0.74rem;
}

/* ============================================================
   Responsivo: filtro temporal em telas estreitas
   ============================================================ */
@media (max-width: 900px) {
  .temporal-filter-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .temporal-filter-label {
    font-size: 0.62rem;
  }
}

/* ============================================================
   TOGGLE "Ver dados do período" ↔ "Ver mês em destaque"
   ============================================================ */
.view-mode-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 10px;
  margin: var(--sp-3) 0 var(--sp-2);
  border: 1px solid #e2e8f0;
}
.view-mode-toggle .vm-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s ease-out;
  font-family: var(--font-sans);
  white-space: nowrap;
}
.view-mode-toggle .vm-btn:hover {
  color: #1e293b;
  background: rgba(255,255,255,0.7);
}
.view-mode-toggle .vm-btn.active {
  background: #ffffff;
  color: var(--brand-700, #1e5e2e);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px rgba(46,125,50,0.15);
}
.view-mode-toggle .vm-btn svg {
  flex-shrink: 0;
  opacity: 0.85;
}

/* Tag pequena nos KPI labels indicando modo (período/média) */
.kpi-mode-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  background: rgba(100, 116, 139, 0.12);
  padding: 1px 6px;
  border-radius: var(--r-full);
  margin-left: 4px;
  vertical-align: middle;
}

/* Sub-títulos dentro da legenda do mapa (Estiagem / Excesso hídrico) */
.leaflet-control-custom-legend .legend-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #94a3b8;
  margin-top: 8px;
  margin-bottom: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.leaflet-control-custom-legend .legend-section-title:first-of-type {
  border-top: none;
  padding-top: 0;
}

@media (max-width: 600px) {
  .view-mode-toggle .vm-btn {
    font-size: 0.72rem;
    padding: 7px 8px;
  }
}

/* ============================================================
   RESUMO DA JANELA — picos múltiplos por classe
   ============================================================ */
.resumo-pct {
  font-size: 0.74rem;
  color: #64748b;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.resumo-picos {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.resumo-pico {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-left: 3px solid;
  border-radius: 6px;
}
.resumo-pico-icon {
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
}
.resumo-pico-body {
  flex: 1;
  min-width: 0;
}
.resumo-pico-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.resumo-pico-count {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
}
.resumo-pico-meses {
  font-size: 0.74rem;
  color: #334155;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
  line-height: 1.45;
  word-break: break-word;
}

/* ============================================================
   Reforço: atributo [hidden] vence display:flex/grid/block
   (alguns navegadores e CSS antigos sobrescrevem o default)
   ============================================================ */
[hidden] { display: none !important; }

/* ============================================================
   RASTER CONTROL + LEGEND (camadas de variáveis no mapa)
   ============================================================ */
.leaflet-control-raster {
  background: var(--white);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--n-200);
  font-family: var(--font-sans);
  width: 210px;
}
.leaflet-control-raster .rc-title {
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--n-600);
  margin-bottom: var(--sp-2);
}
.leaflet-control-raster .rc-select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--n-800);
  padding: 6px 8px;
  border: 1px solid var(--n-200);
  border-radius: var(--r-md);
  background: var(--surface-1);
  cursor: pointer;
}
.leaflet-control-raster .rc-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.leaflet-control-raster .rc-row label {
  font-size: 0.68rem;
  color: var(--n-600);
  white-space: nowrap;
}
.leaflet-control-raster .rc-row input[type="range"] {
  flex: 1;
  accent-color: var(--brand-500);
  cursor: pointer;
  overflow: hidden;
}
.leaflet-control-raster .rc-month {
  font-size: 0.7rem;
  color: var(--n-600);
  margin-top: var(--sp-2);
}
.leaflet-control-raster .rc-month strong { color: var(--n-800); }
.leaflet-interactive:focus {
  outline: 2px solid rgba(59, 131, 246, 0.13); 
  outline-offset: 2px; 
}

.raster-legend {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--n-100);
}
.raster-legend .rl-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--n-700);
  margin-bottom: 5px;
  line-height: 1.3;
}
.raster-legend .rl-bar {
  height: 10px;
  border-radius: var(--r-xs);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.raster-legend .rl-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--n-500);
  margin-top: 3px;
  font-family: var(--font-mono);
}
.raster-legend .rl-classes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.raster-legend .rl-class {
  display: flex;
  align-items: center;
  font-size: 0.66rem;
  color: var(--n-700);
  line-height: 1.6;
}
.raster-legend .rl-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 7px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

/* Suaviza o reescalonamento do raster ao dar zoom */
.raster-overlay-img { image-rendering: auto; }

/* Tooltip do nome do município */
.municipio-tooltip {
  background-color: rgba(17, 24, 39, 0.85) !important;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #f1f5f9 !important;
  font-family: var(--font-sans) !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  padding: 6px 12px !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-lg) !important;
}


@media (max-width: 768px) {
  .leaflet-control-raster { width: 168px; padding: var(--sp-2); }
  .leaflet-control-raster .rc-select { font-size: 0.72rem; }
}
