:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #17233a;
  --muted: #617086;
  --border: #d7deea;
  --primary: #225ec9;
  --primary-hover: #184da9;
  --primary-soft: #eaf1ff;
  --success: #15704a;
  --success-soft: #ecf8f2;
  --danger: #a12929;
  --danger-soft: #fff1f1;
  --warning: #815b12;
  --shadow: 0 14px 40px rgb(28 48 82 / 9%);
  --radius: 14px;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 0%, rgb(64 122 226 / 8%), transparent 28rem),
    var(--bg);
  line-height: 1.65;
}

button,
input,
summary {
  font: inherit;
}

button,
.file-button,
summary {
  min-height: 44px;
}

button:focus-visible,
input:focus-visible,
.file-button:focus-within,
summary:focus-visible {
  outline: 3px solid rgb(34 94 201 / 26%);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  background: #172844;
  color: #fff;
  border-bottom: 4px solid #2f70db;
}

.header-inner {
  width: min(880px, calc(100% - 32px));
  min-height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.eyebrow {
  color: #a9c8ff;
}

h1 {
  margin: 0;
  font-size: clamp(1.22rem, 3.4vw, 1.75rem);
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.local-badge {
  flex: none;
  padding: 7px 12px;
  border: 1px solid rgb(255 255 255 / 32%);
  border-radius: 999px;
  color: #dce9ff;
  font-size: 0.75rem;
  font-weight: 700;
}

.shell {
  width: min(780px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.stepper {
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 82%);
  box-shadow: 0 6px 20px rgb(28 48 82 / 5%);
}

.stepper ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 30%;
  height: 1px;
  background: var(--border);
}

.step-number {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 0.78rem;
}

.step.is-current {
  color: var(--primary);
}

.step.is-current .step-number {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.step.is-complete {
  color: var(--success);
}

.step.is-complete .step-number {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.panel {
  padding: clamp(22px, 5vw, 38px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.section-kicker {
  color: var(--primary);
}

.panel-heading h2,
.success-banner h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3.4vw, 1.55rem);
  line-height: 1.45;
}

.panel-heading > p:last-child,
.success-banner p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.upload-card {
  position: relative;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.upload-card.is-dragging {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgb(34 94 201 / 10%);
  transform: translateY(-1px);
}

.file-type {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.excel-type {
  color: #12613e;
  background: #e5f5ec;
}

.pdf-type {
  color: #9e2e2e;
  background: #ffeded;
}

.upload-copy h3 {
  margin: 13px 0 4px;
  font-size: 1rem;
}

.upload-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.upload-copy .file-rule {
  margin-top: 8px;
  font-size: 0.73rem;
}

.file-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 18px;
  border: 1px solid #b8c5d9;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  transition: background 150ms ease, border-color 150ms ease;
}

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

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-selection {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid #a9d6bf;
  border-radius: 8px;
  background: var(--success-soft);
  font-size: 0.78rem;
}

.selected-mark {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 0.68rem;
}

.selected-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-file {
  min-height: 32px;
  padding: 3px 7px;
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}

.safety-note,
.rule-box,
.discard-note {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 0.82rem;
}

.safety-note p,
.discard-note p {
  margin: 2px 0 0;
  color: var(--muted);
}

.primary-button,
.secondary-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

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

.primary-button:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-button:disabled {
  border-color: #d4dbe6;
  background: #e7ebf1;
  color: #8793a4;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid #b9c5d7;
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.button-hint {
  margin: 8px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.74rem;
}

.message {
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 9px;
  font-size: 0.84rem;
  white-space: pre-line;
}

.error-message {
  border: 1px solid #efbcbc;
  background: var(--danger-soft);
  color: #762020;
}

.error-detail-list {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 0.76rem;
}

.source-files {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.source-files > div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.source-files span {
  color: var(--muted);
  font-size: 0.74rem;
}

.source-files strong {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

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

.summary-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.increase-card {
  border-color: #bcd0f3;
  background: #f5f8ff;
}

.summary-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 900;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.blue-dot {
  background: var(--primary);
}

.slate-dot {
  background: #5c6b81;
}

.summary-card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 0;
}

.summary-card dl > div {
  min-width: 0;
}

.summary-card dt {
  color: var(--muted);
  font-size: 0.7rem;
}

.summary-card dd {
  margin: 2px 0 0;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.rule-box {
  display: block;
  border-color: #c9d9f5;
  background: #f2f6fd;
}

.rule-box h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
}

.rule-box ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 20px;
  color: #42536b;
}

.preview-details {
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.preview-details summary {
  display: flex;
  align-items: center;
  padding: 11px 15px;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.table-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 670px;
  border-collapse: collapse;
  font-size: 0.75rem;
}

th,
td {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 800;
}

td:nth-last-child(-n + 2),
th:nth-last-child(-n + 2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.success-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
  padding: 17px;
  border: 1px solid #acd9c3;
  border-radius: 11px;
  background: var(--success-soft);
}

.success-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-weight: 900;
}

.download-list {
  display: grid;
  gap: 14px;
}

.download-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.download-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.download-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.download-link {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 900;
}

.download-link:hover {
  background: var(--primary-hover);
}

.discard-note {
  display: block;
  border-color: #e4cf9f;
  background: #fff9e9;
  color: #60450e;
}

.site-footer {
  padding: 22px 8px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(12 25 46 / 52%);
  backdrop-filter: blur(3px);
}

.busy-card {
  width: min(360px, 100%);
  padding: 26px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(0 0 0 / 22%);
  text-align: center;
}

.busy-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.spinner {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 14px;
  border: 3px solid #d9e3f4;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .header-inner,
  .shell {
    width: min(100% - 22px, 780px);
  }

  .header-inner {
    min-height: 82px;
  }

  .local-badge {
    display: none;
  }

  .shell {
    padding-top: 18px;
  }

  .stepper {
    padding: 14px 12px;
  }

  .step {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    font-size: 0.68rem;
  }

  .step:not(:last-child)::after {
    top: 15px;
    right: -23%;
    width: 46%;
  }

  .panel {
    padding: 22px 17px;
    border-radius: 14px;
  }

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

  .source-files > div {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .download-card {
    grid-template-columns: 1fr;
  }

  .download-link {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
