/* ═══════════════════════════════════════════════════════════════════
   Centro de ventas ML (/ventas_ml): resumen (KPIs + composición por
   origen), actividad (serie semanal SVG + top vendidos), avisos y el
   historial como libro de ventas agrupado por día.
   Mobile-first; breakpoint 900px.
   ═══════════════════════════════════════════════════════════════════ */

.page-header .ventas-header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.ventas-last-check { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── Resumen: KPIs del mes ────────────────────────────── */
.ventas-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
@media (min-width: 900px) { .ventas-kpis { grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); } }

.ventas-kpi {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.ventas-kpi--main { grid-column: 1 / -1; border-top: 3px solid var(--c-primary); }
@media (min-width: 900px) { .ventas-kpi--main { grid-column: auto; } }

.ventas-kpi__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.ventas-kpi__value {
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  line-height: 1.2;
}
.ventas-kpi--main .ventas-kpi__value { font-size: 1.75rem; }
.ventas-kpi__hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.ventas-kpi__hint--up   { color: var(--c-success); font-weight: 600; }
.ventas-kpi__hint--down { color: var(--c-danger);  font-weight: 600; }

/* Composición del ingreso por origen (barra SVG de dos segmentos) */
.ventas-split { margin-top: auto; padding-top: var(--space-2); display: flex; flex-direction: column; gap: 0.3rem; }
.ventas-split__bar { display: block; width: 100%; height: 5px; border-radius: var(--radius-full); overflow: hidden; }
.ventas-split__main { fill: var(--c-primary); }
.ventas-split__rest { fill: var(--gray-200); }
.ventas-split__legend {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem var(--space-3);
  flex-wrap: wrap;
}
.ventas-split__item { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.ventas-split__dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0; }
.ventas-split__dot--main { background: var(--c-primary); }
.ventas-split__dot--rest { background: var(--gray-300); }

/* ── Actividad: serie semanal + top vendidos ──────────── */
.ventas-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
@media (min-width: 900px) { .ventas-panels { grid-template-columns: 2fr 1fr; align-items: start; } }

.ventas-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  min-width: 0;
}
.ventas-panel h2 {
  font-size: var(--text-base);
  font-weight: 700;
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}
.ventas-panel h2 small { font-size: var(--text-xs); font-weight: 500; color: var(--gray-500); }

/* Gráfico semanal: barras de una sola serie; la semana en curso va parcial */
.ventas-chart { width: 100%; height: auto; display: block; }
.ventas-chart__bar { fill: var(--c-primary); }
.ventas-chart__bar:hover { opacity: 0.8; }
.ventas-chart__bar--current { opacity: 0.45; }
.ventas-chart__bar--empty { fill: var(--gray-200); }
.ventas-chart__baseline { stroke: var(--gray-200); stroke-width: 1; }
.ventas-chart__label { font-size: 10px; fill: var(--gray-500); }
.ventas-chart__label--current { font-style: italic; }
.ventas-chart__value { font-size: 10px; font-weight: 600; fill: var(--gray-500); }

/* Top vendidos: ranking con meter de ingreso relativo */
.ventas-top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ventas-top li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--text-sm);
}
.ventas-top li:last-child { border-bottom: none; }
.ventas-top__rank {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: var(--text-xs);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ventas-top__main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.ventas-top__main a { color: inherit; }
.ventas-top__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ventas-top__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.ventas-top__meter { display: block; width: 100%; height: 3px; border-radius: var(--radius-full); overflow: hidden; }
.ventas-top__revenue {
  margin-left: auto;
  flex-shrink: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ventas-top__empty { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }

/* ── Avisos (chips accionables, solo si hay algo) ─────── */
.ventas-alerts { margin-bottom: var(--space-3); }

/* ── Historial: toolbar + libro de ventas por día ─────── */
.ventas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.ventas-seg {
  display: inline-flex;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.ventas-seg__opt {
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  text-decoration: none;
  white-space: nowrap;
}
.ventas-seg__opt:hover { color: var(--color-text); }
.ventas-seg__opt--active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow);
}

.ventas-hour-col { width: 3.5rem; }
.ventas-hour { color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ventas-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.ventas-estado { min-width: 11rem; }
.ventas-estado .badge + .badge { margin-left: 0.25rem; }
.ventas-retry { margin-top: 0.3rem; }

/* Separador de día: fila que agrupa el historial como libro de ventas */
.ventas-day-row td {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 0.45rem 0.75rem;
}
.ventas-day__label { font-weight: 700; font-size: var(--text-sm); }
.ventas-day__date { font-size: var(--text-xs); color: var(--color-text-muted); margin-left: var(--space-2); }
.ventas-day__summary { float: right; font-size: var(--text-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
