/* ═══════════════ DASHBOARD v2.0 ═══════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.accent-green::before  { background: var(--green); }
.stat-card.accent-blue::before   { background: var(--blue); }
.stat-card.accent-orange::before { background: var(--primary); }
.stat-card.accent-purple::before { background: var(--purple); }
.stat-card.accent-teal::before   { background: var(--teal); }
.stat-card.accent-red::before    { background: var(--red); }
.stat-card.accent-indigo::before { background: #6366f1; }

.stat-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat-body { display: flex; flex-direction: column; }
.stat-label {
  font-size: 0.73rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.stat-value { font-size: 1.45rem; font-weight: 800; color: var(--text); margin: 0.2rem 0 0.15rem; line-height: 1.1; letter-spacing: -0.5px; }
.stat-change { font-size: 0.73rem; font-weight: 600; }
.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }
.stat-sub { font-size: 0.73rem; color: var(--text-muted); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .chart-card.wide { grid-column: span 2; }
}
@media (max-width: 700px) {
  .charts-grid {
    grid-template-columns: 1fr;
    flex: unset;          /* deja de comprimir — sección scrollea */
    min-height: unset;
  }
  .chart-card.wide { grid-column: span 1; }
  .rendimiento-card { min-height: 520px; }  /* garantiza que se vean chart + bottom */
  #chart-performance { max-height: 140px; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chart-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-shrink: 0;
}
.chart-card-header h3 { font-size: 0.875rem; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.chart-legend { display: flex; align-items: center; gap: 0.75rem; font-size: 0.75rem; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.primary  { background: var(--primary); }
.legend-dot.secondary { background: var(--blue); }

/* ── Top Products List ── */
.top-products-list {
  display: flex; flex-direction: column; gap: 0.45rem;
  overflow-y: auto; flex: 1; padding-right: 2px;
}
.top-empty {
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
  padding: 2rem 0;
}
/* ── tp-* (new dual-bar top products) ── */
.tp-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; border-bottom: 1px solid var(--border);
}
.tp-row:last-child { border-bottom: none; }
.tp-rank {
  font-size: 1rem; width: 1.6rem; text-align: center; flex-shrink: 0;
}
.top-rank-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--border);
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
}
.tp-img {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; border: 1.5px solid var(--border);
}
.tp-img-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.tp-info { flex: 1; min-width: 0; }
.tp-name {
  display: block; font-size: 0.78rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.tp-bars { display: flex; flex-direction: column; gap: 3px; margin-bottom: 3px; }
.tp-bar-wrap {
  height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden;
  border: 1px solid var(--border);
}
.tp-bar-rev  { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.4s ease; }
.tp-bar-cost { height: 100%; background: #3498DB;       border-radius: 99px; transition: width 0.4s ease; }
.tp-bar-labels { display: flex; gap: 0.6rem; }
.tp-lbl-rev  { font-size: 0.65rem; color: var(--primary); font-weight: 600; }
.tp-lbl-cost { font-size: 0.65rem; color: #3498DB;       font-weight: 600; }
.tp-stats {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0;
}
.tp-qty    { font-size: 0.72rem; font-weight: 700; color: var(--text); }
.tp-profit { font-size: 0.72rem; color: #27AE60; font-weight: 700; }

/* ── Rendimiento card split layout ── */
.rendimiento-card { overflow: hidden; }
.rendimiento-top  { flex-shrink: 0; }
.rendimiento-divider {
  height: 1px; background: var(--border);
  margin: 0.85rem 0; flex-shrink: 0;
}
.rendimiento-bottom {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.rendimiento-bottom .chart-card-header { flex-shrink: 0; }

/* ── Bottom Productos color overrides ── */
.bp-bar-rev  { background: #E74C3C !important; }
.bp-profit   { color: #E74C3C !important; }
.bp-rank-num {
  background: #FDE8E8 !important;
  border-color: #E74C3C !important;
  color: #C0392B !important;
}
