:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --ink: #211f1c;
  --muted: #6f6960;
  --line: #d8d0c5;
  --panel: #fffdfa;
  --red: #b7342c;
  --gold: #c39535;
  --green: #2f6f61;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px max(24px, calc((100vw - 1180px) / 2)) 24px;
  background: #201b18;
  color: #fffaf0;
  border-bottom: 4px solid var(--red);
}

.eyebrow,
.snapshot span,
.metrics span {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .eyebrow,
.topbar .snapshot span {
  color: #d3b978;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.1rem;
}

.snapshot {
  min-width: 190px;
  text-align: right;
}

.snapshot strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.topnav {
  display: flex;
  gap: 14px;
  margin-top: 18px;
}

.topnav a {
  color: #fffaf0;
  font-weight: 800;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.topnav a:hover {
  border-color: #d3b978;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.date-filter {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(33 31 28 / 6%);
}

.date-filter label {
  display: grid;
  gap: 6px;
}

.date-filter span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-filter input,
.date-filter button,
.reset-filter {
  min-height: 38px;
  border-radius: 6px;
  font: inherit;
}

.date-filter input {
  min-width: 170px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.date-filter .switch-filter {
  display: grid;
  gap: 6px;
}

.switch-filter input {
  position: absolute;
  width: 1px;
  min-width: 0;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 52px;
  height: 30px;
  background: #d8d0c5;
  border: 1px solid #c7bdb0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fffdfa;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(33 31 28 / 18%);
  transition: transform 0.18s ease;
}

.switch-filter input:checked + .switch-track {
  background: var(--red);
  border-color: var(--red);
}

.switch-filter input:checked + .switch-track::after {
  transform: translateX(22px);
}

.switch-filter input:focus-visible + .switch-track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.date-filter button,
.reset-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 750;
}

.date-filter button {
  color: #fffaf0;
  background: var(--red);
  border: 1px solid var(--red);
  cursor: pointer;
}

.reset-filter {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
}

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

.metrics div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(33 31 28 / 6%);
}

.metrics div {
  padding: 18px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.charts-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.chart-panel {
  min-height: 0;
}

.chart-body {
  position: relative;
  height: 360px;
  padding: 18px;
}

.chart-body canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  max-height: 128px;
  margin: 0 18px 18px;
  padding-top: 12px;
  overflow-y: auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  color: #666;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
}

.legend-item[aria-pressed="false"] {
  color: #999;
  text-decoration: line-through;
}

.legend-item:hover,
.legend-item:focus-visible {
  color: var(--ink);
  outline: none;
}

.legend-swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-label {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sort-button {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button::after {
  content: "-";
  display: inline-block;
  margin-left: 5px;
  color: #a29a8f;
  font-size: 0.7rem;
}

.sort-button[data-sort-direction="asc"]::after {
  content: "^";
}

.sort-button[data-sort-direction="desc"]::after {
  content: "v";
}

td:first-child {
  font-weight: 750;
}

.about-page {
  display: grid;
  gap: 18px;
  max-width: 860px;
}

.about-section {
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgb(33 31 28 / 6%);
}

.about-section p {
  margin: 12px 0 0;
  color: #3c3832;
  line-height: 1.6;
}

.about-table {
  margin-top: 14px;
}

code {
  font-size: 0.88em;
}

@media (max-width: 900px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .snapshot {
    text-align: left;
  }

  .metrics,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .date-filter {
    align-items: stretch;
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 14px;
  }

  .topbar {
    padding-inline: 18px;
  }

  .date-filter {
    display: grid;
  }

  .date-filter input,
  .date-filter button,
  .reset-filter {
    width: 100%;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 0.84rem;
  }
}
