:root {
  --bg: #f5efe2;
  --paper: rgba(255, 251, 242, 0.84);
  --paper-strong: rgba(255, 250, 240, 0.95);
  --ink: #1a1814;
  --muted: #655c50;
  --line: rgba(38, 31, 22, 0.12);
  --shadow: 0 18px 60px rgba(56, 39, 16, 0.12);
  --accent: #0d6d6c;
  --accent-soft: rgba(13, 109, 108, 0.12);
  --warm: #bf5f2e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(191, 95, 46, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(13, 109, 108, 0.2), transparent 30%),
    linear-gradient(180deg, #fff9ef 0%, #f5efe2 42%, #efe4d2 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 85%);
}

.page-shell {
  width: min(1400px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: end;
  margin-bottom: 26px;
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--muted);
}

h1,
h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 5rem);
  line-height: 0.95;
  max-width: 12ch;
}

h2 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

.hero-text,
.panel-subtle,
.controls-note p,
.leader-meta,
.metric-copy p {
  color: var(--muted);
}

.hero-text {
  max-width: 56ch;
  margin-top: 14px;
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-badge,
.panel,
.metric-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero-badge {
  border-radius: 26px;
  padding: 22px;
  display: grid;
  gap: 10px;
}

.hero-badge strong {
  font-size: 1.6rem;
}

.content {
  display: grid;
  gap: 22px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  border-radius: 24px;
  padding: 18px 20px;
}

.metric-card::after,
.panel::after,
.hero-badge::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.36), transparent 70%);
  border-radius: 50%;
}

.metric-copy h3 {
  margin: 0 0 6px;
  font-size: 2rem;
  line-height: 1;
}

.metric-copy p {
  margin: 0;
}

.controls-panel {
  display: grid;
  grid-template-columns: 160px 170px 170px 160px minmax(0, 1fr);
  gap: 18px;
  align-items: end;
}

.panel {
  border-radius: 30px;
  padding: 22px;
}

.controls-note p:last-child {
  margin: 0;
}

select,
input[type="month"] {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(40, 28, 18, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--paper-strong);
  color: var(--ink);
  font: inherit;
}

input[type="month"]::-webkit-calendar-picker-indicator {
  opacity: 0.7;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.legend button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--paper-strong);
  color: var(--ink);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font: inherit;
  cursor: pointer;
}

.legend button.is-muted {
  opacity: 0.45;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-frame {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.16));
  border: 1px solid rgba(37, 28, 18, 0.08);
  padding: 14px;
}

#lineChart {
  width: 100%;
  height: auto;
  display: block;
}

.tooltip {
  position: absolute;
  min-width: 150px;
  pointer-events: none;
  background: rgba(17, 18, 18, 0.94);
  color: #fffef6;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.24);
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
  gap: 22px;
}

.heatmap-wrap {
  overflow-x: auto;
}

.heatmap-grid {
  display: grid;
  gap: 6px;
  min-width: max-content;
}

.heatmap-cell,
.heatmap-head,
.heatmap-admin {
  border-radius: 10px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 6px 8px;
  font-size: 0.82rem;
}

.heatmap-head {
  color: var(--muted);
  font-size: 0.74rem;
}

.heatmap-admin {
  justify-content: start;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.42);
}

.heatmap-cell {
  color: #102221;
  font-weight: 600;
}

.leaderboard {
  display: grid;
  gap: 12px;
}

.leader-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(35, 24, 16, 0.08);
}

.leader-rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.leader-main strong {
  display: block;
  font-size: 1rem;
}

.leader-total {
  font-size: 1.5rem;
  font-weight: 700;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 30px 16px;
}

@media (max-width: 1050px) {
  .hero,
  .metrics,
  .grid-two {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1400px);
    padding-top: 20px;
  }

  .panel,
  .hero-badge,
  .metric-card {
    border-radius: 22px;
  }

  .chart-frame {
    padding: 8px;
  }

  .controls-panel {
    grid-template-columns: 1fr;
  }
}
