/* ============================================================
   dashboard.css — Panel de control
   Sistema visual del dashboard: cabecera, segmented tabs, KPIs
   con tendencia, tarjetas de panel, listas operativas y gráficos.
   Usa los tokens de base.css; no depende de ninguna librería.
   ============================================================ */

/* ----- Cabecera de la vista ----- */
.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.dash-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.dash-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--c-navy);
  margin: 4px 0 4px;
}

.dash-sub {
  font-size: 14px;
  color: var(--c-muted);
}

.dash-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-muted);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.dash-alert-chip:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.dash-alert-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8ecf4;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dash-alert-chip.activo .dash-alert-num {
  background: #fef3c7;
  color: #92400e;
}

.dash-alert-chip.activo {
  color: var(--c-text);
}

/* ----- Tabs: control segmentado ----- */
.dash-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  margin-bottom: 22px;
  border-radius: 14px;
  background: #e8ecf4;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--c-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.dash-tab-ico {
  font-size: 13px;
  opacity: 0.85;
}

.dash-tab:hover {
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.6);
}

.dash-tab.active {
  background: #fff;
  color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

.dash-panel { display: block; }

/* ----- Grillas del dashboard ----- */
.mgrid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.mgrid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.dash-row {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.dash-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-row-2-1 { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); }

/* ----- KPI cards ----- */
.mcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  min-width: 0;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-med), transform var(--t-med), border-color var(--t-med);
}

.mcard-click { cursor: pointer; }

.mcard-click:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.mcard-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  min-width: 0;
}

.mcard-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.mcard-label {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
  min-width: 0;
}

.mcard-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--c-navy);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.mcard-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  min-height: 22px;
  font-size: 12px;
  color: var(--c-muted);
}

.mcard-nota {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.mcard-spark {
  margin-top: 2px;
  width: 100%;
  line-height: 0;
}

/* Tonos: solo tiñen el icono, el valor queda neutro y legible. */
.mcard-success .mcard-ico { background: #d1fae5; color: #047857; }
.mcard-warning .mcard-ico { background: #fef3c7; color: #92400e; }
.mcard-danger  .mcard-ico { background: #fee2e2; color: #b91c1c; }
.mcard-info    .mcard-ico { background: #dbeafe; color: #1d4ed8; }
.mcard-neutral .mcard-ico { background: #e8ecf4; color: var(--c-muted); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.trend-up   { background: #d1fae5; color: #065f46; }
.trend-down { background: #fee2e2; color: #991b1b; }

/* ----- Tarjeta de panel ----- */
.panel-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.dash-row .panel-card { margin-bottom: 0; }

.panel-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 12px;
}

.panel-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--c-navy);
  line-height: 1.25;
}

.panel-card-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--c-muted);
}

.panel-card-body {
  padding: 4px 22px 20px;
  min-width: 0;
}

.panel-card-foot {
  padding: 12px 22px;
  border-top: 1px solid var(--c-border);
}

.panel-nota {
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--c-muted);
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--c-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--t-fast);
}

.link-btn:hover { color: var(--c-primary-strong); text-decoration: underline; }

/* ----- Cola de atención ----- */
.atencion-lista,
.lista-simple {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.atencion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast);
}

.atencion-item:hover { background: #f6f8fc; }

.atencion-item.nivel-alta  { border-left-color: var(--bad); }
.atencion-item.nivel-media { border-left-color: var(--warn); }
.atencion-item.nivel-info  { border-left-color: var(--info); }

.atencion-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  background: #f1f5f9;
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 700;
}

.nivel-alta .atencion-ico  { background: #fee2e2; color: #b91c1c; }
.nivel-media .atencion-ico { background: #fef3c7; color: #92400e; }

.atencion-txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.atencion-txt strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-text);
}

.atencion-txt em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--c-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Listas de alumnos ----- */
.lista-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--t-fast);
}

.lista-fila + .lista-fila { border-top: 1px solid #eef1f6; }
.lista-fila:hover { background: #f6f8fc; }

.lista-fila-txt {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.lista-fila-txt strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lista-fila-txt em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--c-muted);
}

.lista-fila-extra {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ----- Chips de estado / plazo ----- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--c-muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip-danger { background: #fee2e2; color: #991b1b; }
.chip-warn   { background: #fef3c7; color: #92400e; }
.chip-info   { background: #dbeafe; color: #1e40af; }
.chip-ok     { background: #d1fae5; color: #065f46; }

/* ----- Mini barra de progreso ----- */
.mini-progreso {
  display: inline-block;
  width: 72px;
  height: 6px;
  border-radius: 999px;
  background: #e8ecf4;
  overflow: hidden;
  flex-shrink: 0;
}

.mini-progreso-ancho { width: 100%; margin-top: 5px; }

.mini-progreso-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f46e5, #6366f1);
}

.mini-progreso-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}

/* ----- Mini stats bajo la barra de cobro ----- */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}

.mini-stats > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mini-stats span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.mini-stats strong {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--c-navy);
  font-variant-numeric: tabular-nums;
}

/* ----- Tablas del dashboard ----- */
#dashboard-content .tabla-mini th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  font-size: 11.5px;
}

#dashboard-content .tabla-mini td {
  padding: 11px 10px;
  border-bottom: 1px solid #eef1f6;
  font-size: 13.5px;
}

#dashboard-content .tabla-mini tbody tr:last-child td { border-bottom: none; }

#dashboard-content .tabla-mini .num { text-align: right; font-variant-numeric: tabular-nums; }
#dashboard-content .tabla-mini .col-secundaria { color: var(--c-muted); }

.fila-clickeable { cursor: pointer; }

.celda-alumno {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.celda-alumno strong { display: block; font-weight: 600; }

.celda-alumno em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--c-muted);
}

.celda-progreso {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.celda-progreso em {
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

/* ----- Estados vacíos ----- */
.estado-vacio {
  padding: 22px 4px;
  text-align: center;
  font-size: 13.5px;
  color: var(--c-muted);
}

.estado-ok {
  border-radius: 10px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 600;
}

.dash-onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 40px auto;
  padding: 40px 32px;
  text-align: center;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}

.dash-onboarding-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-size: 24px;
}

.dash-onboarding h2 {
  font-size: 22px;
  color: var(--c-navy);
}

.dash-onboarding p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-muted);
}

/* ============================================================
   Gráficos (SVG/HTML inline generados por js/ui/charts.js)
   ============================================================ */

.chart-wrap { min-width: 0; }

.chart {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  overflow: visible;
}

.chart-grid {
  stroke: #eef1f6;
  stroke-width: 1;
}

.chart-grid-base { stroke: #d8dfea; }

.chart-tick {
  fill: var(--c-muted);
  font-size: 10.5px;
  font-weight: 500;
}

.chart-label {
  fill: var(--c-muted);
  font-size: 11px;
  font-weight: 600;
}

.chart-hover-zona {
  fill: transparent;
  transition: fill var(--t-fast);
}

.chart-grupo:hover .chart-hover-zona { fill: rgba(79, 70, 229, 0.05); }

.chart-spark {
  display: block;
  width: 100%;
  height: 34px;
  overflow: visible;
}

/* ----- Barras horizontales ----- */
.chart-hbars {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.chart-hbar {
  display: grid;
  grid-template-columns: minmax(80px, 34%) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.chart-hbar-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-hbar-track {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.chart-hbar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-hbar-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-navy);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-hbar-val em {
  margin-left: 6px;
  font-style: normal;
  font-weight: 500;
  font-size: 12px;
  color: var(--c-muted);
}

/* ----- Barra segmentada ----- */
.chart-stack {
  display: flex;
  height: 22px;
  margin: 6px 0 4px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1f6;
}

.chart-seg {
  display: block;
  height: 100%;
  transition: opacity var(--t-fast);
}

.chart-stack:hover .chart-seg { opacity: 0.75; }
.chart-stack .chart-seg:hover { opacity: 1; }

/* ----- Donut ----- */
.chart-donut-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.chart-donut { width: 168px; height: 168px; }

.chart-donut-seg { transition: opacity var(--t-fast); }

.chart-donut-center {
  fill: var(--c-navy);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
}

.chart-donut-sub {
  fill: var(--c-muted);
  font-size: 11px;
  font-weight: 600;
}

/* ----- Anillo de progreso ----- */
.chart-anillo-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.chart-anillo { width: 132px; height: 132px; }

.chart-anillo-val {
  fill: var(--c-navy);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.chart-anillo-sub {
  fill: var(--c-muted);
  font-size: 10.5px;
  font-weight: 600;
}

/* ----- Leyenda ----- */
.chart-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--c-muted);
}

.chart-leyenda-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-leyenda-item strong {
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ----- Estado vacío de gráficos ----- */
.chart-vacio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px 16px;
  text-align: center;
  color: var(--c-muted);
  font-size: 13px;
}

.chart-vacio-ico {
  font-size: 22px;
  opacity: 0.45;
}

/* ----- Progreso de cobro ----- */
.chart-progress-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.chart-progress-pct {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

.chart-progress-cap {
  font-size: 12.5px;
  color: var(--c-muted);
}

.chart-progress-bar {
  height: 12px;
  border-radius: 999px;
  background: #e8ecf4;
  overflow: hidden;
}

.chart-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #047857, #34d399);
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-progress-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.chart-progress-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chart-progress-item-end { text-align: right; }

.chart-progress-item em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.chart-progress-item strong {
  font-size: 15px;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
  .dash-row-2-1,
  .dash-row-2 { grid-template-columns: minmax(0, 1fr); }
  .mgrid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .dash-head { align-items: flex-start; }
  .dash-title { font-size: 24px; }
  .mgrid,
  .mgrid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-card-head { padding: 16px 16px 10px; }
  .panel-card-body { padding: 4px 16px 18px; }
  .panel-card-foot { padding: 12px 16px; }
  .dash-tabs { width: 100%; }
}

@media (max-width: 620px) {
  .mgrid,
  .mgrid-5 { grid-template-columns: minmax(0, 1fr); }
  .mcard-value { font-size: 24px; }
  .mini-stats { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .chart-hbar { grid-template-columns: minmax(70px, 40%) minmax(0, 1fr) auto; gap: 8px; }
  #dashboard-content .tabla-mini .col-secundaria { display: none; }
}
