.public-stats-page,
.public-stats {
  --stats-ink: #172033;
  --stats-muted: #64748b;
  --stats-line: #d8e0ea;
  --stats-bg: #f6f8fb;
  --stats-surface: #ffffff;
  --stats-blue: #2563eb;
  --stats-cyan: #0891b2;
  --stats-green: #16a34a;
  --stats-amber: #d97706;
  --stats-red: #dc2626;
  --stats-violet: #7c3aed;
  --stats-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

.public-stats {
  color: var(--stats-ink);
}

.public-stats-page {
  margin: 0;
  min-height: 100vh;
  background: var(--stats-bg);
  color: var(--stats-ink);
  font-family: 'Prompt', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.public-stats-page * {
  box-sizing: border-box;
}

.public-stats-page,
.public-stats {
  overflow-wrap: anywhere;
}

.stats-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px clamp(16px, 4vw, 36px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--stats-line);
  backdrop-filter: blur(14px);
}

.stats-brand {
  color: #0f766e;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.stats-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-nav a,
.stats-toolbar button,
.public-stats-link {
  min-height: 40px;
  border: 1px solid var(--stats-line);
  border-radius: 8px;
  background: var(--stats-surface);
  color: var(--stats-ink);
  padding: 8px 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.stats-nav a:hover,
.stats-toolbar button:hover,
.public-stats-link:hover {
  border-color: var(--stats-cyan);
  color: #0f766e;
}

.stats-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.stats-hero,
.stats-privacy-box,
.public-stats-panel {
  background: var(--stats-surface);
  border: 1px solid var(--stats-line);
  border-radius: 8px;
  box-shadow: var(--stats-shadow);
}

.stats-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(18px, 4vw, 30px);
  margin-bottom: 14px;
}

.stats-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.22;
}

.stats-hero p,
.stats-privacy-box span,
.public-stats-panel-head span,
.public-stats-privacy {
  color: var(--stats-muted);
}

.stats-hero p {
  margin: 0;
  font-size: .95rem;
}

.stats-toolbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-toolbar label {
  display: grid;
  gap: 6px;
}

.stats-toolbar label span {
  color: var(--stats-muted);
  font-size: .82rem;
  font-weight: 700;
}

.stats-toolbar select {
  min-height: 40px;
  border: 1px solid var(--stats-line);
  border-radius: 8px;
  background: #fff;
  color: var(--stats-ink);
  padding: 7px 10px;
  font: inherit;
}

.stats-toolbar select:focus,
.stats-toolbar button:focus {
  outline: 3px solid rgba(8, 145, 178, .16);
  border-color: var(--stats-cyan);
}

.public-stats-preview {
  overflow: hidden;
}

.public-stats-head {
  align-items: center;
}

.public-stats-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.stats-metric-band {
  margin-bottom: 12px;
}

.public-stat-card {
  min-height: 106px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--stats-line);
  border-top: 4px solid var(--tone, var(--stats-cyan));
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.public-stat-card span {
  color: var(--stats-muted);
  font-size: .78rem;
  font-weight: 700;
}

.public-stat-card strong {
  display: block;
  color: var(--stats-ink);
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1;
}

.public-stat-card small {
  color: var(--stats-muted);
  font-size: .76rem;
}

.public-stats-grid,
.stats-chart-grid {
  display: grid;
  gap: 12px;
}

.public-stats-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  margin-top: 12px;
}

.stats-chart-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.stats-panel-wide {
  grid-column: span 2;
}

.public-stats-panel {
  min-width: 0;
  padding: 16px;
}

.public-stats-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.public-stats-panel-head strong {
  display: block;
  color: var(--stats-ink);
  font-size: 1rem;
}

.public-stats-panel-head span {
  display: block;
  font-size: .84rem;
}

.public-stats-chart {
  min-height: 230px;
  border: 1px solid var(--stats-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0%, #f8fbfc 100%);
  overflow: hidden;
}

.public-chart-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
  color: var(--stats-muted);
  font-size: .78rem;
  font-weight: 700;
  flex-wrap: wrap;
}

.public-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.public-chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.stats-trend-large {
  min-height: 320px;
}

.public-stats-svg {
  display: block;
  width: 100%;
  min-height: inherit;
}

.public-axis-label,
.public-chart-label {
  fill: var(--stats-muted);
  font-size: 10px;
}

.public-stats-donut-wrap {
  display: grid;
  gap: 12px;
  justify-items: center;
  align-content: start;
  min-height: 230px;
}

.public-donut {
  width: min(190px, 64vw);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--stats-line);
}

.public-donut-core {
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--stats-line);
}

.public-donut-core strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.05;
}

.public-legend,
.public-stats-bars,
.public-milestones {
  display: grid;
  gap: 10px;
}

.public-legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  color: var(--stats-muted);
  font-size: .82rem;
}

.public-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.public-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(120px, 2fr) auto;
  gap: 10px;
  align-items: center;
  font-size: .84rem;
}

.public-bar-label {
  min-width: 0;
  color: var(--stats-ink);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e6edf3;
  overflow: hidden;
}

.public-bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--stats-cyan), var(--stats-green));
}

.public-bar-value {
  color: var(--stats-muted);
  font-weight: 800;
}

.public-milestone {
  display: grid;
  grid-template-columns: minmax(120px, .75fr) minmax(160px, 1fr) minmax(150px, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--stats-line);
  border-radius: 8px;
  background: #fbfdff;
  font-size: .84rem;
}

.public-milestone strong,
.public-milestone span,
.public-milestone small {
  display: block;
}

.public-milestone span,
.public-milestone small {
  color: var(--stats-muted);
}

.stats-privacy-box {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 14px;
}

.stats-privacy-box strong {
  color: #0f766e;
}

.public-stats-privacy {
  margin: 12px 0 0;
  font-size: .84rem;
}

.public-stats-empty,
.public-stats-error {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1px dashed var(--stats-line);
  border-radius: 8px;
  color: var(--stats-muted);
  text-align: center;
  padding: 16px;
}

.public-stats-error {
  color: var(--stats-red);
}

@media (max-width: 1060px) {
  .public-stats-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .public-stats-grid,
  .stats-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .stats-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 14px;
  }

  .stats-topbar,
  .stats-hero {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stats-nav,
  .stats-toolbar {
    justify-content: flex-start;
  }

  .stats-toolbar > * {
    flex: 1 1 150px;
  }

  .public-stats-metrics,
  .public-stats-grid,
  .stats-chart-grid {
    grid-template-columns: 1fr;
  }

  .stats-panel-wide {
    grid-column: auto;
  }

  .public-milestone {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .stats-topbar {
    align-items: stretch;
    padding: 12px 14px;
  }

  .stats-brand {
    white-space: normal;
    line-height: 1.25;
  }

  .stats-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
  }

  .stats-shell {
    width: calc(100vw - 24px);
    padding-top: 12px;
  }

  .stats-hero,
  .stats-privacy-box,
  .public-stats-panel {
    border-radius: 8px;
  }

  .stats-hero {
    gap: 14px;
    padding: 18px;
  }

  .stats-hero h1 {
    font-size: clamp(1.7rem, 9vw, 2.2rem);
  }

  .stats-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stats-toolbar > * {
    width: 100%;
  }

  .stats-toolbar button,
  .public-stats-link {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }

  .public-stats-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .public-stat-card {
    min-height: 100px;
    padding: 12px;
  }

  .public-stat-card strong {
    font-size: 1.55rem;
  }

  .public-stats-panel {
    padding: 13px;
  }

  .public-stats-chart,
  .stats-trend-large,
  .public-stats-donut-wrap {
    min-height: 210px;
  }

  .public-bar-row {
    grid-template-columns: 1fr auto;
  }

  .public-bar-track {
    grid-column: 1 / -1;
  }
}
