:root {
  --page-bg: #f3f6fa;
  --panel-bg: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d8e0e8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --header-start: #1d4ed8;
  --header-end: #38bdf8;
  --table-head: #eaf2fb;
  --row-hover: #f3f8fd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
}

.site-header {
  padding: 42px 24px;
  background: linear-gradient(
    135deg,
    var(--header-start),
    var(--header-end)
  );
  color: #ffffff;
}

.header-inner {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.9;
}

.site-header h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 42px);
}

.lead {
  margin: 0;
  line-height: 1.8;
}

.container {
  width: min(1280px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.panel {
  margin-bottom: 24px;
  padding: 24px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 20px rgb(15 23 42 / 6%);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 21px;
}

.controls {
  display: grid;
  grid-template-columns:
    minmax(150px, 0.8fr)
    minmax(170px, 1fr)
    minmax(170px, 1fr)
    minmax(190px, 1.2fr)
    minmax(170px, 1fr);
  gap: 16px;
}

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

select {
  width: 100%;
  min-height: 44px;
  padding: 0 40px 0 13px;
  border: 1px solid #b9c5d2;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

select:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(37 99 235 / 15%);
}

.station-heading,
.table-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.section-label {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.station-heading h2,
.table-heading h2 {
  margin: 0;
}

.station-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, auto));
  gap: 8px 20px;
  color: var(--muted);
  font-size: 14px;
}

.meta-item {
  display: grid;
  gap: 2px;
}

.meta-label {
  color: #94a3b8;
  font-size: 12px;
}

.meta-value {
  color: var(--text);
  font-weight: 600;
}

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.summary-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.summary-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;      /* 13→12 */
  white-space: nowrap;  /* 折り返さない */
  letter-spacing: -0.02em;
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.sort-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
  font-variant-numeric: tabular-nums;
}

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

th:last-child,
td:last-child {
  border-right: none;
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: #334155;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

td:first-child {
  text-align: center;
}

tbody tr:hover {
  background: var(--row-hover);
}

.empty-row {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .site-header {
    padding: 30px 18px;
  }

  .container {
    width: min(100% - 20px, 1280px);
    margin-top: 18px;
  }

  .panel {
    padding: 18px;
  }

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

  .station-heading,
  .table-heading {
    display: block;
  }

  .station-meta {
    margin-top: 16px;
    grid-template-columns: 1fr;
  }

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

  .sort-note {
    margin-top: 10px;
  }
}

/* ==========================================================
   地点情報・概要のコンパクト表示
========================================================== */

/* 観測地点の基本情報を横一列にする */
#stationMeta {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 12px 20px;
  align-items: start;
}

#stationMeta .meta-item {
  min-width: 0;
}

#stationMeta .meta-label {
  display: block;
  margin-bottom: 3px;
  font-size: 0.78rem;
  line-height: 1.2;
}

#stationMeta .meta-value {
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
}

/* 観測地点名まわりの余白を縮小 */
#stationTitle {
  margin-top: 4px;
  margin-bottom: 8px;
  font-size: 1.45rem;
  line-height: 1.2;
}

#status {
  margin-top: 10px;
  margin-bottom: 0;
  line-height: 1.4;
}


/* 概要カードを8枚横一列にする */
#summaryCards {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

#summaryCards .summary-card {
  min-width: 0;
  padding: 16px 14px;
}

#summaryCards .summary-label {
  margin-bottom: 10px;
  font-size: 0.78rem;
  line-height: 1.25;
}

#summaryCards .summary-value {
  font-size: 1.05rem;
  line-height: 1.3;
  white-space: nowrap;
}

#summaryCards .summary-sub {
  margin-top: 5px;
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
}


/* 画面が狭い場合は無理に押し込まず横スクロール */
@media (max-width: 1200px) {
  #summaryCards {
    grid-template-columns: repeat(8, minmax(135px, 1fr));
    overflow-x: auto;
    padding-bottom: 6px;
  }

  #stationMeta {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
  }
}

@media (max-width: 700px) {
  #stationMeta {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
  }
}

/* ==========================================
   気温極値（値＋日付）
   ========================================== */

.extreme-date-cell {
  min-width: 120px;
  text-align: right;
  white-space: nowrap;
}

.extreme-date-value {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.extreme-date-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.chart-panel {
  margin-top: 24px;
}

.chart-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 16px;
}

.station-chart-container {
  position: relative;
  height: 500px;
}

#chartMetricControl {
  min-width: 220px;
}

/* ==========================================================
   地点別・年別推移グラフ
========================================================== */

.chart-panel {
  margin-top: 24px;
}

.chart-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 16px;
}

#chartMetricControl {
  min-width: 220px;
}

#chartMetricSelect {
  width: 100%;
}

.station-chart-container {
  position: relative;
  width: 100%;
  height: 500px;
  min-width: 0;
}

@media (max-width: 768px) {
  .chart-heading {
    align-items: stretch;
    flex-direction: column;
  }

  #chartMetricControl {
    min-width: 0;
  }

  .station-chart-container {
    height: 420px;
  }
}

@media (max-width: 560px) {
  .station-chart-container {
    height: 340px;
  }
}