:root {
  --teal: #147b80;
  --teal-dark: #0e6267;
  --teal-pale: #e7f5f4;
  --ink: #18333f;
  --muted: #647783;
  --line: #d5dde2;
  --surface: #ffffff;
  --bg: #f3f6f8;
  --success: #178a55;
  --success-bg: #eaf8f0;
  --warning: #9b6800;
  --warning-bg: #fff8e7;
  --danger: #c74444;
  --danger-bg: #fff0f0;
  font-family: "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-header { background: #fff; border-bottom: 2px solid var(--teal); }
.header-inner { max-width: 1180px; margin: auto; min-height: 72px; display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: var(--teal); border-radius: 6px; font-weight: 800; }
h1 { margin: 0; color: var(--teal); font-size: 20px; }
.header-inner p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.version { margin-left: auto; background: var(--teal-pale); color: var(--teal); border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; }

.page-shell { width: min(1180px, calc(100% - 28px)); margin: 28px auto 70px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; margin: 0 0 28px; padding: 20px 26px; background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 8px #16313f12; border-radius: 12px; }
.steps li { display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; }
.steps li:not(:last-child)::after { content: ""; position: absolute; width: 34%; height: 2px; right: -17%; background: var(--line); }
.steps li > span { width: 32px; height: 32px; border: 2px solid #9eacb5; border-radius: 50%; display: grid; place-items: center; color: #7d8d97; font-weight: 800; background: #fff; }
.steps li.active > span { color: #fff; border-color: var(--teal); background: var(--teal); }
.steps strong, .steps small { display: block; }
.steps strong { font-size: 14px; }
.steps small { color: var(--muted); margin-top: 2px; }

.section-block { margin-top: 24px; }
.section-heading { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-icon { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 4px; color: #fff; background: var(--teal); font-weight: 800; font-size: 13px; }
.tag { color: var(--teal); background: var(--teal-pale); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 2px 8px #16313f0d; }

.file-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 24px; }
.file-card { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; text-align: center; padding: 15px; border: 2px dashed #a8b7be; border-radius: 9px; background: #fbfcfd; cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.file-card:hover, .file-card:focus-within { border-color: var(--teal); transform: translateY(-1px); }
.file-card.selected { border-style: solid; border-color: #5bc98e; background: #ecf9f1; }
.file-card input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.file-title { align-self: stretch; text-align: left; font-size: 13px; font-weight: 700; }
.file-title b { float: right; color: #d74747; background: #fff0f0; border-radius: 4px; padding: 2px 5px; font-size: 11px; }
.file-title em { float: right; color: var(--teal); background: var(--teal-pale); border-radius: 4px; padding: 2px 5px; font-style: normal; font-size: 11px; }
.file-icon { color: var(--teal); font-size: 25px; }
.file-card strong { max-width: 100%; overflow-wrap: anywhere; font-size: 13px; }
.file-card small { color: var(--muted); }
.template-card { cursor: default; border-style: solid; border-color: #b7d9d8; background: #f3fbfa; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.form-actions p { color: var(--muted); font-size: 13px; margin: 0; }
.primary-button { border: 0; border-radius: 7px; background: var(--teal); color: #fff; padding: 13px 22px; font-weight: 800; box-shadow: 0 2px 5px #0f777b2e; }
.primary-button:hover { background: var(--teal-dark); }
.primary-button:disabled { cursor: wait; opacity: .55; }

.rule-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 20px; }
.rule-grid article { min-height: 98px; display: flex; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfd; }
.rule-grid article > span { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-pale); color: var(--teal); font-weight: 900; }
.rule-grid strong { font-size: 13px; }
.rule-grid p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.notice { padding: 15px 18px; border: 1px solid #e8ba50; background: var(--warning-bg); color: #72500c; border-radius: 8px; margin-bottom: 14px; line-height: 1.6; }
.notice.success { border-color: #70c49a; background: var(--success-bg); color: #14643f; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.summary-card { display: grid; grid-template-columns: auto 1fr; align-items: center; padding: 20px; border: 1px solid; border-radius: 9px; }
.summary-card strong { grid-row: span 2; font-size: 34px; margin-right: 15px; }
.summary-card span { font-weight: 800; }
.summary-card small { color: var(--muted); }
.summary-card.success { color: var(--success); border-color: #75cda0; background: var(--success-bg); }
.summary-card.warning { color: var(--warning); border-color: #e9c15d; background: var(--warning-bg); }
.summary-card.danger { color: var(--danger); border-color: #ed9c9c; background: var(--danger-bg); }
.mini-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 14px 0 24px; }
.mini-summary div { display: flex; flex-direction: column; align-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.mini-summary strong { color: var(--teal); font-size: 22px; }
.mini-summary span { color: var(--muted); font-size: 12px; }
.subheading { margin-top: 22px; }
.subheading > span:last-child { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 930px; }
th { background: #f2f5f7; color: #536774; font-size: 12px; text-align: left; padding: 11px 9px; border-bottom: 1px solid var(--line); }
td { padding: 9px; border-bottom: 1px solid #e5eaed; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td input, td select { width: 100%; min-width: 78px; border: 1px solid #c8d3d9; border-radius: 5px; padding: 7px 8px; background: #fff; color: var(--ink); }
td input:focus, td select:focus { outline: 2px solid #80cbcf; border-color: var(--teal); }
.review-pill { display: inline-block; max-width: 270px; padding: 5px 8px; border-radius: 999px; font-size: 11px; line-height: 1.4; }
.review-pill.ok { color: var(--success); background: var(--success-bg); }
.review-pill.warn { color: #79530a; background: var(--warning-bg); }
.review-pill.error { color: var(--danger); background: var(--danger-bg); }
.row-disabled { opacity: .55; }

.output-panel { margin-top: 22px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.output-panel h3 { margin: 0 0 12px; font-size: 16px; }
.month-fields { display: flex; gap: 10px; flex-wrap: wrap; }
.month-fields label { font-size: 12px; color: var(--muted); }
.month-fields input { width: 86px; margin-left: 4px; border: 1px solid #c8d3d9; border-radius: 5px; padding: 6px; }
.confirm-check { display: block; margin-top: 12px; font-size: 13px; }

.busy-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: #092a3488; backdrop-filter: blur(2px); }
.busy-card { width: min(430px, 100%); text-align: center; background: #fff; border-radius: 12px; padding: 30px; box-shadow: 0 18px 60px #00171f55; }
.busy-card strong { display: block; font-size: 18px; margin-top: 14px; }
.busy-card p { color: var(--muted); margin-bottom: 0; }
.spinner { display: inline-block; width: 40px; height: 40px; border: 4px solid #d7ecec; border-top-color: var(--teal); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: min(480px, calc(100% - 40px)); padding: 14px 18px; color: #fff; background: #a73636; border-radius: 8px; box-shadow: 0 8px 25px #00171f40; }
footer { padding: 28px 20px; text-align: center; color: #819099; font-size: 11px; border-top: 1px solid var(--line); background: #fff; }

@media (max-width: 950px) {
  .file-panel { grid-template-columns: repeat(2, 1fr); }
  .rule-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .header-inner { min-height: 58px; padding: 8px 12px; }
  .header-inner p, .version { display: none; }
  h1 { font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; }
  .page-shell { width: min(100% - 18px, 1180px); margin-top: 14px; }
  .steps { padding: 13px 8px; margin-bottom: 18px; }
  .steps li { gap: 5px; flex-direction: column; text-align: center; }
  .steps li > span { width: 25px; height: 25px; font-size: 12px; }
  .steps strong { font-size: 11px; }
  .steps small { font-size: 9px; }
  .steps li:not(:last-child)::after { top: 12px; width: 38%; right: -19%; }
  .section-heading h2 { font-size: 16px; }
  .file-panel, .rule-grid, .summary-grid, .mini-summary { grid-template-columns: 1fr; }
  .file-panel { padding: 12px; gap: 10px; }
  .file-card { min-height: 135px; }
  .form-actions, .output-panel { flex-direction: column; align-items: stretch; }
  .primary-button { width: 100%; }
  .rule-grid { padding: 12px; }
  .rule-grid article { min-height: auto; }
  .mini-summary { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  table, thead, tbody, tr, th, td { display: block; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody { display: grid; gap: 10px; }
  tbody tr { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; box-shadow: 0 2px 6px #16313f0b; }
  td { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: center; padding: 5px 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; }
  .review-pill { max-width: none; border-radius: 6px; }
  .output-panel { padding: 16px; }
}
