:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #18253b;
  background: #f4f7fb;
  font-synthesis: none;
  --muted: #53627b;
  --accent: #2850d4;
  --border: #dbe3f0;
  --paper: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-inline-size: 0; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible {
  outline: 3px solid #7895fc;
  outline-offset: 2px;
}
h1[tabindex="-1"]:focus { outline: none; }

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 22%, #e9efff 0, #f4f7fb 60%);
}
.login-card {
  width: min(100%, 420px);
  padding: 42px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 24px 68px rgb(35 61 117 / 9%);
}
.login-card > .brand-mark { width: 49px; height: 49px; border-radius: 14px; }
.login-card h1 { margin: 22px 0 30px; font-size: clamp(22px, 5.5vw, 30px); letter-spacing: -.025em; }
.login-card form { display: grid; gap: 20px; }
.session-check { color: var(--muted); font-size: 14px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: white;
  background: var(--accent);
}
.brand-mark svg { width: 65%; height: 65%; }
.field { display: grid; gap: 8px; min-width: 0; }
.field label { color: #34445e; font-size: 13px; font-weight: 650; }
.field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #cbd6e7;
  border-radius: 9px;
  background: var(--paper);
  color: inherit;
  font-size: 16px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}
.button-primary { background: var(--accent); color: white; }
.button-primary:hover:enabled { background: #1f42ba; }
.button-secondary { border-color: var(--border); background: var(--paper); color: #34445e; }
.button-secondary:hover:enabled, .button-preset:hover:enabled { background: #edf2ff; }
.login-button { min-height: 46px; margin-top: 4px; }
.button-preset { min-height: 36px; padding: 6px 11px; color: #3c4d67; background: #f4f7fb; }
.button-preset[aria-pressed="true"] { color: #2248c5; background: #e9efff; border-color: #d3dfff; }

.topbar { border-bottom: 1px solid var(--border); background: var(--paper); }
.topbar-content {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100% - 48px, 1080px);
  margin-inline: auto;
  padding-block: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 760; white-space: nowrap; }
.account { display: flex; min-width: 0; align-items: center; gap: 12px; }
.account > span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.account .button { min-height: 38px; }
.overview { width: min(100% - 48px, 1080px); margin-inline: auto; padding: 55px 0 72px; }
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: clamp(29px, 5vw, 39px); letter-spacing: -.04em; }
.controls {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
}
.controls form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; }
.date-controls, .date-presets { display: flex; align-items: flex-end; gap: 9px; }
.date-controls .field { width: 10rem; }
.date-controls .button { min-height: 44px; padding-inline: 20px; }
.controls .hint, .controls .error { flex-basis: 100%; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff1f2;
  color: #9c2633;
  font-size: 14px;
  line-height: 1.5;
}
.page-header .error { margin-top: 12px; }
.results { margin-top: 33px; }
.results-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.results-header h2 { font-size: 18px; }
.results-header .hint { margin-top: 5px; }
.refresh svg { width: 17px; height: 17px; }
.results > .error { margin-bottom: 14px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.metric {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--paper);
  padding: 24px;
}
.metric-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.metric-icon svg { width: 21px; height: 21px; }
.people { background: #eaf0ff; color: #2a50cf; }
.subscriptions { background: #e6f5f0; color: #176c57; }
.metric h3 { margin-top: 20px; color: var(--muted); font-size: 15px; font-weight: 650; }
.metric-value {
  margin-top: 5px;
  font-size: clamp(31px, 5vw, 46px);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  letter-spacing: -.04em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
/* Keep the metric line in place while the loading indicator is visible. */
.metrics[aria-busy="true"] .metric-value { position: relative; visibility: hidden; }
.metrics[aria-busy="true"] .metric-value::before {
  content: "";
  position: absolute;
  inset-block-start: calc(50% - .3em);
  inset-inline-start: 0;
  inline-size: .6em;
  block-size: .6em;
  border: 3px solid var(--border);
  border-block-start-color: var(--accent);
  border-radius: 50%;
  visibility: visible;
  animation: metric-spin .8s linear infinite;
}
@keyframes metric-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  .metrics[aria-busy="true"] .metric-value::before { animation: none; }
}
.result-status { margin-top: 10px; min-height: 20px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .overview, .topbar-content { width: calc(100% - 32px); }
  .overview { padding-top: 32px; }
  .topbar-content { gap: 10px; }
  .account { gap: 6px; }
  .account .button { padding-inline: 8px; }
  .controls { padding: 16px; }
  .date-controls { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-controls .field { width: auto; }
  .date-controls .button { grid-column: 1 / -1; }
  .metric { padding: 16px; }
  .metrics { gap: 10px; }
  .login-card { padding: 28px; }
}
@media (max-width: 360px) {
  .date-controls { grid-template-columns: minmax(0, 1fr); }
  .brand-mark { width: 30px; height: 30px; }
}
