:root {
  --bg: #f4fbf7;
  --surface: #ffffff;
  --surface-soft: #f7fcfa;
  --text: #17221e;
  --muted: #60746c;
  --line: #d7ebe1;
  --line-strong: #b8d6ca;
  --primary: #2f8068;
  --primary-dark: #17604d;
  --primary-soft: #e8f6f0;
  --blue: #3b7876;
  --blue-soft: #edf8f5;
  --amber: #a86415;
  --amber-soft: #fff2df;
  --red: #aa3f38;
  --red-soft: #fff0ef;
  --shadow: 0 12px 30px rgba(31, 84, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #f7fdf9 0%, var(--bg) 280px);
  color: var(--text);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.5;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  min-height: 64px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 255, 252, 0.96);
  backdrop-filter: blur(10px);
}

.header-main {
  display: block;
}

.header-brand {
  min-width: 220px;
}

.header-brand h1,
.page-title h2,
.section-heading h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.header-brand h1 {
  color: var(--primary-dark);
  font-size: 20px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.page-flow-visual {
  margin: 8px 0 46px;
  overflow-x: auto;
}

.flow-stage-track {
  --flow-circle: 112px;
  --flow-line: #8ac0aa;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  align-items: start;
  min-width: 920px;
  min-height: 158px;
  padding: 0 32px;
}

.flow-stage-track::before {
  content: "";
  position: absolute;
  left: 32px;
  right: 32px;
  top: calc(var(--flow-circle) / 2);
  height: 3px;
  background: var(--flow-line);
  transform: translateY(-50%);
}

.flow-stage {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--text);
  text-decoration: none;
}

.flow-stage[href] {
  cursor: pointer;
}

.flow-stage.dev-nav-disabled {
  cursor: default;
}

.flow-stage.dev-nav-disabled:not(.active) .flow-stage-number {
  filter: saturate(0.65);
  opacity: 0.86;
}

.flow-stage-number {
  display: grid;
  place-items: center;
  width: var(--flow-circle);
  height: var(--flow-circle);
  border: 3px solid var(--primary-dark);
  border-radius: 50%;
  background: #e9eeeb;
  color: #fff;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.flow-stage.done .flow-stage-number {
  background: #acd9c7;
  color: var(--primary-dark);
}

.flow-stage.active .flow-stage-number {
  background: var(--primary);
}

.flow-stage-label {
  justify-self: center;
  margin-top: 4px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
  white-space: nowrap;
}

.page-title,
.section-heading,
.panel-heading,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-title {
  margin-bottom: 18px;
}

.page-title h2,
.section-heading h2 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.25;
}

.action-row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
.small-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.button {
  min-height: 40px;
  padding: 0 16px;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.button.secondary,
.small-button,
.icon-button {
  border-color: var(--line-strong);
  color: var(--primary-dark);
}

.button.secondary:hover,
.small-button:hover,
.icon-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.button.disabled,
.button[aria-disabled="true"] {
  border-color: var(--line);
  background: #edf4f0;
  color: var(--muted);
  pointer-events: none;
  opacity: 0.82;
}

.nav-warning {
  width: 100%;
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.small-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 20px;
}

.panel,
.metric-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel + .panel,
.panel + .details-panel,
.details-panel + .panel {
  margin-top: 18px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel h3 {
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.info {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.future {
  background: #edf4f0;
  color: #64746d;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(47, 128, 104, 0.14);
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

textarea {
  min-height: 170px;
  padding: 10px;
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.span-all {
  grid-column: 1 / -1;
}

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

.table-wrap.compact {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: right;
}

.data-table th {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table input,
.data-table select {
  min-height: 34px;
  padding: 0 8px;
  font-size: 13px;
}

.small-table {
  min-width: 520px;
}

.details-panel {
  overflow: hidden;
}

.details-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.details-body {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .page-title {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row {
    justify-content: flex-start;
  }

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

@media (max-width: 720px) {
  .page {
    width: min(100vw - 20px, 1500px);
    padding-top: 14px;
  }

  .site-header {
    padding: 12px 16px 14px;
  }

  .form-grid.three,
  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-all {
    grid-column: auto;
  }
}
