/* houmon-saseki tool styles (loaded after base.css). No inline styles (CSP). Mobile first:
   モード・基準・利用者数の入れ方・3か月の人数・「いまの結果」 fit the first 375×812 screen. */

[hidden] { display: none !important; }
h1 { font-size: 1.1rem; line-height: 1.35; margin-bottom: var(--space-1); }
.verified { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 var(--space-2); }
.verified .badge { border-color: var(--ok); color: var(--ok); }
.verified-text { display: none; }
.std-line { font-size: 0.78rem; line-height: 1.45; margin: 0 0 var(--space-2); }
.breadcrumb { font-size: 0.8rem; }
#tool-form fieldset { min-width: 0; }
#tool-form > fieldset, #tool-form > details, #tool-form > .field, #tool-form > .choice { margin-bottom: var(--space-2); }
.legend-sub { display: inline; font-size: 0.72rem; font-weight: 400; color: var(--text-muted); }
.choice { display: flex; align-items: center; gap: var(--space-2); font-weight: 400 !important; min-height: 2.75rem; }
.choice input { width: 1.2rem; height: 1.2rem; flex: none; }
.btn-link { font: inherit; background: none; border: 0; padding: 0.5rem 0; min-height: 2.75rem; color: var(--accent); text-decoration: underline; cursor: pointer; }
.btn-small { min-height: 2.5rem; padding: 0.25rem 0.75rem; font-size: 0.9rem; }
.save-line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
select { max-width: 100%; }
input, select { min-width: 0; }

/* モード・基準: 2択のセグメント */
.seg-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 2px solid var(--accent); border-radius: var(--radius); padding: 0; overflow: hidden; }
#tool-form > .seg-switch { margin-bottom: var(--space-1); }
.seg { position: relative; display: block; margin: 0; cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--accent); }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 2.6rem; padding: 0.2rem 0.25rem; font-weight: 700; font-size: 0.95rem; line-height: 1.2; color: var(--accent); text-align: center; }
.seg-small .seg span { min-height: 2.4rem; font-size: 0.85rem; }
.seg input:checked + span { background: var(--accent); color: var(--bg); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -5px; }

.count-mode { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); border: 0; padding: 0; }
.inline-choice { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.5rem; font-size: 0.85rem; font-weight: 400 !important; }
.inline-choice input { width: 1.1rem; height: 1.1rem; margin: 0; }

/* 3か月の人数: 行 = 月、列 = 要介護 / 要支援者等 / 通院等のみ */
.month-set { border: 0; padding: 0; margin: 0; }
.month-set legend { font-weight: 700; font-size: 0.85rem; padding: 0; }
.month-grid { display: grid; grid-template-columns: 3.6rem repeat(3, minmax(0, 1fr)); gap: 0.2rem var(--space-2); align-items: center; }
.m-head { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); line-height: 1.2; }
.m-label { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.month-grid .field { margin: 0; min-width: 0; }
.month-grid input { width: 100%; text-align: right; min-height: 2.5rem; }
.hint-details summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); min-height: 2.25rem; display: flex; align-items: center; }
.hint-details .hint { padding-left: 1.2em; margin: 0; }
.est-field input { max-width: 10rem; text-align: right; }
.month-field label { font-size: 0.85rem; }
.month-field input { max-width: 12rem; }
.eff-choice { font-size: 0.9rem; line-height: 1.4; }

.block { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); }
.block legend { font-weight: 700; padding: 0 var(--space-1); }
.pair-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0 var(--space-2); align-items: end; }
.pair-grid .field { margin-bottom: var(--space-2); min-width: 0; }
.pair-grid input, .pair-grid select { width: 100%; max-width: 14rem; }

/* 職員の行 */
.staff-wrap { display: grid; gap: var(--space-2); }
.staff-card { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-1) var(--space-2) var(--space-2); margin: 0; }
.staff-card legend { font-weight: 700; font-size: 0.9rem; padding: 0 var(--space-1); }
.staff-remove { min-height: 2.5rem; font-size: 0.85rem; margin-left: auto; }
.staff-grid .field-wide { grid-column: 1 / -1; }
.staff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-2); }
.staff-grid .field { margin-bottom: var(--space-1); min-width: 0; }
.staff-grid label { font-size: 0.78rem; line-height: 1.3; }
.staff-grid input, .staff-grid select { width: 100%; }
.staff-checks { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); }
.staff-checks .choice { min-height: 2.5rem; font-size: 0.85rem; }
#staffTable-error:empty { display: none; }

details.options summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }

/* いまの結果(不足・エラーのときは枠と文字を警告の色に) */
.top-summary { border: 2px solid var(--accent); border-radius: var(--radius); padding: var(--space-1) var(--space-2); margin: var(--space-2) 0; background: var(--bg); }
.top-summary.is-bad { border-color: var(--danger); }
.top-summary p { margin: 0; }
.top-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
.quick-result { font-weight: 700; color: var(--accent); min-height: 1.5em; font-size: 0.95rem; line-height: 1.45; }
.top-summary.is-bad .quick-result, .top-summary.is-bad .quick-result a { color: var(--danger); }
.top-cond { color: var(--text-muted); font-size: 0.75rem; line-height: 1.4; }
.top-cond:empty { display: none; }
.example-tag { background: var(--mark-bg); color: var(--mark-text); padding: 0 0.25rem; border-radius: 4px; }
#prefill-status { margin-bottom: var(--space-1); }
@media (min-width: 48rem) {
  h1 { font-size: 1.5rem; }
  .verified-text { display: inline; }
  .top-summary { position: sticky; top: 0; z-index: 3; box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); }
  .month-grid { grid-template-columns: 5rem repeat(3, minmax(0, 9rem)); }
  .staff-grid { grid-template-columns: repeat(4, minmax(0, 12rem)); }
  .staff-grid .field-wide { grid-column: auto; }
  .rule-tables { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
}

/* ---------- Results ---------- */
.results-heading { margin-top: var(--space-4); }
.summary-line { font-size: 0.9rem; color: var(--text-muted); }
/* 表の中では数を途中で折らない(base.css の body{overflow-wrap:anywhere} を表だけ戻す)。
   数・見出しは1行、文の欄だけ語の切れ目で折る。 */
#results .tool-table { overflow-wrap: normal; word-break: keep-all; }
#results .tool-table th, #results .tool-table td.num { white-space: nowrap; }
#results .tool-table thead th { white-space: normal; word-break: normal; vertical-align: bottom; }
#results .tool-table .wrap { white-space: normal; overflow-wrap: break-word; word-break: normal; }
#results .tool-table th, #results .tool-table td { padding-left: 0.35rem; padding-right: 0.35rem; }
.result-table td.num, .result-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.users-table th, .users-table td { padding-left: 0.35rem; padding-right: 0.35rem; font-size: 0.85rem; }
.staff-table th, .staff-table td { font-size: 0.85rem; padding-left: 0.35rem; padding-right: 0.35rem; }
.result-main { font-size: 1rem; }
.result-main.is-bad { color: var(--danger); }
.example-label { display: inline-block; font-size: 0.875rem; font-weight: 600; background: var(--mark-bg); color: var(--mark-text); padding: 0 var(--space-2); border-radius: 4px; margin-bottom: var(--space-2); }
.result-block { margin: var(--space-3) 0; }
.result-block h3, .card-block h3 { margin-bottom: var(--space-1); }
.card-block { border: 2px solid var(--accent); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: var(--space-3) 0; }
.card-block.card-bad { border-color: var(--danger); }
.card-block p { margin: 0 0 var(--space-1); }
.card-note { margin: var(--space-3) 0; font-weight: 600; }
.big-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); }
.big { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.formula { font-variant-numeric: tabular-nums; }
.cite { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.check-list { list-style: none; padding: 0; margin: var(--space-1) 0; }
.shu-list { padding-left: 1.2em; margin: 0 0 var(--space-1); }
.is-ok { color: var(--ok); font-weight: 700; }
.is-bad { color: var(--danger); font-weight: 700; }
.cell-sub { display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 400; }
.note-list { padding-left: 1.2em; }
.note-list li { margin-bottom: var(--space-1); }
.note-warn { color: var(--danger); }
.note-caution { color: var(--mark-text); background: var(--mark-bg); padding: 0 0.25rem; border-radius: 4px; }
.notes-more summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.error-list ul { padding-left: 1.2em; }
.rule-table th[scope="row"] { font-weight: 600; white-space: nowrap; }
.rule-table td { text-align: right; }
.rule-table caption { text-align: left; font-weight: 700; }
/* 日本語の文を文節で折る(「1.4以上」「第5条第2項」を途中で折らない。対応しないブラウザでは通常の折り返し) */
.card-block, .formula, .quick-result, .top-cond, .result-main, .summary-line, .note-list li, .shu-list li { overflow-wrap: break-word; word-break: auto-phrase; }

.print-header { margin-bottom: var(--space-2); }
.print-title { font-weight: 700; font-size: 1.1rem; margin: 0 0 var(--space-1); }
@media print {
  .results { break-inside: auto; }
  .card-block, .result-table, .print-header { break-inside: avoid; }
  .results-heading { display: none; }
  .print-meta { display: grid; grid-template-columns: repeat(3, max-content 1fr); gap: 2pt 6pt; margin: 0; font-size: 10pt; }
  .print-meta dt { font-weight: 700; }
  .print-meta dd { margin: 0; border-bottom: 1px solid #000; min-width: 6em; }
  .print-meta dd.sign { min-height: 2.2em; }
}
