/* ==========================================================================
   FUNDACIÓN REDSAVIA — Finanzas Empresariales Básicas
   Tablero financiero dinámico por empresario (Consultor, Finanzas y Empresario)
   ========================================================================== */

.fin-wrap {
  display: grid;
  gap: 16px;
}

/* Barra superior de filtros */
.fin-filter-bar {
  background: #ffffff;
  border: 1px solid var(--p-linea);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(17, 46, 28, 0.04);
}
.fin-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.fin-filter-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  color: #143923;
}
.fin-filter-field select {
  padding: 7px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--p-linea);
  background: #faf8f2;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: #0b2f4f;
  min-width: 175px;
}

/* 4 Tarjetas KPI Pastel */
.fin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.fin-kpi {
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(23, 61, 38, 0.08);
  display: grid;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(17, 46, 28, 0.04);
}
.fin-kpi--ventas { background: #e8f3e4; --kcol: #1b5e3b; --kbadge: #d3ebcc; }
.fin-kpi--costos { background: #fbf0dd; --kcol: #8a5614; --kbadge: #f5dfb8; }
.fin-kpi--gastos { background: #e3f0fa; --kcol: #0f3b6e; --kbadge: #cce2f5; }
.fin-kpi--util { background: #efe6f7; --kcol: #5c2e82; --kbadge: #e1cff0; }
.fin-kpi--neg { background: #fbeae8; --kcol: #9c2f24; --kbadge: #f4d0cc; }

.fin-kpi__top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fin-kpi__ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--kcol);
  display: grid;
  place-items: center;
  flex: none;
}
.fin-kpi__ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fin-kpi__lbl { font-size: 0.78rem; font-weight: 700; color: #36473d; display: block; }
.fin-kpi__val { font-family: var(--p-serif); font-size: clamp(1.18rem, 1.7vw, 1.5rem); font-weight: 700; color: #142a1e; line-height: 1.1; display: block; margin-top: 2px; }
.fin-kpi__pill {
  justify-self: center;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--kbadge);
  color: var(--kcol);
  font-size: 0.74rem;
  font-weight: 800;
}

/* 3 Tarjetas Centrales (Evolución, Composición, Indicadores) */
.fin-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.2fr) minmax(240px, 0.88fr);
  gap: 14px;
  align-items: stretch;
}
.fin-card {
  background: #ffffff;
  border: 1px solid var(--p-linea);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 14px rgba(17, 46, 28, 0.04);
}
.fin-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.fin-card__head h3 {
  margin: 0;
  font-family: var(--p-serif);
  font-size: 1.02rem;
  color: #143923;
  display: flex;
  align-items: center;
  gap: 7px;
}
.fin-card__head svg { width: 18px; height: 18px; stroke: #1b5e3b; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.fin-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Dona de composición de egresos */
.fin-donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.fin-donut-box {
  position: relative;
  width: 132px;
  height: 132px;
  flex: none;
}
.fin-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.fin-donut-center strong { font-family: var(--p-serif); font-size: 0.86rem; color: #142a1e; }
.fin-donut-center small { font-size: 0.7rem; color: var(--p-tinta-2); font-weight: 700; }
.fin-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  flex: 1;
}
.fin-legend li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: #2b3c32;
}
.fin-legend-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.fin-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}

/* Indicadores clave */
.fin-ind-list {
  display: grid;
  gap: 11px;
  margin: auto 0;
}
.fin-ind-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 700;
  color: #283a30;
}
.fin-ind-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: #e6f2e6;
  color: #1b5e3b;
  font-weight: 800;
  font-size: 0.84rem;
  white-space: nowrap;
}
.fin-ind-pill--lime { background: #e8f4d4; color: #2b5919; }
.fin-ind-pill--neg { background: #fbeae8; color: #9c2f24; }

/* Fila Inferior: Registros recientes + Herramientas financieras */
.fin-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.fin-type-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
}
.fin-type-pill--ingreso { background: #ddf1d5; color: #1b5e3b; }
.fin-type-pill--costo { background: #fae8cb; color: #8a5614; }
.fin-type-pill--gasto { background: #dcebfa; color: #0f3b6e; }

.fin-del-btn {
  border: 0;
  background: transparent;
  color: #9c4a40;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.fin-del-btn:hover { background: #fbeae8; }

/* 5 botones de Herramientas financieras (exactos a la referencia) */
.fin-tools-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.fin-tool-btn {
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 800;
  color: #142a1e;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.fin-tool-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(17, 46, 28, 0.09);
}
.fin-tool-btn.is-active {
  border-color: #1b5e3b;
  box-shadow: 0 0 0 3px rgba(27, 94, 59, 0.14);
}
.fin-tool-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fin-tool-btn--venta { background: #e8f3e4; color: #1b5e3b; }
.fin-tool-btn--costo { background: #fbf0dd; color: #8a5614; }
.fin-tool-btn--gasto { background: #e3f0fa; color: #0f3b6e; }
.fin-tool-btn--analisis { background: #efe6f7; color: #5c2e82; }
.fin-tool-btn--proy { background: #ebf5df; color: #2d631d; }

.fin-drawer-box {
  background: #f6f3e9;
  border: 1.5px solid rgba(27, 94, 59, 0.22);
  border-radius: 16px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}
.fin-empty-chart {
  flex: 1;
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
  border-radius: 12px;
  background: #faf8f2;
  color: var(--p-tinta-2);
  font-size: 0.82rem;
}

@media (max-width: 1260px) {
  .fin-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-charts-grid { grid-template-columns: 1fr; }
  .fin-bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .fin-kpi-grid { grid-template-columns: 1fr; }
  .fin-tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-donut-wrap { flex-direction: column; align-items: flex-start; }
}
