/* ==========================================================================
   Farmácia Digital — Analytics Dashboard
   Identidade Visual idêntica ao Dashboard FD (SES-MG / CIAF)
   ========================================================================== */

/* ─── CSS Variables ─── */
:root {
  /* Brand Colors — matching Dashboard FD logo */
  --fd-blue: #2196F3;
  --fd-blue-dark: #1976D2;
  --fd-blue-light: #64B5F6;
  --fd-blue-50: #E3F2FD;
  --fd-blue-bg: rgba(33, 150, 243, 0.08);

  --fd-orange: #FF9800;
  --fd-orange-dark: #F57C00;
  --fd-orange-light: #FFB74D;
  --fd-orange-bg: rgba(255, 152, 0, 0.08);

  --fd-green: #4CAF50;
  --fd-green-dark: #388E3C;
  --fd-green-light: #81C784;
  --fd-green-bg: rgba(76, 175, 80, 0.08);

  --fd-red: #EF5350;
  --fd-red-bg: rgba(239, 83, 80, 0.08);

  --fd-indigo: #6366F1;
  --fd-purple: #8B5CF6;

  /* Tema Claro (Default — igual ao Dashboard FD) */
  --bg-app: #f6f9fc;   /* medido no dashboard original */
  --bg-topbar: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e3eaf2;
  --border-focus: var(--fd-blue);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 14px;   /* cards do dashboard original */
  --radius-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.03), 0 1px 2px rgba(0,0,0,0.02);
  --shadow-md: 0 4px 12px rgba(33, 150, 243, 0.05), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.06);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
}

/* ─── Dark Theme ─── */
[data-tema="escuro"] {
  --bg-app: #0e1117;
  --bg-topbar: rgba(18, 18, 28, 0.88);
  --bg-card: #191d28;
  --bg-card-hover: #1e2430;
  --bg-input: #151922;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: var(--fd-blue-light);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
}

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5cdd7; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aab5; }
[data-tema="escuro"] ::-webkit-scrollbar-thumb { background: #2a3040; }

/* ==========================================================================
   GOVERNMENT STRIPE — matching Dashboard FD exactly
   ========================================================================== */
.gov-stripe {
  height: 4px;
  background: linear-gradient(90deg, #2196F3 0%, #1976D2 35%, #64B5F6 50%, #1976D2 65%, #2196F3 100%);
  width: 100%;
}

/* ==========================================================================
   HEADER — Glass effect identical to Dashboard FD
   ========================================================================== */
.header-nav {
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo-img {
  height: 64px;
  width: auto;
  object-fit: contain;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.2;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.badge-ciaf {
  background: var(--fd-blue-bg);
  color: var(--fd-blue);
  border: 1px solid rgba(33, 150, 243, 0.2);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ─── Header Buttons ─── */
.btn-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-fd-primary {
  background: var(--fd-blue);
  color: #fff;
}
.btn-fd-primary:hover {
  background: var(--fd-blue-dark);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.25);
}

.btn-fd-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-fd-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--fd-blue);
  color: var(--fd-blue);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--fd-blue);
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */
.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}

/* ==========================================================================
   SECTION NAV TABS — matching Dashboard FD
   ========================================================================== */
.section-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  color: var(--fd-blue);
  border-bottom-color: var(--fd-blue);
}

/* Ícone de traço: herda a cor do texto do botão, então acompanha
   os estados (inativo, hover, ativo) sem regra extra. */
.tab-btn__icone {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-btn:focus-visible {
  outline: 2px solid var(--fd-blue);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ==========================================================================
   COMPACT FILTER BAR — identical to Dashboard FD
   ========================================================================== */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.filter-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}

/* Form controls */
.form-control {
  height: 36px;
  padding: 0 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease-in-out;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.08);
}

/* Search input wrapper with icon */
.filter-search-wrapper {
  position: relative;
  flex: 2;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.pl-8 {
  padding-left: 2.1rem !important;
}

/* Select inputs */
.select-compact {
  flex: 1.2;
  min-width: 140px;
  cursor: pointer;
}

/* Date input wrappers */
.date-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 0.5rem;
  height: 36px;
  min-width: 155px;
  flex: 1;
}
.date-label-sub {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  user-select: none;
}
.date-compact {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  height: 100% !important;
  width: 100%;
  box-shadow: none !important;
}

/* Actions block */
.filter-actions-row {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

/* Results count badge row */
.results-badge-row {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
}
.results-badge {
  display: inline-block;
  background: var(--border-color);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
}

/* ==========================================================================
   KPI CARDS — with left border accent (identical to Dashboard FD)
   ========================================================================== */
.kpi-row {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  width: 100%;
}

/* Large Featured Card */
.kpi-featured-card {
  background: linear-gradient(135deg, var(--fd-blue-dark), var(--fd-blue));
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 20px -4px rgba(33, 150, 243, 0.25);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.kpi-featured-card::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.kpi-featured-card::after {
  content: "";
  position: absolute;
  bottom: -50px;
  right: 60px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.kpi-featured-card__left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
}

.kpi-featured-card__icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  color: #ffffff;
  flex-shrink: 0;
}

.kpi-featured-card__content {
  display: flex;
  flex-direction: column;
}

.kpi-featured-card__title {
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.15rem;
}

.kpi-featured-card__value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-featured-card__right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-left: 1.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.kpi-featured-card__stat {
  text-align: right;
}

.kpi-featured-card__stat-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
}

.kpi-featured-card__stat-value {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

@media (max-width: 600px) {
  .kpi-featured-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .kpi-featured-card__right {
    width: 100%;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 0.75rem;
    justify-content: space-between;
  }
}

/* Grid of regular KPIs */
.kpi-grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 1200px) {
  .kpi-grid-row {
    /* 4 cards: o de tempo médio até o aceite saiu da Visão Geral. */
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.kpi-grid-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(33, 150, 243, 0.15);
}

.kpi-grid-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.kpi-grid-card__icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.kpi-grid-card__title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.kpi-grid-card__value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-grid-card__subtitle {
  font-size: 0.7rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

.circular-progress {
  flex-shrink: 0;
}

/* Base icon colors */
.icon--blue { background: var(--fd-blue-bg); color: var(--fd-blue); }
.icon--orange { background: var(--fd-orange-bg); color: var(--fd-orange); }
.icon--green { background: var(--fd-green-bg); color: var(--fd-green); }
.icon--red { background: var(--fd-red-bg); color: var(--fd-red); }
.icon--indigo { background: rgba(99, 102, 241, 0.1); color: var(--fd-indigo); }
.icon--purple { background: rgba(139, 92, 246, 0.1); color: var(--fd-purple); }

/* ==========================================================================
   MAP — matching Dashboard FD regional-map.tsx layout
   ========================================================================== */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; }
}

.map-card, .ranking-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.map-card__header, .ranking-card h3 {
  font-family: var(--font-display);
}

.map-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.map-card__header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.map-svg-container {
  width: 100%;
  height: 500px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

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

.regional-path {
  stroke: var(--border-color);
  stroke-width: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.regional-path:hover {
  stroke: var(--fd-blue);
  stroke-width: 2.5px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.15));
}
.regional-path.selected {
  stroke: var(--fd-blue);
  stroke-width: 3px;
}

/* Map Tooltip */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  z-index: 200;
  font-size: 0.78rem;
  min-width: 170px;
  display: none;
}
.map-tooltip h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--fd-blue);
  margin-bottom: 0.3rem;
}
.map-tooltip__row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.15rem;
}

/* Ranking Sidebar */
.ranking-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 420px;
  padding-right: 0.3rem;
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: var(--bg-app);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.ranking-item:hover {
  border-color: var(--fd-blue);
  background: var(--fd-blue-bg);
}
.ranking-name { font-weight: 600; }
.ranking-val { font-weight: 700; color: var(--fd-blue); font-family: var(--font-display); }

/* ==========================================================================
   PANEL CARDS (Charts & Tables) — Premium style
   ========================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.panel-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(33, 150, 243, 0.1);
}

.panel-card--full { grid-column: 1 / -1; }

.panel-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.panel-card__header h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Uma linha explicando o que o gráfico mede — evita o título ambíguo. */
.panel-card__nota {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-weight: 400;
}

.chart-wrapper {
  position: relative;
  height: 280px;
  width: 100%;
}
.chart-wrapper--tall { height: 340px; }

.margin-bottom { margin-bottom: 1.5rem; }

/* ==========================================================================
   DATA TABLE — polished, minimal lines
   ========================================================================== */
.data-table-container {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  background: var(--bg-app);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 0.15s;
}
.data-table tbody tr:hover {
  background: var(--fd-blue-bg);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Territory tag */
.territory-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--fd-blue-bg);
  color: var(--fd-blue);
}

/* ==========================================================================
   BADGES — status pills
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-green { background: var(--fd-green-bg); color: var(--fd-green-dark); }
.badge-orange { background: var(--fd-orange-bg); color: var(--fd-orange-dark); }
.badge-red { background: var(--fd-red-bg); color: var(--fd-red); }
.badge-blue { background: var(--fd-blue-bg); color: var(--fd-blue); }

/* ==========================================================================
   QUALITY BOX
   ========================================================================== */
.quality-box {
  background: rgba(255, 152, 0, 0.06);
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
}
.quality-box strong { color: var(--fd-orange); display: block; margin-bottom: 0.3rem; }
.quality-box ul { padding-left: 1.25rem; color: var(--text-muted); }

/* ==========================================================================
   STATE OVERLAYS (Loading / Error / Empty)
   ========================================================================== */
.state-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
  gap: 1rem;
}

.state-overlay__icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

.state-overlay__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.state-overlay__text {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 420px;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--fd-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   ANIMATIONS — matching Dashboard FD
   ========================================================================== */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
  animation: fade-in-up 0.4s ease-out forwards;
}

/* Stagger delays */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.animate-pulse { animation: pulse-soft 2s ease-in-out infinite; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .filter-flex {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-search-wrapper, .select-compact, .date-input-wrapper {
    width: 100%;
    flex: none;
  }
  .filter-actions-row {
    margin-left: 0;
    justify-content: flex-end;
    margin-top: 0.25rem;
  }
}

@media (max-width: 768px) {
  .header-container { padding: 0.5rem 1rem; }
  .brand-logo-img { height: 48px; }
  .brand-text h1 { font-size: 0.88rem; }
  .brand-text p { font-size: 0.65rem; }
  .app-container { padding: 1rem; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .section-nav { gap: 0; }
  .tab-btn { padding: 0.55rem 0.7rem; font-size: 0.75rem; }
}

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

/* ==========================================================================
   ÍCONES DE TRAÇO
   Substituem os emojis: herdam a cor do texto ao redor e têm o mesmo desenho
   em qualquer sistema operacional.
   ========================================================================== */
.ico {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

.state-overlay__icon .ico { width: 2.25rem; height: 2.25rem; stroke-width: 1.5; }

/* O valor dos cards MENORES usa o token de texto (fundo claro → tinta escura);
   a identidade de status vem do ícone e do anel. Número colorido compete com o
   dado e reduz o contraste. */
.kpi-grid-card__value {
  color: var(--text-main);
}

/* O card em destaque tem FUNDO AZUL — o número precisa ser branco nos dois
   temas, não seguir o token de texto (que é escuro no modo claro). */
.kpi-featured-card__value {
  color: #ffffff;
}

/* ==========================================================================
   LEGENDA DO MAPA — intensidade 0 → Máx (como no dashboard original)
   ========================================================================== */
.map-legenda {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.map-legenda__rotulo {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.map-legenda__barra {
  width: 160px;
  height: 10px;
  border-radius: 5px;
  /* Opacidade crescente da mesma tinta — é exatamente a codificação usada
     nos polígonos, então a legenda "fala a língua" do mapa. */
  background: linear-gradient(to right, rgba(30, 136, 229, 0.25), rgba(30, 136, 229, 1));
  border: 1px solid var(--border-color);
}

.map-legenda__num {
  font-weight: 600;
  color: var(--text-main);
}

.map-fora {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   DETALHE DA REGIONAL NO CARD DO MAPA
   Aparece ao clicar num polígono — replica o painel do dashboard original.
   ========================================================================== */
.regional-detalhe__cab {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.regional-detalhe__nome strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.regional-detalhe__macro {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.regional-detalhe__fechar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}
.regional-detalhe__fechar:hover {
  color: var(--fd-red);
  border-color: var(--fd-red);
}

.regional-detalhe__mini {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.regional-detalhe__mini span {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.2rem;
  background: var(--bg-card-hover);
  border-radius: var(--radius-sm);
  font-size: 0.66rem;
  color: var(--text-muted);
  text-align: center;
}
.regional-detalhe__mini b {
  font-size: 0.95rem;
  color: var(--text-main);
}

.regional-detalhe__rodape {
  display: flex;
  justify-content: space-around;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.regional-detalhe__rodape b { color: var(--text-main); }

.ranking-carregando {
  margin: 0.5rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   CADEADO DA ABA ANALISTAS
   ========================================================================== */
.bloqueio-area {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 2rem 1rem;
}

.bloqueio-area__cartao {
  width: min(92vw, 380px);
  padding: 2rem 1.75rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.bloqueio-area__icone {
  width: 34px;
  height: 34px;
  margin-bottom: 0.75rem;
  fill: none;
  stroke: var(--fd-blue);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bloqueio-area__cartao h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.bloqueio-area__cartao p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.1rem;
}

#form-analistas-senha {
  display: flex;
  gap: 0.5rem;
}
#form-analistas-senha .form-control { flex: 1; }

.bloqueio-area__erro {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--fd-red);
  font-weight: 600;
}
