/* heikin-kubun 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, #nobe-block > fieldset, #nobe-extra > details, #new6-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; }
.choice-row { display: flex; flex-wrap: wrap; column-gap: var(--space-3); }
details.options { margin-top: var(--space-2); }
details.options summary, .notes-more summary, details.result-block > summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
select { max-width: 100%; }
input, select { min-width: 0; }

.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%; }
.top-grid { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.top-grid select { width: 100%; }
.w4-field { grid-column: span 2; }
.w4-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; }

/* 開所日数 + 区分ごとの延べ: label | input | 「×2 = 240」 */
.d-field { display: grid; grid-template-columns: 7.5rem 8rem 1fr; gap: 0 var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.d-field label { margin: 0; }
.d-field input { text-align: right; width: 100%; }
.d-field .hint { margin: 0; font-size: 0.8rem; }
.d-field .error-text { grid-column: 1 / -1; }
.kubun-set { margin-bottom: var(--space-2); }
.kubun-row { display: grid; grid-template-columns: 7.5rem 8rem 1fr; gap: 0 var(--space-2); align-items: center; margin-bottom: var(--space-1); }
.kubun-row label { margin: 0; font-weight: 600; line-height: 1.2; }
.kubun-row input { text-align: right; width: 100%; }
.kubun-row .calc { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }
.kubun-row .error-text { grid-column: 1 / -1; }
.kubun-row.is-kei { border-top: 1px dashed var(--border); padding-top: var(--space-1); }
.label-sub { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }
.total-line { margin: var(--space-1) 0 0; font-variant-numeric: tabular-nums; color: var(--text-muted); overflow-wrap: anywhere; }

.time-grid { display: grid; gap: var(--space-1); margin-bottom: var(--space-2); }
.time-row { display: grid; grid-template-columns: 6.5rem repeat(2, minmax(0, 9rem)); gap: 0 var(--space-2); align-items: end; }
.time-row .field { margin: 0; min-width: 0; }
.time-row label { font-size: 0.8rem; }
.time-row input { width: 100%; text-align: right; }
.time-label { font-weight: 600; padding-bottom: 0.6rem; font-size: 0.9rem; }

.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); }
/* 上部の要約: 答えの3つの数字(タイル)+ 注意 + 条件の行. 768px以上では画面の上下に貼り付く(入力中も答えが見える). */
.top-summary { border: 2px solid var(--accent); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); background: var(--bg); }
.top-summary.is-bad { border-color: var(--danger); }
.top-summary #prefill-status { margin: 0 0 var(--space-1); }
.top-out p { margin: 0; }
.top-label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.top-summary.is-example .top-label { display: inline-block; background: var(--mark-bg); color: var(--mark-text); padding: 0 var(--space-2); border-radius: 4px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-1) 0; }
.tile { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.25rem; min-width: 0; }
.tile-k { flex: 1 1 100%; font-size: 0.75rem; color: var(--text-muted); line-height: 1.25; }
.tile-v { font-size: 1.6rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--accent); }
.tile-s { font-weight: 700; font-size: 0.95rem; }
.tile.is-edge .tile-v { color: var(--mark-text); background: var(--mark-bg); padding: 0 0.2rem; border-radius: 4px; }
.tile-wide { grid-column: span 2; align-self: center; }
.top-plan { font-weight: 700; }
.top-plan.is-ok { color: var(--ok); }
.top-plan.is-bad, .top-error { color: var(--danger); font-weight: 700; }
.top-alert { color: var(--danger); font-weight: 700; font-size: 0.85rem; margin-top: var(--space-1) !important; }
.top-alert::before { content: "⚠ "; }
.top-cond { color: var(--text-muted); overflow-wrap: anywhere; }
.top-link { display: inline-block; margin-top: var(--space-1); }
.intro-short { display: none; }
.result-main { font-size: 1rem; }
.cond-line { margin-top: 0; }
.group-error { margin: 0; }
.group-error:empty { display: none; }
@media (min-width: 48rem) {
  .top-summary { position: sticky; top: 0; bottom: 0; z-index: 3; box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); }
}

/* ---------- Staff rows (same as kaigo-haichi) ---------- */
.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-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; }
.avg-card { border: 2px solid var(--accent); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin: var(--space-3) 0; overflow-wrap: anywhere; }
.avg-card h3 { margin: 0 0 var(--space-1); font-size: 1rem; }
.avg-card p { margin: 0 0 var(--space-1); }
.avg-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-3); }
.avg-value { font-size: 2.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ratio-badge { font-weight: 700; font-size: 1.1rem; padding: 0.1rem 0.6rem; border-radius: 999px; border: 2px solid var(--accent); color: var(--accent); }
.avg-card.is-edge { border-color: var(--mark-text); background: var(--mark-bg); color: var(--mark-text); }
.edge-band { font-weight: 700; }
.formula { font-variant-numeric: tabular-nums; }
.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-card.is-main { grid-column: 1 / -1; border-width: 2px; border-left-width: 6px; border-color: var(--accent); }
.item-big { font-size: 1.1rem; }
.item-big .big-num { font-size: 2.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.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-ng { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.status { font-weight: 700; white-space: nowrap; }
.status-ok { color: var(--ok); }
.status-ng { color: var(--danger); }
.is-bad, .is-warn { color: var(--danger); }
.strong { font-weight: 700; }
.result-block.is-diff { border: 2px solid var(--danger); border-radius: var(--radius); padding: var(--space-2) var(--space-3); }
.quick tr.is-current th, .quick tr.is-current td, .alt-table tr.is-current th, .alt-table tr.is-current td { font-weight: 700; background: var(--accent-soft); }
.result-table th.num, .result-table td.num { text-align: right; white-space: nowrap; }
.comp-table, .kasan-table, .alt-table { font-variant-numeric: tabular-nums; }
.month-table { font-variant-numeric: tabular-nums; min-width: 34rem; }
.month-table input { width: 100%; min-width: 3.5rem; text-align: right; padding: 0.25rem; }
.month-table td, .month-table th { padding: 0.15rem 0.25rem; }
#paste { width: 100%; font-family: var(--font-mono); font-size: 0.85rem; }
.transfer-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem; background: var(--accent-soft); padding: var(--space-2) var(--space-3); border-radius: 4px; margin: 0 0 var(--space-2); }

.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: 22rem; 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 the 区分 rows + 開所日数. */
  .h1-sub, .intro { display: none; }
  .intro-short { display: block; font-size: 0.85rem; margin: 0 0 var(--space-1); }
  #kind-hint { display: none; } /* the option text says it; keeps the 区分 rows on the first screen */
  /* Phones: the summary sits right after the 区分 rows; while it is below the screen it sticks to the bottom (compact). */
  .top-summary { padding: var(--space-1) var(--space-2); position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -2px 8px rgb(0 0 0 / 0.12); }
  .top-summary .top-link { display: none; }
  .top-cond { font-size: 0.7rem; line-height: 1.3; }
  .tiles { margin: 0; }
  .tile-v { font-size: 1.35rem; }
  .tile-k { font-size: 0.7rem; }
  .verified { font-size: 0.75rem; margin-bottom: var(--space-1); }
  h1 { margin-bottom: var(--space-1); font-size: 1.35rem; }
  .breadcrumb { font-size: 0.8rem; }
  .breadcrumb li[aria-current] { display: none; }
  .form-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .view-switch { padding-top: var(--space-1); padding-bottom: var(--space-1); }
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--space-2); }
  .view-switch legend { grid-column: 1 / -1; }
  .view-switch .choice { min-height: 2.25rem; font-size: 0.85rem; line-height: 1.25; }
  .top-grid { grid-template-columns: 1fr 1fr; }
  .top-grid .field { margin-bottom: var(--space-1); }
  #mode-hint { display: none; } /* the selected option says the same; keeps the 区分 rows on the first screen */
  #dk-hint { font-size: 0.8rem; }
  .d-field, .kubun-row { grid-template-columns: 5.5rem 6.5rem 1fr; }
  .d-field { margin-bottom: var(--space-1); }
  .d-field label { font-size: 0.85rem; line-height: 1.2; }
  .d-field .hint { font-size: 0.7rem; line-height: 1.2; }
  .kubun-set legend { font-size: 0.9rem; }
  .kubun-row input, .d-field input { min-height: 2.5rem; padding-top: 0.3rem; padding-bottom: 0.3rem; }
  .kubun-row .calc { font-size: 0.8rem; }
  .label-sub { font-size: 0.7rem; }
  .time-row { grid-template-columns: 4.5rem repeat(2, minmax(0, 1fr)); }
  .item-list, .staff-wrap { grid-template-columns: minmax(0, 1fr); }
  .w4-field { grid-column: 1 / -1; }
  .avg-value { font-size: 2rem; }
  .item-big .big-num { font-size: 2rem; }
}

@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; }
  .top-summary { position: static; box-shadow: none; }
  details.result-block > summary { display: none; }
  .item-list { grid-template-columns: 1fr 1fr; }
  .item-card, .avg-card { break-inside: avoid; background: none !important; color: #000 !important; }
  .table-scroll { overflow: visible; }
  .rule-table { min-width: 0; }
  .transfer-text { background: none; border: 1px solid #000; }
}
