:root {
  --ink: #111827;
  --muted: #5b6472;
  --line: #d7dde7;
  --soft: #f5f7fb;
  --panel: #fff;
  --accent: #1f6feb;
  --danger: #a61b1b;
  --hold: #8a5a00;
  --ok: #18794e;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.62;
}
body { margin: 0; }
a { color: #0b5bd3; text-decoration: none; }
a:hover { text-decoration: underline; }
:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.site-shell { max-width: 1120px; margin: 0 auto; padding: 0 24px; min-width: 0; }
.site-header { border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.site-header .site-shell { display: flex; justify-content: space-between; align-items: center; min-height: 64px; }
.brand { font-weight: 800; color: #111827; letter-spacing: -0.02em; }
.nav a { margin-left: 18px; color: #374151; font-weight: 650; }
.hero { padding: 54px 0 28px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.55rem); line-height: 1.12; margin: 0 0 18px; letter-spacing: -0.045em; }
.hero p { font-size: 1.1rem; max-width: 780px; color: var(--muted); margin: 0; }
.quick-check { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 24px 0; padding: 0; list-style: none; }
.quick-check li { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.guide-figure { margin: 26px 0; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); overflow: hidden; max-width: 100%; }
.guide-figure img { display: block; width: 100%; max-width: 100%; height: auto; }
.section { padding: 24px 0; border-top: 1px solid var(--line); min-width: 0; }
.section h2 { font-size: 1.65rem; margin: 0 0 14px; letter-spacing: -0.025em; }
.section h3 { font-size: 1.2rem; margin: 18px 0 10px; }
.flow-list, .check-list { padding-left: 1.25rem; }
.flow-list li, .check-list li { margin: 0.45rem 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 16px 0;
  background: #fff;
  width: 100%;
  max-width: 100%;
}
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table-wrap th, .table-wrap td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.table-wrap th { background: #f3f6fb; }

.resource-banner { margin: 18px 0 10px; border: 1px solid #b9cdfa; background: #eef4ff; border-radius: 18px; padding: 18px; display: grid; gap: 10px; }
.resource-banner strong { font-size: 1.1rem; }
.resource-banner .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; text-decoration: none; max-width: max-content; }
.note { background: #fff7ed; border: 1px solid #fed7aa; padding: 14px; border-radius: 14px; color: #6b3a00; }
.site-footer { margin-top: 42px; border-top: 1px solid var(--line); padding: 30px 0; color: var(--muted); font-size: 0.92rem; }
.form-layout { display: grid; gap: 16px; }
.form-card, .result-card { border: 1px solid var(--line); border-radius: 18px; background: #fff; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; min-width: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 760; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid #b8c0cc; border-radius: 10px; padding: 10px; font: inherit; background: #fff; }
.field textarea { min-height: 84px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.actions button, .actions a.button { min-height: 44px; border: 0; border-radius: 12px; background: #111827; color: #fff; padding: 10px 16px; font-weight: 800; cursor: pointer; text-decoration: none; }
.actions button.secondary { background: #e5e7eb; color: #111827; }
.inline-error { color: var(--danger); font-weight: 750; margin-top: 8px; }
.field-help { color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.field-error { display: block; min-height: 1.25em; color: var(--danger); font-size: 0.86rem; font-weight: 750; line-height: 1.45; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"],
.row-table input[aria-invalid="true"], .row-table select[aria-invalid="true"], .row-table textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(166, 27, 27, 0.12);
}
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.result-tile { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.result-tile b { display: block; font-size: 1.35rem; }
.status-hold { color: var(--hold); font-weight: 800; }
.status-stop { color: var(--danger); font-weight: 800; }
.usage-list { display: grid; gap: 8px; padding-left: 1.25rem; }
.print-note { font-size: 0.9rem; color: var(--muted); }
.screen-reader-only { position: absolute; left: -9999px; }
main, section, form, .form-layout, .form-card, .result-card { min-width: 0; max-width: 100%; }
img, svg { max-width: 100%; }

/* Repeated-row input area: 44px+ controls and an accessible mobile card layout. */
.table-wrap .row-table { width: 100%; min-width: 780px; table-layout: fixed; border-collapse: collapse; }
.row-table th, .row-table td { border: 1px solid var(--line); padding: 8px; vertical-align: top; min-width: 0; }
.row-table td:nth-child(4) { width: 96px; }
.row-table input,
.row-table select,
.row-table textarea,
.row-table button[data-remove-row] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid #9ca7b6;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.35;
  background: #fff;
}
.row-table button[data-remove-row] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  color: #7f1d1d;
  background: #fff7f7;
  border-color: #e8b4b4;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.row-table button[data-remove-row]:hover { background: #feecec; }

@media (max-width: 720px) {
  .site-shell { padding: 0 16px; }
  .site-header .site-shell { align-items: flex-start; flex-direction: column; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .nav a { margin: 0 14px 0 0; }
  .quick-check, .field-grid, .result-grid { grid-template-columns: 1fr; }
  .hero { padding: 34px 0 20px; }
  .resource-banner .button, .actions button, .actions a.button { width: 100%; max-width: none; }
  .guide-figure { border-radius: 14px; }

  .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; margin-left: 0; margin-right: 0; }
  .table-wrap .row-table { display: block; width: 100%; min-width: 0; table-layout: auto; border-collapse: separate; }
  .row-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .row-table tbody { display: grid; width: 100%; gap: 14px; }
  .row-table tr { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; min-width: 0; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 3px 12px rgba(17, 24, 39, 0.05); }
  .row-table td, .row-table td:nth-child(4) { display: block; width: 100%; min-width: 0; border: 0; padding: 0; }
  .row-table td[data-label]::before { content: attr(data-label); display: block; margin: 0 0 6px; color: #374151; font-size: 0.9rem; font-weight: 760; line-height: 1.35; overflow-wrap: anywhere; }
  .row-table input, .row-table select, .row-table textarea, .row-table button[data-remove-row] { width: 100%; max-width: 100%; min-width: 0; min-height: 48px; }
  .row-table button[data-remove-row] { min-width: 0; }
}

@media print {
  .site-header, .site-footer, .actions, .nav, .no-print { display: none !important; }
  body { font-size: 10.5pt; }
  .site-shell { max-width: none; padding: 0; }
  .section { break-inside: avoid; }
  .form-card, .result-card, .resource-banner { box-shadow: none; }
  .table-wrap { overflow: visible; }
  .table-wrap .row-table { display: table; width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; font-size: 8.5pt; }
  .row-table thead { position: static; width: auto; height: auto; padding: 0; margin: 0; overflow: visible; clip: auto; clip-path: none; white-space: normal; display: table-header-group; }
  .row-table tbody { display: table-row-group; }
  .row-table tr { display: table-row; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .row-table th, .row-table td, .row-table td:nth-child(4) { display: table-cell; width: auto; border: 1px solid var(--line); padding: 5px; vertical-align: top; }
  .row-table td[data-label]::before { display: none; }
  .row-table input, .row-table select, .row-table textarea { min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .row-table button[data-remove-row], .row-table th:last-child, .row-table td:last-child { display: none !important; }
  @page { size: A4; margin: 14mm 12mm; }
}
