:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-soft: #e0f2fe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: #0f172a;
  color: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
  line-height: 1;
  color: #38bdf8;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
}

.period-tabs {
  display: inline-flex;
  background: #1e293b;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.tab {
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: #fff;
}

.tab.active {
  background: #0284c7;
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
  gap: 16px;
  max-width: 1480px;
  margin: 16px auto;
  padding: 0 16px;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.leg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.leg i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

#map {
  width: 100%;
  height: 440px;
  background: #e2e8f0;
}

.detail-card {
  padding: 16px;
}

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

.detail-header h2 {
  margin: 0;
  font-size: 19px;
}

.st-meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.chart-range-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
}

.tab-sm {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-sm.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.kpi {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
}

.kpi-val {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.kpi-val.snow-pos {
  color: #0284c7;
}

.chart-wrap {
  position: relative;
  height: 340px;
  width: 100%;
}

.chart-note {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

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

.table-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
}

.hourly-table-wrap {
  margin-top: 10px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.rank-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
  position: sticky;
  top: 76px;
}

.count-label {
  font-size: 12px;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.filter-bar input,
.filter-bar select {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.filter-bar input {
  flex: 1;
  min-width: 0;
}

.rank-table-wrap {
  flex: 1;
  overflow-y: auto;
}

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

.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

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

.rank-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.rank-table tbody tr:hover {
  background: #f0f9ff;
}

.rank-table tbody tr.selected {
  background: #e0f2fe;
}

.st-cell-name {
  font-weight: 600;
}

.st-cell-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.pill {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.diff-pos {
  color: #0284c7;
  font-weight: 700;
}

.diff-high {
  color: #dc2626;
  font-weight: 700;
}

.diff-neg {
  color: #64748b;
}

.footer {
  text-align: center;
  padding: 20px 16px 32px;
  font-size: 12px;
  color: var(--muted);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .rank-card {
    height: 520px;
    position: static;
  }
  #map {
    height: 360px;
  }
}
