/* ── admin-statistics.css v2 — Phase 3B ─────────────────────────────────────
   All selectors scoped to #page-admin-stats to avoid affecting other pages.  */

/* ── Filter card ─────────────────────────────────────────────────────────── */
#page-admin-stats .st-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
#page-admin-stats .st-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}
#page-admin-stats .st-label {
  font-size: 0.70rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#page-admin-stats .st-custom-dates {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── KPI grid ─────────────────────────────────────────────────────────────── */
#page-admin-stats .st-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
#page-admin-stats .st-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  min-width: 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  border-top: 3px solid #2563eb;
}
#page-admin-stats .st-kpi-card.accent-green  { border-top-color: #16a34a; }
#page-admin-stats .st-kpi-card.accent-orange { border-top-color: #ea580c; }
#page-admin-stats .st-kpi-card.accent-red    { border-top-color: #e53e3e; }
#page-admin-stats .st-kpi-card.accent-teal   { border-top-color: #0d9488; }
#page-admin-stats .st-kpi-card.accent-violet { border-top-color: #7c3aed; }
#page-admin-stats .st-kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0;
}
#page-admin-stats .st-kpi-value {
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 750;
  color: #0f172a;
}
#page-admin-stats .st-kpi-note {
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #64748b;
}

/* ── Quality card ─────────────────────────────────────────────────────────── */
#page-admin-stats .st-quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
#page-admin-stats .st-q-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#page-admin-stats .st-q-label {
  font-size: 0.70rem;
  color: #64748b;
  font-weight: 600;
}
#page-admin-stats .st-q-val {
  font-size: 0.96rem;
  font-weight: 700;
  color: #0f172a;
}
#page-admin-stats .st-q-note {
  font-size: 0.67rem;
  color: #94a3b8;
  line-height: 1.4;
}
#page-admin-stats .st-warn-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  margin-top: 4px;
  border: 1px solid #fde68a;
}

/* ── Chart wrappers ───────────────────────────────────────────────────────── */
#page-admin-stats .st-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 320px;
}
#page-admin-stats .st-chart-wrap canvas {
  width: 100% !important;
  height: 320px !important;
}

/* ── Distribution bars ────────────────────────────────────────────────────── */
#page-admin-stats .st-dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
#page-admin-stats .st-dist-label {
  width: 100px;
  flex-shrink: 0;
  color: #0f172a;
  font-weight: 500;
}
#page-admin-stats .st-dist-bar-bg {
  flex: 1;
  background: #f1f5f9;
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}
#page-admin-stats .st-dist-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}
#page-admin-stats .st-dist-pct {
  width: 48px;
  text-align: right;
  color: #64748b;
  font-size: 0.78rem;
}
#page-admin-stats .st-dist-cnt {
  width: 48px;
  text-align: right;
  font-weight: 700;
  color: #0f172a;
  font-size: 0.78rem;
}

/* Cumulative pills */
#page-admin-stats .st-cum-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
#page-admin-stats .st-cum-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 80px;
}
#page-admin-stats .st-cum-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1d4ed8;
}
#page-admin-stats .st-cum-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

/* ── Comparison cards ─────────────────────────────────────────────────────── */
#page-admin-stats .st-cmp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
#page-admin-stats .st-cmp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
#page-admin-stats .st-cmp-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
}
#page-admin-stats .st-cmp-card.overall {
  background: #eff6ff;
  border-color: #bfdbfe;
}
#page-admin-stats .st-cmp-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#page-admin-stats .st-cmp-badge {
  font-size: 0.66rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 2px 6px;
  border: 1px solid #fde68a;
  font-weight: 700;
}
#page-admin-stats .st-cmp-unsupported {
  font-size: 0.78rem;
  color: #64748b;
  font-style: italic;
  margin-top: 6px;
}
#page-admin-stats .st-cmp-tbl {
  width: 100%;
  font-size: 0.79rem;
  border-collapse: collapse;
}
#page-admin-stats .st-cmp-tbl td {
  padding: 3px 0;
  color: #64748b;
}
#page-admin-stats .st-cmp-tbl td:last-child {
  text-align: right;
  font-weight: 700;
  color: #0f172a;
}
#page-admin-stats .st-cmp-perf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}
#page-admin-stats .st-cmp-mini {
  text-align: center;
  flex: 1 1 60px;
}
#page-admin-stats .st-cmp-mini-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
}
#page-admin-stats .st-cmp-mini-lbl {
  font-size: 0.62rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── Group / toggle buttons ───────────────────────────────────────────────── */
#page-admin-stats .st-group-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
#page-admin-stats .st-group-btn {
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid #e2e8f0;
  font-size: 0.78rem;
  cursor: pointer;
  background: #fff;
  color: #64748b;
  font-weight: 500;
  transition: all 0.15s;
}
#page-admin-stats .st-group-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 700;
}
#page-admin-stats .st-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
#page-admin-stats .st-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid #e2e8f0;
  user-select: none;
  background: #fff;
  color: #64748b;
  transition: all 0.15s;
}
#page-admin-stats .st-toggle.active {
  font-weight: 700;
  border-color: currentColor;
  background: #f8fafc;
}
#page-admin-stats .st-toggle .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Summary table ────────────────────────────────────────────────────────── */
#page-admin-stats .st-tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#page-admin-stats .st-tbl {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: 0.80rem;
}
#page-admin-stats .st-tbl th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  padding: 9px 10px;
  text-align: left;
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
#page-admin-stats .st-tbl th:hover { color: #2563eb; }
#page-admin-stats .st-tbl th.sorted { color: #2563eb; }
#page-admin-stats .st-tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  color: #0f172a;
}
#page-admin-stats .st-tbl tbody tr:hover td { background: #f8fafc; }
#page-admin-stats .st-tbl td.num { text-align: right; }
#page-admin-stats .st-tbl td.muted { color: #64748b; }
#page-admin-stats .st-tbl td.unsupported { color: #94a3b8; font-style: italic; }

/* Pagination */
#page-admin-stats .st-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 0;
  gap: 10px;
  flex-wrap: wrap;
}
#page-admin-stats .st-page-info {
  font-size: 0.80rem;
  color: #64748b;
}
#page-admin-stats .st-page-btns {
  display: flex;
  gap: 6px;
}
#page-admin-stats .st-page-btn {
  padding: 6px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  color: #0f172a;
  font-weight: 500;
}
#page-admin-stats .st-page-btn:hover { background: #f1f5f9; }
#page-admin-stats .st-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Loading / empty / error ──────────────────────────────────────────────── */
#page-admin-stats .st-loading {
  text-align: center;
  padding: 32px 20px;
  color: #64748b;
  font-size: 0.88rem;
}
#page-admin-stats .st-skeleton {
  background: #e2e8f0;
  border-radius: 6px;
  height: 18px;
  margin: 8px 0;
  animation: st-pulse 1.4s ease-in-out infinite;
}
@keyframes st-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
#page-admin-stats .st-error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 14px 18px;
  color: #b91c1c;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  #page-admin-stats .st-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  #page-admin-stats .st-kpi-grid {
    grid-template-columns: 1fr;
  }
  #page-admin-stats .st-chart-wrap {
    min-height: 260px;
  }
  #page-admin-stats .st-chart-wrap canvas {
    height: 260px !important;
  }
  #page-admin-stats .st-cmp-grid {
    grid-template-columns: 1fr;
  }
  #page-admin-stats .st-filter-row { gap: 8px; }
  #page-admin-stats .st-filter-group { min-width: 110px; flex: 1 1 110px; }
}
