/* =====================================================================
   ESTILOS INSTITUCIONALES - SFIA GTO (ADN Pomelli)
   ===================================================================== */

:root {
  --sfia-navy: #142392;
  --sfia-blue: #0363c9;
  --sfia-teal: #00a985;
  --sfia-bg-light: #e4ecfa;
  --sfia-dark: #2c3e50;
  --white: #ffffff;
  --soft-blue: #f4f8ff;
  --soft-border: rgba(20, 35, 146, 0.10);
}

body {
  font-family: 'Proxima Nova', 'Google Sans Flex', -apple-system, sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  color: var(--sfia-dark);
}

.section-title {
  color: var(--sfia-navy);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 1.35rem;
}

.section-subtitle {
  color: #5b6b85;
  font-size: 0.92rem;
  margin-bottom: 0;
}

.expect-card {
  border: 1px solid rgba(20, 35, 146, 0.08) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 18px rgba(20, 35, 146, 0.05);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.expect-card .card-header {
  background: linear-gradient(135deg, rgba(20,35,146,0.96) 0%, rgba(3,99,201,0.9) 100%) !important;
  color: white !important;
  font-weight: 700;
}

.state-side-card {
  border: 1px solid rgba(20, 35, 146, 0.08) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 18px rgba(20, 35, 146, 0.05);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  height: 100%;
}

.state-side-card .card-header {
  background: linear-gradient(135deg, rgba(20,35,146,0.96) 0%, rgba(3,99,201,0.9) 100%) !important;
  color: white !important;
}

.expect-mini-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, rgba(244,248,255,0.95), rgba(255,255,255,0.9));
  border: 1px solid rgba(20,35,146,0.08);
  border-radius: 12px;
  padding: 1rem 0.75rem;
  min-height: 120px;
  text-align: center;
}

.expect-source {
  color: #5f7189;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.expect-value {
  color: var(--sfia-navy);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.45rem;
}

.expect-date {
  color: #53657e;
  font-size: 0.75rem;
  font-weight: 600;
}

.macro-kpi-card {
  border: 1px solid rgba(20, 35, 146, 0.08) !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 18px rgba(20, 35, 146, 0.06);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  min-height: 170px;
}

.macro-kpi-card .card-header {
  background: linear-gradient(135deg, rgba(20, 35, 146, 0.96) 0%, rgba(3, 99, 201, 0.9) 100%) !important;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.macro-kpi-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 0.75rem 0.5rem 0.5rem;
}

.macro-kpi-source {
  color: #5f7189;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.macro-kpi-value {
  color: var(--sfia-navy);
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 2.1rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.macro-kpi-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  text-align: center;
  min-height: 24px;
}

.macro-kpi-date {
  color: #53657e;
  font-size: 0.72rem;
  font-weight: 600;
}

.macro-kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
}

.macro-kpi-badge.positive {
  background: rgba(0, 169, 133, 0.1);
  color: #0d8d6d;
}

.macro-kpi-badge.negative {
  background: rgba(220, 53, 69, 0.08);
  color: #b22631;
}

.macro-kpi-badge.neutral {
  background: rgba(3, 99, 201, 0.08);
  color: #1859b1;
}

.download-toolbar {
  background: linear-gradient(180deg, #f9fbff 0%, #eef5ff 100%);
  border-top: 1px solid rgba(20, 35, 146, 0.08);
  border-bottom: 1px solid rgba(20, 35, 146, 0.12);
  box-shadow: 0 -4px 16px rgba(20, 35, 146, 0.03);
  position: relative;
  z-index: 1000;
}

.download-toolbar .card {
  border: 1px solid rgba(20, 35, 146, 0.08) !important;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.download-toolbar .btn {
  min-height: 40px;
  font-weight: 600;
}

.filter-card {
  border: 1px solid rgba(20, 35, 146, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(244,248,255,0.98) 100%);
  box-shadow: 0 6px 18px rgba(20, 35, 146, 0.04);
  position: relative;
  z-index: 9999 !important; /* <-- Filtros forzados al frente */
}

.white-container {
  background-color: var(--white) !important;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(20, 35, 146, 0.05);
  border: 1px solid rgba(20, 35, 146, 0.08);
  position: relative;
  z-index: 1; /* <-- ¡Le quitamos el !important para respetar tu código de app.py! */
  margin-bottom: 20px;
  overflow: visible !important;
}

/* =====================================================================
   Fijar el stacking correcto para que los filtros queden por encima de la gráfica 
   ===================================================================== */
.filter-card,
.dash-dropdown,
.DayPicker {
  overflow: visible !important;
}

/* Base de los controles de input */
.Select-control,
.DatePickerRange,
.DatePickerInput {
  position: relative !important;
  z-index: 9999 !important;
}

/* Enviar los popups de Dropdown y Calendario al frente */
.Select-menu-outer,
.DateRangePicker_picker,
.SingleDatePicker_picker,
.dropdown-menu {
  z-index: 99999 !important;
}

/* Gráficas enviadas explícitamente hacia atrás */
.js-plotly-plot,
.dash-graph {
  position: relative !important;
  z-index: 0 !important;
}

/* =====================================================================
   Encabezados y Textos 
   ===================================================================== */

h2, h3, h4, h5 {
  font-weight: 700;
  color: var(--sfia-navy);
}
.text-info { color: var(--sfia-blue) !important; }
.text-primary { color: var(--sfia-navy) !important; }

/* Estilo de Pestañas (Tabs) */
.nav-tabs {
  border-bottom: 3px solid var(--sfia-bg-light);
}
.nav-tabs .nav-link {
  color: var(--sfia-navy);
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px solid transparent;
  margin-right: 5px;
  border-radius: 10px 10px 0 0;
  transition: all 0.3s ease;
  padding: 10px 14px;
}
.nav-tabs .nav-link.active {
  background-color: var(--sfia-teal) !important;
  color: var(--white) !important;
  border-color: var(--sfia-teal) !important;
  box-shadow: 0 6px 18px rgba(0, 169, 133, 0.18);
}

/* Tarjetas (Cards) */
.card {
  border: 1px solid rgba(20, 35, 146, 0.1) !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
  background-color: var(--white);
}
.card-header {
  background: linear-gradient(135deg, var(--sfia-navy) 0%, #1f3ec7 100%) !important;
  color: var(--white) !important;
  border-radius: 12px 12px 0 0 !important;
  font-weight: 700;
}
.bg-info { background-color: var(--sfia-blue) !important; }

/* Input y dropdowns */
.Select-control, .Select-menu-outer, .dropdown-menu, .form-control {
  border-radius: 10px !important;
  border-color: rgba(20, 35, 146, 0.14) !important;
}

.Select-control:hover, .form-control:hover {
  border-color: rgba(3, 99, 201, 0.35) !important;
}

.Select-value-label {
  color: var(--sfia-navy) !important;
  font-weight: 500;
}

/* Botones */
.btn {
  border-radius: 10px !important;
  transition: all 0.2s ease;
}

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

.btn-outline-primary {
  border-width: 1.5px;
}

.btn-success {
  box-shadow: 0 8px 16px rgba(40, 167, 69, 0.18);
}

.download-action-btn {
  background: linear-gradient(135deg, rgba(20,35,146,0.96) 0%, rgba(3,99,201,0.94) 100%) !important;
  border: 1px solid rgba(20,35,146,0.18) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  padding: 0.68rem 1.1rem !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 18px rgba(20, 35, 146, 0.12);
}

.download-action-btn:hover {
  box-shadow: 0 10px 22px rgba(20, 35, 146, 0.18);
}

.download-action-btn.btn-success {
  background: linear-gradient(135deg, #1e9a66 0%, #22b573 100%) !important;
  border-color: rgba(30, 154, 102, 0.2) !important;
}

.download-action-btn.btn-outline-primary {
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(244,248,255,0.98) 100%) !important;
  border: 1.5px solid rgba(20,35,146,0.18) !important;
  color: var(--sfia-navy) !important;
  box-shadow: 0 6px 18px rgba(20, 35, 146, 0.06);
}

.download-action-btn.btn-outline-primary:hover {
  background: linear-gradient(135deg, rgba(20,35,146,0.96) 0%, rgba(3,99,201,0.94) 100%) !important;
  color: #ffffff !important;
}

/* Tablas Dash */
.dash-spreadsheet-container .dash-spreadsheet-inner th {
  background-color: var(--sfia-navy) !important;
  color: white !important;
  font-weight: 600;
}

.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td {
  border-color: rgba(20, 35, 146, 0.08);
}

.ranking-table {
  border-radius: 14px;
  overflow: hidden;
}

.ranking-table .dash-spreadsheet-container {
  border-radius: 14px;
}

.ranking-table .dash-spreadsheet-container .dash-spreadsheet-inner tr:hover td {
  background-color: rgba(3, 99, 201, 0.06) !important;
}

.ranking-table .dash-spreadsheet-container .dash-spreadsheet-inner td {
  border-bottom: 1px solid rgba(20, 35, 146, 0.06);
  vertical-align: middle;
}

.data-table-export .dash-table-container .export {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, rgba(20,35,146,0.96) 0%, rgba(3,99,201,0.94) 100%) !important;
  border: 1px solid rgba(20,35,146,0.18) !important;
  color: #ffffff !important;
  border-radius: 10px !important;
  padding: 0.45rem 0.8rem !important;
  box-shadow: 0 8px 18px rgba(20, 35, 146, 0.12);
  font-weight: 700 !important;
}

.data-table-export .dash-table-container .export:hover {
  box-shadow: 0 10px 22px rgba(20, 35, 146, 0.18);
}

.data-table-export .dash-table-container {
  display: flex;
  flex-direction: column;
}

.data-table-export .dash-spreadsheet-container {
  order: 1;
}

.data-table-export .dash-spreadsheet-menu {
  order: 2;
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.data-table-export .dash-table-container .export-menu,
.data-table-export .dash-table-container .dropdown-menu {
  border-radius: 10px !important;
  border: 1px solid rgba(20,35,146,0.10) !important;
  box-shadow: 0 12px 28px rgba(20, 35, 146, 0.14) !important;
}

.data-table-export .dash-table-container .export-menu .Select-control,
.data-table-export .dash-table-container .export-menu .dropdown-item {
  border-radius: 8px !important;
}

/* Mejoras de layout */
.white-container .dash-graph {
  border-radius: 10px;
}