:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #5b6b7a;
  --border: #dbe3ea;
  --accent: #1f6feb;
  --accent-soft: #e3eefc;
  --row-hover: #f0f5fb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #171e26;
    --text: #e4ebf2;
    --muted: #93a3b3;
    --border: #2a3542;
    --accent: #5aa2ff;
    --accent-soft: #1c2c42;
    --row-hover: #1d2631;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 22px;
}

h2 {
  margin: 0;
  font-size: 17px;
}

h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.tagline,
.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

nav {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main {
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

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

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.map {
  min-height: 520px;
  border-radius: 10px;
  border: 1px solid var(--border);
  z-index: 0;
}

@media (max-width: 900px) {
  .map {
    min-height: 340px;
  }
}

.panel,
.detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
}

.detail {
  margin-top: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  position: sticky;
  top: 0;
  background: var(--surface);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover,
.data-table tbody tr.selected {
  background: var(--row-hover);
}

.data-table .sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.data-table .narrow-only,
.narrow-only-inline {
  display: none;
}

/* phones: drop the least important columns, fold what they showed into the remaining cells, and tighten spacing */
@media (max-width: 600px) {
  main {
    padding: 12px;
  }

  .panel,
  .detail {
    padding: 12px 10px;
  }

  .wide-only {
    display: none;
  }

  .data-table .narrow-only {
    display: block;
  }

  .narrow-only-inline {
    display: inline;
  }

  .data-table th,
  .data-table td {
    padding: 6px 5px;
  }

  .data-table td:first-child {
    white-space: normal;
  }

  .chart-box {
    height: 240px;
  }
}

.sortable th[data-sort] {
  cursor: pointer;
}

.sortable th.sorted::after {
  content: " ▾";
}

.sortable th.sorted.asc::after {
  content: " ▴";
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll.tall {
  max-height: 520px;
  overflow-y: auto;
}

.snow {
  font-weight: 700;
}

.snow-0 { color: var(--muted); font-weight: 400; }
.snow-1 { color: #4a90d9; }
.snow-2 { color: #2f6fd0; }
.snow-3 { color: #7b4fd6; }
.snow-4 { color: #c2389b; }

.station-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 14px;
}

.station-card strong {
  font-size: 16px;
}

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 14px;
}

@media (max-width: 900px) {
  .charts {
    grid-template-columns: minmax(0, 1fr);
  }
}

.chart-box {
  position: relative;
  height: 280px;
  padding-bottom: 24px;
}

.spot-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
  cursor: pointer;
}

.spot-badge.level-0 { background: #868e96; }
.spot-badge.level-1 { background: #4a90d9; }
.spot-badge.level-2 { background: #2f6fd0; }
.spot-badge.level-3 { background: #7b4fd6; }
.spot-badge.level-4 { background: #c2389b; }

footer {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
