:root {
  --paper: #eef3ef;
  --window: rgba(250, 252, 250, 0.96);
  --panel: rgba(255, 255, 255, 0.58);
  --ink: #16231f;
  --ink-soft: #53635d;
  --ink-faint: #7b8984;
  --line: rgba(22, 35, 31, 0.13);
  --line-strong: rgba(22, 35, 31, 0.22);
  --accent: #0b806b;
  --green: #0b806b;
  --blue: #3478a8;
  --amber: #a8682d;
  --rose: #b64f5b;
  --shadow: rgba(24, 58, 49, 0.13);
  --radius: 14px;
  --duration-fast: 160ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  --paper: #0d1715;
  --window: rgba(18, 31, 27, 0.96);
  --panel: rgba(19, 37, 32, 0.72);
  --ink: #edf8f4;
  --ink-soft: #b7cbc4;
  --ink-faint: #82968f;
  --line: rgba(226, 245, 238, 0.13);
  --line-strong: rgba(226, 245, 238, 0.23);
  --accent: #63d6bd;
  --green: #63d6bd;
  --blue: #77b9e5;
  --amber: #e5aa68;
  --rose: #f08a98;
  --shadow: rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--paper);
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 2%, color-mix(in srgb, var(--green) 12%, transparent), transparent 27rem),
    linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--paper) 92%, var(--ink) 8%));
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.stats-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 38px));
  margin: 0 auto;
  padding: 18px 0;
}

.stats-brand,
.stats-nav-actions,
.back-link {
  display: inline-flex;
  align-items: center;
}

.stats-brand {
  gap: 9px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.stats-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--window);
  box-shadow: 0 4px 0 var(--shadow);
  color: var(--accent);
  place-items: center;
}

.stats-brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.stats-brand > i {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}

.stats-brand strong {
  color: var(--accent);
}

.stats-nav-actions {
  gap: 8px;
}

.theme-toggle,
.back-link {
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--window);
  color: var(--ink-soft);
  text-decoration: none;
}

.theme-toggle {
  width: 42px;
  cursor: pointer;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.back-link {
  gap: 7px;
  padding: 0 14px;
  font-size: 12px;
}

.back-link svg {
  width: 14px;
  height: 14px;
}

.stats-main {
  width: min(1180px, calc(100% - 38px));
  margin: 0 auto;
  padding: 12px 0 34px;
}

.stats-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 4px 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.panel-kicker {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 750;
}

.stats-hero h1 {
  margin: 7px 0 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.14;
}

.stats-hero p {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.refresh-state {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--window);
  color: var(--ink-soft);
  font-size: 10px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 16%, transparent);
}

.refresh-state.error .live-dot {
  background: var(--rose);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rose) 16%, transparent);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  position: relative;
  min-width: 0;
  padding: 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--window);
  box-shadow: 0 8px 24px var(--shadow);
}

.metric-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--card-accent);
  content: "";
}

.accent-green {
  --card-accent: var(--green);
}

.accent-blue {
  --card-accent: var(--blue);
}

.accent-amber {
  --card-accent: var(--amber);
}

.accent-rose {
  --card-accent: var(--rose);
}

.metric-icon {
  display: grid;
  width: 32px;
  height: 32px;
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--card-accent) 30%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--card-accent) 10%, transparent);
  color: var(--card-accent);
  place-items: center;
}

.metric-icon svg {
  width: 16px;
  height: 16px;
}

.metric-label,
.metric-card small {
  display: block;
  color: var(--ink-faint);
  font-size: 10px;
}

.metric-card strong {
  display: block;
  margin: 6px 0 3px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 23px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.chart-panel,
.info-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--window);
  box-shadow: 0 8px 24px var(--shadow);
}

.chart-panel {
  padding: 17px 17px 10px;
}

.chart-panel:first-child {
  grid-column: 1 / -1;
}

.chart-panel > header,
.info-panel > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chart-panel h2,
.info-panel h2 {
  margin: 3px 0 0;
  font-size: 15px;
}

.chart-panel-actions {
  display: flex;
  flex: none;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
}

.chart-panel-actions > strong {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
}

.period-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.period-switch button {
  min-width: 38px;
  min-height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 750;
}

.period-switch button:hover {
  color: var(--ink);
}

.period-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--paper);
}

.chart-stage {
  min-height: 210px;
  margin-top: 12px;
}

.chart-stage svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-empty {
  display: grid;
  min-height: 190px;
  color: var(--ink-faint);
  font-size: 11px;
  place-items: center;
  text-align: center;
}

.chart-gridline {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--ink-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  opacity: 0.13;
}

.chart-point {
  stroke: var(--window);
  stroke-width: 2;
}

.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 12px;
  margin-top: 12px;
}

.info-panel {
  padding: 17px;
}

.source-badge {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 9px;
}

.store-copy {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.store-art {
  width: 116px;
  aspect-ratio: 460 / 215;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

.store-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.store-copy h3 {
  margin: 0;
  font-size: 18px;
}

.store-copy p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.65;
}

.store-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 18px 0 0;
}

.store-details div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.store-details dt {
  color: var(--ink-faint);
  font-size: 9px;
}

.store-details dd {
  margin: 5px 0 0;
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-panel header > svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
}

.news-list {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.news-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.news-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.news-marker {
  width: 7px;
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.news-item a {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.news-item a:hover {
  color: var(--accent);
}

.news-item time,
.news-item p {
  display: block;
  margin: 4px 0 0;
  color: var(--ink-faint);
  font-size: 9.5px;
  line-height: 1.55;
}

.empty-copy {
  margin: 24px 0;
  color: var(--ink-faint);
  font-size: 11px;
  text-align: center;
}

.stats-footnote {
  margin: 18px 2px 0;
  color: var(--ink-faint);
  font-size: 10px;
}

@media (max-width: 960px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel:first-child {
    grid-column: auto;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .stats-nav,
  .stats-main {
    width: min(100% - 26px, 1180px);
  }

  .stats-brand > span:nth-child(2),
  .stats-brand > i,
  .back-link span {
    display: none;
  }

  .stats-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    padding: 14px;
  }

  .metric-card strong {
    font-size: 19px;
  }

  .store-copy {
    grid-template-columns: 1fr;
  }

  .store-art {
    width: min(220px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
