:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --wash: #f3f6f9;
  --accent: #3d62a8;
  --accent-strong: #2a4880;
  --accent-soft: #eaf1fb;
  --warning: #a06400;
  --warning-soft: #fff4d7;
  --shadow: 0 18px 45px rgba(25, 40, 61, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.65;
}

button,
input,
select {
  font: inherit;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: end;
  padding: 32px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h1 span {
  display: block;
}

.title-lock {
  white-space: nowrap;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.28rem;
  line-height: 1.35;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: #3f4d5f;
  font-size: 1.04rem;
}

.hero-note,
.summary-card,
.control-panel,
.pattern-section,
.reference-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-note {
  padding: 20px;
}

.hero-note strong,
.hero-note span {
  display: block;
}

.hero-note span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-section {
  display: grid;
  gap: 20px;
}

.control-panel {
  padding: 22px;
}

.condition-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(260px, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: end;
}

.confirm-wide {
  margin-top: 4px;
}

.print-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

fieldset {
  margin: 0;
  padding: 0 0 22px;
  border: 0;
}

fieldset + fieldset {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

fieldset:last-child {
  padding-bottom: 0;
}

legend {
  margin-bottom: 14px;
  font-weight: 800;
}

.fieldset-note {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.state-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.pattern-section {
  margin-bottom: 22px;
  padding: 24px;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: -4px 0 16px;
  color: #475467;
  font-size: 0.88rem;
  font-weight: 700;
}

.matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.matrix-legend i {
  display: inline-block;
  width: 22px;
  height: 14px;
  border: 1px solid #677485;
  border-radius: 3px;
}

.legend-before {
  background: #d8d6ce;
}

.legend-individual {
  background: #d7ecff;
}

.legend-fixed {
  background: #d9f2c7;
}

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

.pattern-card {
  display: grid;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.pattern-card:hover {
  border-color: #7a99cc;
  background: #fafcff;
}

.pattern-card.is-selected {
  border-color: var(--accent);
  background: #f0f5fc;
  box-shadow: inset 0 0 0 2px rgba(61, 98, 168, 0.16);
}

.pattern-card-top {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.pattern-radio {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid #a7b4c4;
  border-radius: 50%;
  margin-top: 2px;
}

.pattern-card.is-selected .pattern-radio {
  border-color: var(--accent);
}

.pattern-card.is-selected .pattern-radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.pattern-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.45;
}

.pattern-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid #aab6c3;
  border-radius: 6px;
  background: #fff;
}

.pattern-matrix {
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.66rem;
}

.pattern-matrix th,
.pattern-matrix td {
  border: 1px solid #4b5563;
  padding: 1px;
  height: 23px;
  text-align: center;
  vertical-align: middle;
}

.pattern-matrix thead th {
  background: #f7fafc;
  color: #263445;
  font-weight: 800;
  line-height: 1.1;
}

.pattern-matrix tbody th {
  width: 48px;
  background: #fff;
  color: #344054;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.1;
}

.pattern-matrix .hire-month-heading {
  width: 48px;
  min-width: 48px;
  white-space: normal;
}

.pattern-matrix td {
  width: 24px;
  background: #fff;
}

.pattern-matrix td.is-before-hire {
  background: #d8d6ce;
}

.pattern-matrix th.is-fixed-month,
.pattern-matrix td.is-fixed-month {
  background: #edf8e5;
}

.pattern-matrix td.has-grant {
  background: #d7ecff;
  color: #145083;
  font-weight: 900;
}

.pattern-matrix td.is-fixed-grant {
  background: #bfe8a3;
  color: #245b13;
}

.pattern-matrix td span {
  display: inline-block;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

.option-group {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.option-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #344054;
  font-weight: 800;
}

.option-group input {
  width: 18px;
  min-height: 18px;
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c9d2de;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

select:focus,
input:focus {
  outline: 3px solid rgba(61, 98, 168, 0.18);
  border-color: var(--accent);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.print-button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  background: var(--ink);
}

.primary-button:hover {
  background: #2f3a48;
}

.print-button {
  background: var(--accent);
}

.print-button:hover {
  background: var(--accent-strong);
}

.print-button:disabled {
  background: #98a2b3;
  cursor: not-allowed;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-panel {
  display: grid;
  gap: 16px;
}

.preview-heading {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px 22px;
}

.preview-heading h2 {
  margin-bottom: 0;
}

.summary-card {
  padding: 24px;
}

.summary-card h2 {
  font-size: 1.7rem;
}

.summary-card p:last-child {
  margin-bottom: 0;
}

.timeline {
  display: grid;
  gap: 12px;
}

.person-schedule {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.print-sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.recipient-line {
  font-size: 1.45rem;
  font-weight: 900;
}

.recipient-line span {
  display: inline-block;
  min-width: 220px;
  padding: 0 10px 3px;
  border-bottom: 2px solid var(--ink);
}

.company-line {
  justify-self: end;
  min-width: 210px;
  padding-bottom: 4px;
  border-bottom: 1px solid #98a2b3;
  color: #344054;
  text-align: right;
  font-weight: 800;
}

.schedule-title {
  margin-bottom: 12px;
}

.schedule-title h2 {
  font-size: 1.4rem;
}

.schedule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.schedule-meta span,
.event-kind {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #18427a;
  font-size: 0.82rem;
  font-weight: 800;
}

.event-kind.fixed {
  background: #d9f2c7;
  color: #245b13;
}

.event-kind.individual {
  background: #d7ecff;
  color: #145083;
}

.schedule-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.schedule-event {
  position: relative;
  min-height: 148px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.schedule-event::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 48px;
  height: 4px;
  border-radius: 999px;
  background: #d7ecff;
}

.schedule-event.is-fixed::before {
  background: #bfe8a3;
}

.schedule-event.is-entry::before {
  background: #d8d6ce;
}

.event-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  border: 1px solid var(--ink);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.event-date {
  display: block;
  margin-top: 20px;
  color: var(--accent-strong);
  font-size: 1.02rem;
  font-weight: 900;
  white-space: nowrap;
}

.event-days {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1.25;
}

.event-title {
  margin-top: 6px;
  color: #475467;
  font-size: 0.9rem;
}

.print-schedule-table {
  margin-top: 16px;
  min-width: 0;
  font-size: 0.92rem;
}

.print-schedule-table th,
.print-schedule-table td {
  padding: 9px 10px;
}

.after-20-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.legal-notes {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid #d6dde7;
  border-radius: 8px;
  background: #fbfcfe;
}

.legal-notes h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.legal-notes ul {
  margin: 0;
  padding-left: 1.2em;
  color: #475467;
  font-size: 0.9rem;
}

.legal-notes li + li {
  margin-top: 4px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.timeline-date {
  color: var(--accent-strong);
  font-weight: 900;
}

.timeline-item h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.grant-days {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.35;
}

.timeline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.reference-section {
  margin-top: 22px;
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf2f6;
  color: #344054;
  font-size: 0.86rem;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr.is-current {
  background: var(--accent-soft);
}

tbody tr.is-current td:first-child {
  box-shadow: inset 5px 0 0 var(--accent);
  font-weight: 900;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.reference-section {
  display: grid;
  gap: 16px;
}

.reference-section p,
footer p {
  color: var(--muted);
}

.compact table {
  min-width: 900px;
}

footer {
  padding: 20px 4px 0;
  font-size: 0.9rem;
}

.is-hidden {
  display: none;
}

@media (max-width: 900px) {
  .hero,
  .condition-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 18px;
  }

  .section-heading {
    display: block;
  }

  .schedule-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .two-columns,
  .timeline-item,
  .action-row {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .summary-card,
  .pattern-section,
  .month-section,
  .reference-section {
    padding: 18px;
  }

}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  .hero,
  .pattern-section,
  .control-panel,
  .preview-heading,
  .reference-section,
  footer {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .tool-layout,
  .result-panel {
    display: block;
  }

  .print-panel {
    display: none !important;
  }

  .person-schedule {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .schedule-strip {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .schedule-event {
    min-height: 112px;
    break-inside: avoid;
    padding: 8px;
  }

  .event-number {
    width: 28px;
    height: 28px;
    background: var(--ink) !important;
    color: #fff !important;
    border-color: var(--ink) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .event-date {
    font-size: 0.78rem;
  }

  .event-days {
    font-size: 1rem;
  }

  .event-title,
  .event-kind,
  .schedule-meta span {
    font-size: 0.68rem;
  }

  .after-20-note {
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  .legal-notes {
    padding: 8px 10px;
  }

  .legal-notes h3 {
    font-size: 0.82rem;
    margin-bottom: 4px;
  }

  .legal-notes ul {
    font-size: 0.68rem;
    line-height: 1.45;
  }

  .legal-notes li + li {
    margin-top: 2px;
  }
}
