.stats-mode, .stats-src, .stats-period {
  display: inline-flex; gap: 4px; padding: 4px;
  max-width: 100%; box-sizing: border-box;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill);
}
.stats-mode { margin-top: var(--s4); }
.stats-mode-btn, .stats-src-btn, .stats-period-btn {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 var(--s5);
  border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--muted);
  font: inherit; font-size: .9375rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
@media (hover: hover) { .stats-mode-btn:hover, .stats-src-btn:hover, .stats-period-btn:hover { color: var(--ink); } }
.stats-mode-btn[aria-pressed="true"], .stats-src-btn[aria-pressed="true"], .stats-period-btn[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
}
.stats-mode-btn:focus-visible, .stats-src-btn:focus-visible, .stats-period-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 640px) {
  .stats-mode, .stats-src { display: flex; width: 100%; }
}

.stats-slot .stats-src, .stats-slot .stats-pick, .stats-slot .stats-period { margin-top: var(--s3); }
.stats-pick-btn[hidden] { display: none; }

.stats-empty-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9375rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
@media (hover: hover) { .stats-empty-btn:hover { border-color: var(--ink); } }
.stats-empty-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.stats-table .stats-delta, .stats-table .stats-cur { width: 1%; text-align: right; white-space: nowrap; }
.stats-table tbody .stats-delta span { font-weight: 700; }
.stats-table tbody .stats-delta .stats-none { font-weight: 400; }
.stats-table tbody .stats-cur { color: var(--muted); font-size: .8125rem; }

.stats-table tbody th, .stats-table tbody td { vertical-align: middle; }

.stats-place-delta { font-weight: 400; }
.stats-place-delta .stats-up, .stats-place-delta .stats-down { font-weight: 700; }

.stats-card .stats-status.stats-status-empty {
  margin-top: var(--s4); color: var(--ink); font-size: 1.0625rem; font-weight: 600; max-width: 60ch;
}
.stats-empty { margin-top: var(--s2); }
.stats-empty .sub { margin: 0; max-width: 60ch; }
.stats-empty-btn { margin-top: var(--s3); white-space: normal; text-align: center; max-width: 100%; }

.stats-out { transition: opacity .15s; }
.stats-out.stats-loading { opacity: .45; }
@media (prefers-reduced-motion: reduce) { .stats-out { transition: none; } }

@media (max-width: 400px) {
  .stats-mode-btn, .stats-src-btn, .stats-period-btn { padding: 0 var(--s3); }
  .stats-table tbody .stats-cur { font-size: .75rem; }
  .stats-card .stats-status.stats-status-empty { font-size: 1rem; }
}

.stats-filter { margin-top: var(--s3); }
.stats-filter[hidden] { display: none; }
.stats-filter-sum {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-2);
  font-weight: 600; font-size: .9375rem; cursor: pointer; list-style: none;
}
.stats-filter-sum::-webkit-details-marker { display: none; }
.stats-filter-sum::after { content: "▾"; margin-left: var(--s2); color: var(--muted); }
.stats-filter[open] > .stats-filter-sum::after { content: "▴"; }
.stats-filter-sum:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.stats-filter-body { margin-top: var(--s3); }
.stats-filter:not([open]) > .stats-filter-body { display: none; }
.stats-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 640px) { .stats-filter-grid { grid-template-columns: 1fr; } }
.stats-filter-field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.stats-filter-label { font-size: .875rem; color: var(--muted); font-weight: 600; }
.stats-filter-sel {
  min-height: 44px; width: 100%; padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md, 12px);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
}
.stats-filter-sel:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.stats-filter-reset { margin-top: var(--s3); }
.stats-filter-reset[hidden] { display: none; }
