/* ── Reset & Base ─────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Noto Sans JP", sans-serif;
  color: #1e293b;
  background: #f8fafc;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #0d9e55;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ── Header ──────────────────────────────────── */
.site-header {
  background: #0da656;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.site-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.site-header h1 a {
  color: #fff;
  text-decoration: none;
}

.site-header nav a {
  color: rgba(255, 255, 255, 0.85);
  margin-left: 1.5rem;
  font-size: 0.9rem;
}

.site-header nav a:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Breadcrumb ──────────────────────────────── */
.breadcrumb {
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: #64748b;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.breadcrumb a {
  color: #0d9e55;
}

.breadcrumb span {
  margin: 0 0.4rem;
  color: #94a3b8;
}

/* ── Main ────────────────────────────────────── */
main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Hero (top page) ─────────────────────────── */
.hero {
  text-align: center;
  padding: 3rem 1rem;
  background: linear-gradient(135deg, #0da656 0%, #088a45 100%);
  color: #fff;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.hero h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* ── Section ─────────────────────────────────── */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  margin: 2rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #0da656;
}

/* ── Region Grid (top page) ──────────────────── */
.region-block {
  margin-bottom: 1.5rem;
}

.region-block h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.5rem;
}

.pref-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pref-link {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #0d9e55;
  transition: background 0.15s, box-shadow 0.15s;
}

.pref-link:hover {
  background: #edfbf3;
  box-shadow: 0 1px 3px rgba(13, 166, 86, 0.15);
  text-decoration: none;
}

.pref-link.disabled {
  color: #94a3b8;
  background: #f1f5f9;
  border-color: #e2e8f0;
  pointer-events: none;
  cursor: default;
}

/* ── Score Card (municipality page) ──────────── */
.score-hero {
  text-align: center;
  padding: 2rem 1rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  margin-bottom: 2rem;
}

.score-hero h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.score-hero .pref-label {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.total-score {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.total-score .unit {
  font-size: 1rem;
  font-weight: 400;
  color: #64748b;
  margin-left: 0.25rem;
}

.score-hero .rank-badge {
  display: inline-block;
  margin-top: 0.5rem;
}

/* ── Score Pair (livability + disaster) ───────── */
.score-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.score-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.score-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.5rem;
}

.score-card .score-value {
  font-size: 2rem;
  font-weight: 700;
}

/* ── Rank Badge ──────────────────────────────── */
.rank-badge {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.rank-s { background: #f59e0b; }
.rank-a { background: #3b82f6; }
.rank-b { background: #10b981; }
.rank-c { background: #f97316; }
.rank-d { background: #ef4444; }

/* ── Data Table ──────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  margin-bottom: 2rem;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.data-table th {
  background: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: none;
  white-space: nowrap;
}

.data-table td {
  font-size: 0.9rem;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table .col-rank {
  text-align: center;
  width: 3rem;
}

.data-table .col-score {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

.data-table .col-num {
  text-align: right;
  white-space: nowrap;
}

.data-table .muni-name-link {
  font-weight: 600;
}

/* ── Detail Table (municipality detail) ──────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-section {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.detail-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.detail-section table {
  width: 100%;
  border-collapse: collapse;
}

.detail-section td {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f1f5f9;
}

.detail-section td:last-child {
  text-align: right;
  font-weight: 600;
}

/* ── Chart Container ─────────────────────────── */
.chart-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Map Placeholder ─────────────────────────── */
.map-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 2rem;
}

.map-container #map {
  width: 100%;
  height: 350px;
}

/* ── Footer ──────────────────────────────────── */
.site-footer {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  margin-top: auto;
}

.site-footer a {
  color: #94a3b8;
}

/* ── Utilities ───────────────────────────────── */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  main {
    padding: 1rem;
  }

  .hero {
    padding: 2rem 1rem;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  .score-pair {
    grid-template-columns: 1fr;
  }

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

  .data-table {
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }

  .total-score {
    font-size: 2.25rem;
  }

  .site-header {
    padding: 0.5rem 1rem;
  }

  .site-header nav a {
    margin-left: 1rem;
    font-size: 0.8rem;
  }
}
