/* Tarjetas de indicadores, paneles y chips de tendencia. */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-grid .card,
.territorial-kpis .card {
  border: 0;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-left: -1px;
  margin-top: -1px;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  padding: 18px 18px 16px;
  background: transparent;
}

/* Sin overflow:hidden en el contenedor (para no cortar el tooltip .info::after);
   las esquinas redondeadas se replican manualmente en las cards de los bordes. */
.kpi-grid .card:first-child,
.territorial-kpis .card:first-child {
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
}

.kpi-grid .card:last-child,
.territorial-kpis .card:last-child {
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.kpi-grid .card:hover,
.territorial-kpis .card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--line);
  background: color-mix(in srgb, var(--soft) 55%, transparent);
}

.card, .panel, .insight, details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: cardIn .22s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  padding: 16px;
  min-height: 150px;
  min-width: 0;
}

.kpi-grid .card:nth-child(2) { animation-delay: .04s; }
.kpi-grid .card:nth-child(3) { animation-delay: .08s; }
.kpi-grid .card:nth-child(4) { animation-delay: .12s; }
.kpi-grid .card:nth-child(5) { animation-delay: .16s; }
.kpi-grid .card:nth-child(6) { animation-delay: .2s; }

.card:has(#kpiImpactoReal) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 10%, var(--panel)), color-mix(in srgb, var(--blue) 3%, var(--panel)));
  box-shadow: inset 0 3px 0 var(--blue);
}

.card:has(#kpiImpactoReal) .label {
  color: var(--blue);
}

::selection {
  background: color-mix(in srgb, var(--blue) 24%, transparent);
}

.card:hover,
.panel:hover {
  border-color: #d0d5dd;
  box-shadow: 0 18px 36px rgba(15, 23, 42, .075);
  transform: translateY(-1px);
  transition: border-color .22s ease, box-shadow .22s ease, transform .22s ease;
}

.label-row, .panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chart-expand-btn,
.chart-print-btn {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #344054;
  box-shadow: none;
  font-size: 12px;
  gap: 6px;
}

.chart-expand-btn:hover,
.chart-print-btn:hover {
  background: var(--soft-blue);
  border-color: #bfdbfe;
  color: var(--blue-dark);
  box-shadow: none;
  transform: none;
}

.chart-expand-icon,
.chart-print-icon {
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
}

.chart-print-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}

.label {
  color: var(--muted);
  font-weight: 850;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.value {
  margin-top: 12px;
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.sub {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.38;
  color: var(--muted);
}

.blue { color: var(--blue); }
.red { color: var(--red); }
.green { color: var(--green); }
.purple { color: var(--purple); }
.teal { color: var(--teal); }
.orange { color: var(--orange); }
.slate { color: var(--slate); }

.trend {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid #d9e4f2;
  background: #f8fafc;
  color: var(--slate);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 850;
  white-space: normal;
}

.trend-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
}

.trend.good {
  background: #ecfdf5;
  color: #047857;
  border-color: #bbf7d0;
}

.trend.bad {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.trend.neutral {
  background: #f8fafc;
  color: #64748b;
  border-color: #d9e4f2;
}
