/* ---------- Stats and chart styles ----------
   All fills are solid colours. No blur, glow, or motion effects. */

.stats-updated {
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: var(--space-3);
}
.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 110px;
  padding: 1.15rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.kpi-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.kpi-value {
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi-note { color: var(--ink-soft); font-size: 0.74rem; }
.kpi-spark {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 32px;
  opacity: 0.5;
  pointer-events: none;
}
.kpi-spark .spark-fill { stroke: none; opacity: 0.35; }

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.trend-up { background: var(--accent-soft); color: var(--ink); }
.trend-down { background: var(--danger-soft); color: var(--danger); }
.trend-flat { background: var(--surface-2); color: var(--muted); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.chart-card {
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.chart-wide {
  grid-column: 1 / -1;
  margin-top: 1rem;
}
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chart-head h3 { font-size: 1.05rem; }
.chart-head p { color: var(--ink-soft); font-size: 0.82rem; }

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.seg {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.seg-btn {
  padding: 0.35rem 0.65rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn:hover { background: var(--surface-3); color: var(--ink); }
.seg-btn.active { background: var(--button-bg); color: var(--button-fg); }
.chart-input,
.chart-select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.78rem;
}
.chart-input { width: 150px; }
.chart-input:focus,
.chart-select:focus { border-color: var(--primary); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.swatch.views { background: var(--primary); }
.swatch.uniques { background: var(--accent); }

.chart-canvas {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.chart-canvas-lg { min-height: 300px; }
.chart-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 240px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  pointer-events: none;
}
.chart-tooltip .tt-title { margin-bottom: 0.2rem; font-weight: 700; }
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-soft);
}
.chart-tooltip .tt-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ---------- SVG charts ---------- */
.chart-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart-svg .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis-label {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
}
.chart-svg .bar { cursor: pointer; }
.chart-svg .bar:hover { opacity: 0.75; }
.chart-svg .line-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}
.chart-svg .area-path { stroke: none; opacity: 0.16; }
.chart-svg .dot { cursor: pointer; }
.chart-svg .dot:hover { opacity: 0.7; }
.chart-svg .hover-line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.6;
}

.chart-empty {
  padding: 3rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Platform donut ---------- */
.platform-layout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
}
.donut-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}
.donut-wrap svg { width: 100%; height: 100%; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.donut-center strong { font-size: 1.35rem; font-weight: 700; }
.donut-center span { color: var(--muted); font-size: 0.7rem; }
.platform-legend { display: flex; flex-direction: column; gap: 0.35rem; }
.platform-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.35rem;
  border-radius: 3px;
  font-size: 0.78rem;
}
.platform-row:hover { background: var(--surface-2); }
.platform-swatch { width: 12px; height: 12px; border-radius: 2px; }
.platform-name {
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.platform-value { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Download bars ---------- */
.download-list { display: flex; flex-direction: column; gap: 0.6rem; }
.download-row {
  display: grid;
  grid-template-columns: minmax(90px, 200px) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  padding: 0.2rem 0;
}
.download-tag {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.download-track {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
}
.download-fill {
  display: block;
  height: 100%;
  background: var(--primary);
}
.download-row strong { font-size: 0.82rem; font-variant-numeric: tabular-nums; }

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.timeline-bar:last-child { border-bottom: 0; }
.timeline-tag {
  min-width: 70px;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.timeline-meta { min-width: 90px; color: var(--muted); font-size: 0.72rem; }
.timeline-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-3);
}
.timeline-fill { height: 100%; background: var(--primary); }
.timeline-value {
  min-width: 48px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-footnote {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 719px) {
  .chart-controls { justify-content: flex-start; }
  .chart-head { flex-direction: column; }
  .platform-layout { grid-template-columns: 1fr; }
  .donut-wrap { width: 140px; height: 140px; }
  .download-row { grid-template-columns: minmax(70px, 120px) minmax(0, 1fr) auto; gap: 0.5rem; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
