:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #182326;
  --muted: #647278;
  --line: #d7e1e4;
  --accent: #0f766e;
  --accent-2: #d97706;
  --blue: #2563eb;
  --shadow: 0 18px 48px rgba(28, 49, 55, 0.10);
}

* {
  box-sizing: border-box;
}

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

.topbar,
main {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 32px 0 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.meta {
  color: var(--muted);
  text-align: right;
  font-size: 14px;
}

.top-link {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.controls,
.summary,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input,
select {
  padding: 0 12px;
}

button {
  padding: 0 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
}

.summary article {
  padding: 18px;
  background: #fbfdfd;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
}

.panel {
  padding: 18px;
}

.chart-panel {
  margin-bottom: 18px;
}

.monthly-panel {
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rain-legend {
  margin: 0 0 10px -10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 6px 10px;
  white-space: nowrap;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.compact-control {
  width: min(180px, 100%);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5f6;
  color: #34454b;
  font-size: 12px;
  text-transform: uppercase;
}

tbody th {
  text-align: left;
}

tbody tr:nth-child(even) {
  background: #fbfdfd;
}

tbody tr:hover {
  background: #eef7f5;
}

td span {
  color: var(--muted);
  font-size: 12px;
}

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

canvas.is-hovering-bar {
  cursor: pointer;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  min-width: 168px;
  padding: 9px 10px;
  border: 1px solid rgba(24, 35, 38, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(28, 49, 55, 0.18);
  color: var(--ink);
  font-size: 13px;
  pointer-events: none;
}

.tooltip-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tooltip-swatch {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.chart-tooltip strong,
.tooltip-value {
  display: block;
}

.tooltip-value {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-bottom: 32px;
}

.compare-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.ranking {
  display: grid;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 38px;
}

.rank-year {
  font-weight: 800;
}

.rank-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef0;
}

.rank-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.rank-value {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar {
    display: block;
  }

  .meta {
    margin-top: 10px;
    text-align: left;
  }

  .controls,
  .summary,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .summary article {
    padding: 14px 16px;
  }

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