:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;

  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: #38bdf8;

  --positive: #1d4ed8;
  --negative: #dc2626;

  --radius: 12px;
  --card-radius: 18px;
  --control-height: 42px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

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

/* ==========================================================
   ヘッダー
   ========================================================== */

.site-header {
  background:
    linear-gradient(
      135deg,
      var(--accent-dark),
      var(--accent-light)
    );
  color: white;
  padding: 42px 24px;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  opacity: 0.85;
}

.lead {
  margin: 12px 0 0;
  max-width: 800px;
  line-height: 1.7;
  opacity: 0.92;
}

/* ==========================================================
   ページ本体
   ========================================================== */

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

.card,
.control-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.06);
}

.card {
  padding: 20px;
}

/* ==========================================================
   選択・操作パネル
   ========================================================== */

.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  padding: 18px;
  margin-bottom: 20px;
}

.control-panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

select,
button,
input {
  min-height: var(--control-height);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 0 12px;
  background: white;
  color: var(--text);
  font: inherit;
}

select {
  min-width: 150px;
}

select:focus,
button:focus,
input:focus {
  outline: 3px solid color-mix(
    in srgb,
    var(--accent) 20%,
    transparent
  );
  outline-offset: 1px;
}

button {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button:active {
  transform: translateY(1px);
}

/* ==========================================================
   基準値表示
   ========================================================== */

.reference-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-height: var(--control-height);
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.reference-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.reference-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.reference-period {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ==========================================================
   表
   ========================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  background: #f8fafc;
  text-align: center;
  font-weight: 700;
}

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

tbody tr:hover {
  background: #eff6ff;
}

th.sortable {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
}

th.sortable:hover {
  background: #eef4ff;
}

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

td.year,
th.year {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

td.text,
th.text {
  text-align: left;
}

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

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

.error {
  padding: 16px;
  color: #b91c1c;
  line-height: 1.7;
}

/* ==========================================================
   小さい画面
   ========================================================== */

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

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

  .control-panel {
    gap: 12px;
    padding: 14px;
  }

  .control-panel label {
    width: 100%;
  }

  select,
  button {
    width: 100%;
  }

  .reference-value {
    width: 100%;
  }

  .card {
    padding: 12px;
  }

  th,
  td {
    padding: 9px 10px;
  }
}

/* ==========================
   Breadcrumb
   ========================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 5px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.82);
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* ==========================
   Page title
   ========================== */

.page-title-group h1 {
  margin: 0;
  padding: 0;
  border: 0;
  color: #ffffff;
  font-size: clamp(1.45rem, 2.8vw, 1.9rem);
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.page-subtitle {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.86rem;
}