/* kaigo-haichi tool styles (loaded after base.css). No inline styles (CSP). Mobile first. */

[hidden] { display: none !important; }
.h1-sub { display: block; font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-top: var(--space-1); }
#tool-form > fieldset, #tool-form > details, #tool-form > .field, #facility-block > .field, #count-block, #tsusho-block > fieldset { margin-bottom: var(--space-3); }
.verified { font-size: 0.875rem; color: var(--text-muted); margin: 0 0 var(--space-2); }
.verified .badge { border-color: var(--ok); color: var(--ok); }
.quick-result { font-weight: 700; color: var(--accent); margin: 0; min-height: 1.5em; overflow-wrap: anywhere; }
.save-line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.btn-link { font: inherit; background: none; border: 0; padding: 0.5rem 0; min-height: 2.75rem; color: var(--accent); text-decoration: underline; cursor: pointer; }
.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; }
.view-switch .choice { font-weight: 600 !important; }
details.options { margin-top: var(--space-2); }
details.options summary, .notes-more summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
select { max-width: 100%; }
input, select { min-width: 0; }

/* Two (or more) small fields per row on phones. */
.pair-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.25rem, 1fr)); gap: 0 var(--space-2); align-items: end; }
.pair-grid .field { margin-bottom: var(--space-2); min-width: 0; }
.pair-grid input[type="text"] { max-width: 10rem; text-align: right; width: 100%; }
#ndays { text-align: left; max-width: 16rem; }
/* 利用者数の出し方: 選んだ値が切れないよう1行ぶち抜き(高-1). */
#count-block .count-mode-field { grid-column: 1 / -1; }
#count-block select { width: 100%; max-width: 24rem; }
#fy-field select { width: 100%; }
.print-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 var(--space-2); margin: var(--space-2) 0; }
fieldset.t-unit { margin-bottom: var(--space-2); }

.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); }
.top-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.top-summary .quick-result { flex: 1 1 14rem; min-width: 0; }
.top-summary .quick-result::before { content: "いまの結果: "; }
.top-summary #prefill-status { flex: 1 1 100%; margin: 0; }
.top-summary.is-example .quick-result::before { content: "計算例: "; }
/* The summary text starts with its conditions "(特養・入所者 96.7人): …" → 「計算例(特養・入所者 96.7人): …」. */
.top-summary.has-cond .quick-result::before { content: "いまの結果"; }
.top-summary.has-cond.is-example .quick-result::before { content: "計算例"; }
.result-main .cond { font-weight: 600; }
.top-summary.is-example .quick-result::after { content: "(下の数を自分の施設の数に書き換えてください)"; display: block; font-size: 0.85rem; font-weight: 400; color: var(--text-muted); }

/* ---------- Staff rows ---------- */
.staff-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.staff-card { margin: 0; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.staff-card legend { font-weight: 700; padding: 0 var(--space-1); }
.staff-card.is-unused { border-style: dashed; }
.staff-card.is-unused legend::after { content: "(この施設の判定には使いません)"; font-weight: 400; font-size: 0.8rem; color: var(--text-muted); }
.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 .staff-role { grid-column: 1 / -1; }
.staff-grid label { font-size: 0.85rem; }
.staff-grid input { width: 100%; text-align: right; }
.staff-grid select { width: 100%; }
.staff-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.staff-sub { margin: 0; color: var(--text-muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.staff-remove { min-height: 2.25rem; padding: 0.25rem 0.5rem; flex: none; }
.staff-checks { display: flex; flex-wrap: wrap; column-gap: var(--space-3); }
.staff-checks .choice { min-height: 2.25rem; font-size: 0.9rem; }

/* ---------- Results ---------- */
.result-main.is-bad { color: var(--danger); }
.result-block { margin: var(--space-3) 0; }
.result-block h3 { margin-bottom: var(--space-1); }
.key-list { padding-left: 1.2em; }
.key-list li { margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: var(--space-2); }
.item-card { border: 1px solid var(--border); border-left-width: 6px; border-radius: var(--radius); padding: var(--space-2) var(--space-3); min-width: 0; overflow-wrap: anywhere; }
.item-card p { margin: 0 0 var(--space-1); }
.item-card .item-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); font-weight: 700; }
.item-need strong { font-size: 1.1rem; }
.item-sub { font-size: 0.85rem; color: var(--text-muted); margin-left: 0.25rem; }
.item-placed { font-weight: 700; }
.item-placed.is-bad { color: var(--danger); }
.item-card.is-ok { border-left-color: var(--ok); }
.item-card.is-within, .item-card.is-over, .item-card.is-ng { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.item-card.is-check { border-left-color: var(--accent); }
.item-card.is-combined { border-left-color: var(--accent); }
.night-decimal { font-weight: 600; }
.status { font-weight: 700; white-space: nowrap; }
.status-ok { color: var(--ok); }
.status-within, .status-over, .status-ng { color: var(--danger); }
.status-check { color: var(--accent); }
.is-bad, .is-warn { color: var(--danger); }
.strong { font-weight: 700; }
.plan-line { font-weight: 700; }
.plan-line.is-short { color: var(--danger); }
.plan-line.is-ok { color: var(--ok); }

.result-notes { margin-top: var(--space-3); }
.result-notes ul { padding-left: 1.2em; }
.result-notes li { margin-bottom: var(--space-1); }
.note-info, .note-warn {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: var(--space-2) var(--space-3); border-radius: 4px; font-size: 0.9rem;
}
.note-warn { border-left-color: var(--danger); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.result-table caption { text-align: left; font-weight: 700; padding: var(--space-2) 0; }
.rule-table { min-width: 36rem; margin-bottom: var(--space-3); }
.sources li { margin-bottom: var(--space-1); overflow-wrap: anywhere; }

@media (max-width: 30rem) {
  /* First screen on phones: the mode switch, 施設の種類 and 利用者数. */
  .h1-sub { display: none; } /* 施設名は title・description・本文にある。結果の要約を最初の画面に入れる */
  .verified { font-size: 0.75rem; margin-bottom: var(--space-1); }
  .intro { display: none; } /* the same points are in 使い方 below; keeps 施設の種類・利用者数 on the first screen */
  h1 { margin-bottom: var(--space-1); }
  .breadcrumb { font-size: 0.8rem; }
  .view-switch { padding-top: var(--space-1); padding-bottom: var(--space-1); }
  .form-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .view-switch .choice { min-height: 2.25rem; font-size: 0.95rem; }
  .item-list, .staff-wrap { grid-template-columns: minmax(0, 1fr); }
  #type-note, #count-hint { font-size: 0.8rem; }
  .breadcrumb li[aria-current] { display: none; } /* h1 と同じ。結果の要約を最初の画面に入れる */
  .staff-card { padding: var(--space-1) var(--space-2); }
  .staff-sub { font-size: 0.8rem; }
  .staff-grid label { font-size: 0.8rem; }
  .staff-checks .choice { min-height: 2rem; }
  #facility-block > .field, #count-block { margin-bottom: var(--space-2); }
}

@media print {
  .no-print { display: none !important; }
  .print-header { margin-bottom: 6pt; }
  .print-title { font-size: 14pt; font-weight: 700; margin: 0 0 4pt; }
  .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; }
  .notes-more summary { display: none; }
  .item-list { grid-template-columns: 1fr 1fr; }
  .item-card { break-inside: avoid; background: none !important; }
  .table-scroll { overflow: visible; }
  .rule-table { min-width: 0; }
  .print-staff { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .print-staff th, .print-staff td { border: 1px solid #000; padding: 1pt 3pt; text-align: left; }
}
