.stats-page {
  --stats-base: #e9eef2;
  --stats-surface: #edf1f4;
  --stats-text: #182b35;
  --stats-muted: #5d7180;
  --stats-line: #c9d5dc;
  --stats-teal: #006b91;
  --stats-blue: #006b91;
  --stats-yellow: #ffd000;
  --stats-raised: 7px 7px 16px #cbd4da, -7px -7px 16px #fff;
  --stats-inset: inset 4px 4px 9px #cbd4da, inset -4px -4px 9px #fff;
  background: var(--stats-base);
  color: var(--stats-text);
}

.stats-page .stats-shell {
  padding: 24px clamp(16px, 3vw, 44px) 48px;
}

.stats-page .stats-header {
  max-width: 1600px;
  min-height: 0;
  justify-content: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding: 6px 2px 20px;
  border: 0;
  border-bottom: 1px solid var(--stats-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.stats-page .stats-brand-logo {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  object-fit: cover;
}

.stats-page .stats-header > div {
  display: flex;
  min-height: 62px;
  flex-direction: column;
  justify-content: center;
}

.stats-page .stats-header h1 {
  margin: 0 0 6px;
  color: var(--stats-text);
  font-size: 27px;
  font-weight: 750;
  line-height: 1.18;
}

.stats-page .stats-header .stats-contact {
  margin: 0;
  color: var(--stats-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.stats-page .stats-header .stats-contact span {
  display: inline-block;
  white-space: nowrap;
}

.stats-page .stats-layout {
  max-width: 1600px;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 22px;
}

.stats-page .stats-sidebar,
.stats-page .stats-main {
  gap: 18px;
}

.stats-page .stats-card,
.stats-page .stats-summary-card {
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: var(--stats-surface);
  box-shadow: var(--stats-raised);
}

.stats-page .stats-card {
  padding: 20px;
}

.stats-page .stats-card h2 {
  color: var(--stats-text);
  font-size: 16px;
  font-weight: 750;
}

.stats-page .stats-sidebar .stats-card h2 {
  padding-left: 10px;
  border-left: 3px solid var(--stats-yellow);
}

.stats-page .stats-card label,
.stats-page .stats-checkset legend {
  color: #405867;
  font-size: 12px;
  font-weight: 700;
}

.stats-page .stats-card input:not([type="checkbox"]),
.stats-page .stats-card select,
.stats-page .stats-card textarea,
.stats-page .stats-table input,
.stats-page .stats-row-meta select {
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--stats-surface);
  box-shadow: var(--stats-inset);
  color: var(--stats-text);
}

.stats-page .stats-card input:focus-visible,
.stats-page .stats-card select:focus-visible,
.stats-page .stats-card textarea:focus-visible,
.stats-page .stats-table input:focus-visible,
.stats-page .stats-row-meta select:focus-visible {
  border-color: var(--stats-blue);
  outline: 2px solid rgba(0, 107, 145, .24);
  outline-offset: 2px;
}

.stats-page .stats-card button,
.stats-page .stats-table-card button,
.stats-page .stats-export-fallback {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 7px;
  background: var(--stats-surface);
  box-shadow: 4px 4px 9px #cbd4da, -4px -4px 9px #fff;
  color: var(--stats-teal);
  font-size: 13px;
  font-weight: 800;
}

.stats-page #statsSearchButton,
.stats-page #statsRunButton,
.stats-page #statsExportButton {
  background: var(--stats-teal);
  border-color: var(--stats-teal);
  box-shadow: 4px 4px 9px #cbd4da, -4px -4px 9px #fff;
  color: #fff;
}

.stats-page #statsSearchButton {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background .2s ease, box-shadow .25s ease, transform .2s ease;
}

.stats-page #statsSearchButton::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 48%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08) 25%, rgba(255, 255, 255, .5) 50%, rgba(255, 208, 0, .26) 68%, transparent);
  content: '';
  pointer-events: none;
  transform: translateX(-120%) skewX(-20deg);
}

.stats-page #statsSearchButton:not(:disabled):hover::before {
  animation: stats-search-sweep 1s ease-out;
}

.stats-page #statsSearchButton.is-searching:disabled {
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(255, 208, 0, .55), 0 0 20px rgba(0, 107, 145, .3), 4px 4px 9px #cbd4da, -4px -4px 9px #fff;
  animation: stats-search-glow 1.8s ease-in-out infinite;
}

.stats-page #statsSearchButton.is-searching::before {
  animation: stats-search-sweep 1.35s ease-in-out infinite;
}

@keyframes stats-search-sweep {
  to { transform: translateX(330%) skewX(-20deg); }
}

@keyframes stats-search-glow {
  50% { box-shadow: 0 0 0 2px rgba(255, 208, 0, .8), 0 0 28px rgba(0, 107, 145, .45), 4px 4px 9px #cbd4da, -4px -4px 9px #fff; }
}

.stats-page .stats-card button:not(:disabled):hover,
.stats-page .stats-table-card button:not(:disabled):hover,
.stats-page .stats-export-fallback:hover {
  background: #d9ebf1;
  color: #005573;
}

.stats-page #statsSearchButton:not(:disabled):hover,
.stats-page #statsRunButton:not(:disabled):hover,
.stats-page #statsExportButton:not(:disabled):hover {
  background: #005573;
  color: #fff;
}

.stats-page #statsSearchForm.recent-open {
  position: relative;
  z-index: 20;
  overflow: visible;
}

.stats-page .stats-search-field {
  position: relative;
  z-index: 3;
}

.stats-page .stats-recent-panel[hidden] {
  display: none;
}

.stats-page .stats-recent-panel {
  position: absolute;
  top: calc(100% - 3px);
  right: 0;
  left: 0;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 10px;
  background: rgba(237, 246, 252, .91);
  box-shadow: 0 16px 38px rgba(27, 52, 67, .2), 0 1px 3px rgba(27, 52, 67, .12);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px) scale(.985);
  transform-origin: top center;
  transition: opacity .18s ease, transform .22s ease, visibility .18s;
}

.stats-page #statsSearchForm.recent-open .stats-recent-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.stats-page .stats-recent-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 4px 11px 3px 13px;
  color: #687d8a;
  font-size: 11px;
  font-weight: 650;
}

.stats-page .stats-recent-heading span {
  white-space: nowrap;
}

.stats-page #statsSearchForm .stats-recent-heading button {
  width: auto;
  min-height: 24px;
  padding: 2px 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #25688c;
  font-size: 12px;
  font-weight: 600;
}

.stats-page #statsSearchForm .stats-recent-heading button:hover {
  background: transparent;
  color: #164b67;
}

.stats-page .stats-recent-list {
  display: grid;
  max-height: min(324px, 42vh);
  overflow-y: auto;
}

.stats-page #statsSearchForm .stats-recent-list button {
  display: grid;
  grid-template-columns: 18px 29px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 53px;
  padding: 6px 10px;
  border: 0;
  border-top: 1px solid rgba(102, 130, 147, .19);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #1c2d36;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background .14s ease;
}

.stats-page #statsSearchForm .stats-recent-list button:hover,
.stats-page #statsSearchForm .stats-recent-list button:focus-visible {
  background: rgba(203, 225, 241, .55);
  color: #1c2d36;
}

.stats-page .stats-recent-check {
  color: #1d3848;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.stats-page .stats-recent-avatar,
.stats-page .stats-recent-avatar img,
.stats-page .stats-recent-avatar .stats-avatar-fallback {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 7px;
  object-fit: cover;
}

.stats-page .stats-recent-avatar .stats-avatar-fallback {
  background: #26343d;
  color: #fff;
  font-size: 14px;
}

.stats-page .stats-recent-entry {
  display: grid;
  min-width: 0;
}

.stats-page .stats-recent-entry strong,
.stats-page .stats-recent-entry small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-page .stats-recent-entry strong {
  font-size: 14px;
  font-weight: 650;
}

.stats-page .stats-recent-entry small {
  color: #6d7f8a;
  font-size: 11px;
  font-weight: 500;
}

.stats-page button:focus-visible,
.stats-page a:focus-visible {
  outline: 2px solid var(--stats-blue);
  outline-offset: 3px;
}

.stats-page button:disabled {
  opacity: .52;
  box-shadow: none;
}

.stats-page .stats-checkset {
  border: 0;
  background: transparent;
  padding: 8px 0 4px;
}

.stats-page .stats-checkset label {
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: 6px;
  background: var(--stats-surface);
  box-shadow: 3px 3px 7px #d1d9de, -3px -3px 7px #fff;
}

.stats-page .stats-checkset input,
.stats-page .stats-original-toggle input {
  accent-color: var(--stats-teal);
}

.stats-page .stats-message,
.stats-page .stats-section-title p,
.stats-page .stats-account-option small {
  color: var(--stats-muted);
}

.stats-page .stats-message.ok { color: #136b46; }
.stats-page .stats-message.warn { color: #a92f43; }
.stats-page .stats-message.pending { color: var(--stats-blue); }

.stats-page .stats-summary-grid[hidden] { display: none; }
.stats-page #statsResultNote.is-error { color: #a92f43; }

.stats-page .stats-account-list {
  gap: 0;
  max-height: 228px;
  margin-top: 10px;
  overflow-x: hidden;
  padding: 0;
  border-top: 1px solid #cfdae0;
  border-bottom: 1px solid #cfdae0;
  scrollbar-color: #a6b8c2 transparent;
}

.stats-page .stats-account-list[hidden] {
  display: none;
}

.stats-page .stats-account-option,
.stats-page .stats-card .stats-account-option {
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 55px;
  padding: 7px 5px;
  border: 0;
  border-bottom: 1px solid #dbe4e9;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--stats-text);
  font-size: 13px;
  text-align: left;
  transition: background-color .16s ease;
}

.stats-page .stats-account-option:hover,
.stats-page .stats-card .stats-account-option:hover {
  background: #e9f2f6;
}

.stats-page .stats-account-option.active {
  background: #e3f0f5;
  box-shadow: inset 3px 0 0 var(--stats-teal);
}

.stats-page .stats-section-title span,
.stats-page .stats-table a {
  color: var(--stats-blue);
}

.stats-page .stats-account-option img,
.stats-page .stats-account-option .stats-avatar-fallback {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.stats-page .stats-avatar-fallback {
  background: #dceef4;
  color: var(--stats-teal);
}

.stats-page .stats-summary-card {
  min-height: 90px;
  padding: 15px;
}

.stats-page .stats-summary-card span {
  color: var(--stats-muted);
  font-size: 12px;
}

.stats-page .stats-summary-card strong {
  color: var(--stats-teal);
  font-size: 26px;
}

.stats-page .stats-table-wrap {
  border: 1px solid var(--stats-line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--stats-inset);
}

.stats-page .stats-table {
  background: #fff;
}

.stats-page .stats-table th {
  background: #e1eff3;
  color: #244c5d;
}

.stats-page .stats-table td {
  color: var(--stats-text);
}

.stats-page .stats-table tbody tr:nth-child(even):not(.stats-week-row) td {
  background: #f7f9fa;
}

.stats-page .stats-table tbody tr:hover:not(.stats-week-row) td {
  background: #eef6f8;
}

.stats-page .stats-week-row td {
  background: #fff0dd;
  color: #8a4c1c;
}

.stats-page .stats-auth-dialog {
  border-color: rgba(255, 255, 255, .75);
  background: var(--stats-surface);
  box-shadow: var(--stats-raised);
}

.stats-page .stats-auth-dialog .stats-auth-refresh {
  background: var(--stats-teal);
  color: #fff;
}

@media (max-width: 1180px) {
  .stats-page .stats-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .stats-page #statsRunForm {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .stats-page .stats-shell {
    padding: 16px 12px 36px;
  }

  .stats-page .stats-header {
    align-items: center;
    flex-direction: row;
    margin-bottom: 20px;
    padding-bottom: 15px;
  }

  .stats-page .stats-brand-logo {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .stats-page .stats-header > div {
    min-height: 52px;
  }

  .stats-page .stats-header h1 {
    font-size: 21px;
  }

  .stats-page .stats-layout,
  .stats-page .stats-sidebar,
  .stats-page .stats-main {
    gap: 14px;
  }

  .stats-page .stats-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-page #statsRunForm {
    grid-column: auto;
  }

  .stats-page .stats-card {
    padding: 17px;
  }

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

  .stats-page .stats-summary-card strong {
    font-size: 23px;
  }
}

@media (max-width: 380px) {
  .stats-page .stats-summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats-page #statsSearchButton,
  .stats-page #statsSearchButton::before {
    animation: none;
    transition: none;
  }

  .stats-page .stats-account-option {
    transition: none;
  }

  .stats-page .stats-recent-panel,
  .stats-page #statsSearchForm .stats-recent-list button {
    transition: none;
  }
}
