:root {
  color-scheme: dark;
  --background: #1a1a1a;
  --surface: #242424;
  --surface-hover: #303030;
  --border: #303030;
  --grid: #262626;
  --text: #c1c1c1;
  --text-strong: #ffffff;
  --accent: #3b82f6;
  --radius: 4px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  background: var(--background);
  color: var(--text);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  background: var(--background);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--grid);
}

h1,
h2 {
  color: var(--text-strong);
}

h1 {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.subtitle {
  margin-top: 0.25rem;
  color: var(--text);
  font-size: 0.85rem;
  opacity: 0.7;
}

.site-picker {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 1 22rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

select {
  width: 100%;
  min-width: 0;
  height: 2.1rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

select:hover:not(:disabled) {
  background: var(--surface-hover);
}

select:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats .card {
  padding: 1rem;
}

.stats p {
  color: var(--text);
  font-size: 0.78rem;
  opacity: 0.7;
}

.stat-value {
  margin-top: 0.35rem;
  color: var(--text-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
}

.chart-card {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  background: var(--background);
}

.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.timezone {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.75rem;
  opacity: 0.65;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 0.75rem 0 1.15rem;
  color: var(--text);
  font-size: 0.72rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 0.75rem;
  height: 0.75rem;
  border: 1px solid var(--accent);
}

.legend-visitors {
  background: rgba(59, 130, 246, 0.72);
}

.legend-views {
  background: rgba(59, 130, 246, 0.35);
}

.chart-container {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 19rem;
}

.chart-fallback[hidden] {
  display: none;
}

.chart-fallback {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--text);
}

canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
}

@media (max-width: 768px) {
  html {
    font-size: clamp(14px, 1vw + 8px, 16px);
  }

  body {
    padding: 0.6rem;
  }

  header {
    align-items: stretch;
    flex-direction: column;
    gap: 0.8rem;
  }

  .site-picker {
    flex-basis: auto;
    width: 100%;
  }

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

  .chart-card {
    margin-top: 0.6rem;
    padding: 0.6rem 0.25rem 0.35rem;
  }

  .chart-heading,
  .chart-legend {
    padding-inline: 0.45rem;
  }

  .chart-container {
    height: 15rem;
  }
}

@media (max-width: 420px) {
  body {
    padding: 0.35rem;
  }

  .stats .card {
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.45rem;
  }

  .chart-card {
    padding-inline: 0.1rem;
  }

  .chart-container {
    height: 14rem;
  }
}
