/* ─── Statistics Page ───────────────────────────────────────────────────── */

/* KPI grid */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stats-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: var(--transition);
}

.stats-kpi-card:hover { border-color: rgba(116, 24, 32, 0.25); transform: translateY(-2px); }

.stats-kpi-card.kpi-highlight { border-color: rgba(116, 24, 32, 0.35); background: rgba(116, 24, 32, 0.06); }
.stats-kpi-card.kpi-danger    { border-color: rgba(179, 38, 30, 0.35);  background: rgba(179, 38, 30, 0.05); }

.kpi-icon  { font-size: 1.6rem; line-height: 1; }
.kpi-value { font-size: 1.8rem; font-weight: 700; font-family: 'Cormorant Garamond', serif; color: var(--text-primary); }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Section wrapper */
.stats-section {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.stats-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stats-section-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.stats-badge {
  background: rgba(116, 24, 32, 0.12);
  border: 1px solid rgba(116, 24, 32, 0.25);
  color: var(--wine-gold);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.72rem;
  white-space: nowrap;
}

/* Period form */
.stats-period-form { display: flex; flex-direction: column; gap: 1rem; }

.stats-period-inputs {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.stats-period-inputs .form-group { flex: 1; min-width: 140px; }

.stats-quick-ranges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-range-btn {
  background: rgba(66, 7, 13, 0.048);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.quick-range-btn:hover {
  background: rgba(116, 24, 32, 0.12);
  color: var(--wine-gold);
  border-color: rgba(116, 24, 32, 0.3);
}

.stats-period-result {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: rgba(66, 7, 13, 0.036);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.period-result-item { display: flex; flex-direction: column; gap: 0.25rem; }
.period-result-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.period-result-value { font-size: 1.6rem; font-weight: 700; font-family: 'Cormorant Garamond', serif; color: var(--text-primary); }
.period-result-value.revenue { color: var(--wine-gold-light); }
.period-result-divider { width: 1px; height: 48px; background: var(--border-glass); }

/* Top wines list */
.stats-top-list { display: flex; flex-direction: column; gap: 0.6rem; }

.stats-top-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-rows: auto 6px;
  column-gap: 1rem;
  row-gap: 0.4rem;
  align-items: center;
  background: rgba(66, 7, 13, 0.024);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 0.75rem;
  transition: var(--transition);
}

.stats-top-item:hover { border-color: rgba(116, 24, 32, 0.2); background: rgba(66, 7, 13, 0.048); }

.stats-rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(66, 7, 13, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.rank-gold   { background: rgba(116, 24, 32, 0.2); color: var(--wine-gold);  border-color: rgba(116, 24, 32, 0.4); }
.rank-silver { background: rgba(120, 120, 120, 0.15); color: #6B6B6B;            border-color: rgba(120, 120, 120, 0.3); }
.rank-bronze { background: rgba(154, 91, 44, 0.2); color: #9A5B2C;           border-color: rgba(154, 91, 44, 0.35); }

.stats-top-info { min-width: 0; }
.stats-top-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-top-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 3px; font-size: 0.75rem; }

.stats-top-right  { text-align: right; }
.stats-top-units  { font-size: 1rem; font-weight: 700; color: var(--wine-gold-light); }
.stats-top-price  { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* Progress bar row (spans all 3 columns) */
.stats-bar-wrapper {
  grid-column: 1 / -1;
  background: rgba(66, 7, 13, 0.06);
  border-radius: 3px;
  height: 4px;
  overflow: hidden;
}

.stats-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--wine-red), var(--wine-gold));
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 4px;
}

/* Chart wrapper */
.stats-chart-wrapper {
  position: relative;
  padding: 0.5rem 0;
}

@media (max-width: 640px) {
  .stats-period-inputs { flex-direction: column; }
  .stats-period-result { gap: 1rem; }
  .period-result-divider { width: 100%; height: 1px; }
  .stats-top-item { grid-template-columns: 32px 1fr auto; }
}

