/* 見積作成画面。配色は style.css の変数を使う（ダーク/ライトで崩さない） */
.mt-page { padding-bottom: 20px; }
.mt-note { color: var(--muted); font-size: .82rem; margin: 8px 0 0; }
.mt-fixed { color: var(--muted); font-size: .92rem; padding: 8px 0; }
.mt-inline { display: inline-block; margin: 0 10px 0 0; font-size: .85rem; color: var(--muted); }
.mt-inline select, .mt-head-grid select, .mt-head-grid input, .mt-q, .mt-row input {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; min-height: 44px;
}
.mt-inline select { width: auto; }
.mt-head-grid label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.mt-ver-now { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.mt-create { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.mt-versions { list-style: none; margin: 0 0 10px; padding: 0; }
.mt-versions li { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.mt-versions li.is-current { border-color: var(--primary); }
.mt-versions a { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; color: var(--text); min-height: 44px; }
.mt-versions a:hover { background: var(--bg); text-decoration: none; }
.mt-ver-name { font-weight: 700; }
.mt-ver-sum { margin-left: auto; font-weight: 700; }

.mt-q { margin-bottom: 8px; }
.mt-results { max-height: 340px; overflow-y: auto; margin-bottom: 10px; }
.mt-result {
  display: block; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 48px;
}
.mt-result:hover, .mt-result:active { background: var(--bg); border-color: var(--primary); }
.mt-result-name { display: block; font-weight: 700; }
.mt-result-name small { font-weight: 400; color: var(--muted); }
.mt-result-sub { display: block; color: var(--muted); font-size: .85rem; }
.mt-badge { margin-left: 6px; }

.mt-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; background: var(--surface); }
.mt-row.is-shiki { border-color: var(--primary); }
.mt-row-top { display: flex; gap: 6px; align-items: center; }
.mt-row-top input { margin-top: 0; font-weight: 700; flex: 1 1 auto; min-width: 0; }
.mt-row-no { flex: 0 0 auto; color: var(--muted); font-size: .85rem; min-width: 1.4em; text-align: center; }
.mt-row-btns { display: flex; gap: 4px; flex: 0 0 auto; }
.mt-ico {
  width: 44px; height: 44px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; cursor: pointer;
}
.mt-ico:active { background: var(--bg); }
.mt-del { color: var(--danger); }
.mt-spec { margin-top: 6px !important; }
.mt-shiki-hint { margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--bg); color: var(--text); font-size: .85rem; }
.mt-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 8px; }
.mt-row-grid label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.mt-row-grid .mt-cost { grid-column: 1 / -1; }
.mt-row-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 2px; }
.mt-rate { color: var(--muted); font-size: .82rem; }
.mt-amount { font-size: 1.15rem; }

/* 合計の欄（§29-3）。スマホ（700px未満）では画面の下に固定し、1行「合計 ¥… ▲」に畳む。押すと内訳が開く */
.mt-total-panel { position: sticky; bottom: 0; z-index: 10; padding: 8px 12px; margin-bottom: 12px; box-shadow: 0 -2px 10px rgba(0, 0, 0, .12); }
.mt-total-bar {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 4px 6px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.mt-total-bar:active { background: var(--bg); }
.mt-bar-label { font-weight: 700; }
.mt-total-bar .mt-total-val { margin-left: auto; font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.mt-caret { flex: 0 0 auto; width: 1.4em; text-align: center; color: var(--muted); font-size: .9rem; }
.mt-total-detail { display: none; }
.mt-total-panel.is-open .mt-total-detail { display: block; max-height: 45vh; overflow-y: auto; padding: 0 6px 4px; }
.mt-total-panel .mt-msg { max-height: 5.2em; overflow-y: auto; margin-top: 4px; }
.mt-total-panel .mt-actions { margin-top: 6px; }
.mt-total-panel .mt-actions .btn { min-height: 44px; }
.mt-total-line[hidden] { display: none; }
.mt-adj-panel .mt-adj { border: 0; padding: 0; margin: 0; }
.mt-ref-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--bg); color: var(--muted); font-size: .72rem; font-weight: 700; }
.mt-ref-badge[hidden] { display: none; }
/* 409 で読み取り専用に切り替えたときの書きかけ（§29-7(e)） */
.mt-draft { border: 2px dashed var(--danger); }
.mt-draft h2 { color: var(--danger); }
.mt-draft-rows { margin: 4px 0 8px; padding-left: 1.4em; }
.mt-draft-rows li { margin-bottom: 6px; }
.mt-total-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 1rem; padding: 2px 0; }
.mt-total-val { font-weight: 700; }
.mt-grand { font-size: 1.5rem; font-weight: 800; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
.mt-grand .mt-total-val { color: var(--primary); }
.mt-margin { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.mt-msg { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: .9rem; }
.mt-msg.is-error { background: var(--danger-bg); color: var(--danger); }
.mt-actions { display: flex; gap: 10px; margin-top: 10px; }
.mt-actions .btn { flex: 1 1 0; min-height: 48px; }

@media (min-width: 700px) {
  .mt-head-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 0 16px; }
  .mt-row-grid { grid-template-columns: 1fr 1fr 1.3fr 1fr 1.3fr; }
  .mt-row-grid .mt-cost { grid-column: auto; }
  .mt-total-panel { position: static; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
  .mt-total-bar { display: none; }
  .mt-total-detail, .mt-total-panel.is-open .mt-total-detail { display: block; max-height: none; overflow: visible; padding: 0; }
  .mt-total-panel .mt-actions .btn { min-height: 48px; }
}

/* 既定の粗利率・業者比較・下代を直す・自動計算の注記（SPEC 23） */
.mt-arari { margin-bottom: 10px; font-size: .9rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mt-arari .mt-note { margin: 0; }
.mt-arari-txt { font-weight: 700; }
.mt-arari-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mt-arari-edit label { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--muted); }
.mt-arari-edit input { width: 5.5em; padding: 8px 10px; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 1rem; min-height: 44px; }

.mt-koshu { margin-bottom: 10px; }
.mt-koshu.is-multi { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: var(--bg); }
.mt-koshu-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.mt-koshu-meta { color: var(--muted); font-size: .8rem; }
.mt-vrow { display: flex; gap: 6px; align-items: stretch; margin-bottom: 6px; flex-wrap: wrap; }
.mt-vrow .mt-result { flex: 1 1 14em; margin-bottom: 0; }
.mt-vendor-line { display: block; }
.mt-edit-btn { flex: 0 0 auto; min-height: 44px; align-self: stretch; }
.mt-tedit { flex: 1 1 100%; display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px; border: 1px dashed var(--primary); border-radius: var(--radius); background: var(--surface); }
.mt-tedit label { font-size: .78rem; color: var(--muted); }
.mt-tedit input { width: 100%; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 1rem; min-height: 44px; }
.mt-tedit-btns { display: flex; gap: 8px; }

.mt-row-grid .mt-price input { font-weight: 700; }
.mt-autorow { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.mt-autonote { color: var(--muted); font-size: .78rem; }
.mt-autorow .btn[hidden] { display: none; }
/* SPEC §25 業者名（社内用）と、提出で貯まった「前回の下代」 */
.mt-row-grid .mt-gyosha { grid-column: 1 / -1; }
.mt-last { display: block; color: var(--muted); font-size: .8rem; }
.mt-last b { color: inherit; }

/* SPEC §28 通し点検の手直し */
/* 数値欄の ± ボタンと「数字ではありません」 */
.mt-numwrap { display: flex; gap: 4px; align-items: stretch; }
.mt-numwrap input { flex: 1 1 auto; min-width: 0; }
.mt-pm {
  flex: 0 0 auto; width: 44px; min-height: 44px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.mt-pm:active { background: var(--bg); }
.mt-err { display: block; color: var(--danger); font-size: .8rem; font-weight: 700; margin-top: 2px; }
.mt-err[hidden] { display: none; }
input.is-bad, .mt-row input.is-bad, .mt-adj input.is-bad { border-color: var(--danger); background: var(--danger-bg); }
/* PDF前の点検で欠けている行 */
.mt-row.is-bad { border: 2px solid var(--danger); background: var(--danger-bg); }
.mt-rowbad { margin-top: 6px; color: var(--danger); font-size: .85rem; font-weight: 700; }
.mt-rowbad[hidden] { display: none; }

/* 見出し：宛名＋敬称、備考 */
.mt-aite { display: flex; gap: 6px; }
.mt-aite input { flex: 1 1 auto; min-width: 0; }
.mt-head-grid .mt-aite select { width: auto; flex: 0 0 auto; }
.mt-bikou {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; min-height: 88px; resize: vertical;
}
.mt-add-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-add-btns .btn { min-height: 44px; }
.mt-treg { margin-top: 10px; }
.mt-treg-koshu { margin: 0 0 6px; min-height: 40px; }
.mt-autobtns { display: flex; gap: 6px; flex: 0 0 auto; }

/* お値引きと「合計を○円にする」 */
.mt-adj { border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); padding: 6px 0; margin: 4px 0; }
.mt-adj-label { display: block; font-size: .85rem; color: var(--muted); }
.mt-adj input, .mt-target input, .mt-target select {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; min-height: 44px;
}
.mt-target { margin-top: 6px; }
.mt-target summary { cursor: pointer; color: var(--primary); font-size: .9rem; padding: 8px 0; min-height: 36px; }
.mt-target-body { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mt-target-body select { flex: 1 1 8em; width: auto; }
.mt-target-body input { flex: 2 1 8em; width: auto; }
.mt-target-body .btn { min-height: 44px; margin-top: 4px; }

/* 提出済み（読み取り専用） */
.mt-lock { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: .9rem; font-weight: 700; }
.mt-ro-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: .95rem; }
.mt-ro-head dt { color: var(--muted); }
.mt-ro-head dd { margin: 0; word-break: break-all; }
.mt-ro-row { padding: 10px 12px; }
.mt-ro-top { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.mt-ro-spec { color: var(--muted); font-size: .85rem; }
.mt-ro-line { margin-top: 4px; text-align: right; }
.mt-ro-inner { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.mt-ro-bikou { white-space: pre-wrap; margin: 0; }
.mt-actions-wrap { flex-wrap: wrap; }
.mt-actions-wrap .btn { flex: 1 1 9em; }

/* SPEC §30 名義と施工・粗利の配分（社内用） */
.mt-cos { display: flex; flex-direction: column; gap: 0; }
.mt-cos .mt-fixed { padding: 4px 0; }
.mt-hb { border-left: 4px solid var(--primary); }
.hb-base { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; font-size: .95rem; }
.hb-base dt { color: var(--muted); }
.hb-base dd { margin: 0; text-align: right; }
.hb-warn { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: #fff6e0; color: #8a5a00; font-size: .88rem; font-weight: 700; }
.hb-warn[hidden] { display: none; }
.hb-stop { margin: 8px 0; padding: 10px 12px; border: 2px solid var(--danger); border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.hb-ctrl { margin: 10px 0 4px; }
.hb-range-row { display: flex; align-items: center; gap: 8px; }
.hb-range-row input[type=range] { flex: 1 1 auto; min-width: 0; height: 44px; margin: 0; accent-color: var(--primary); }
.hb-end { flex: 0 0 auto; color: var(--muted); font-size: .78rem; }
.hb-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 6px; }
.hb-fields label, .hb-form label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.hb-fields input, .hb-form input[type=date] {
  display: block; width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; min-height: 44px;
}
.hb-result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.hb-share { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--border); }
.hb-share span { font-size: .8rem; color: var(--muted); }
.hb-share b { font-size: 1.1rem; }
.hb-share-re { background: #fff1e0; border-color: #f3cf9f; }
.hb-share-sb { background: #e8f0fe; border-color: #b9cdf5; }
.hb-seikyu { padding: 10px 12px; border-radius: var(--radius); background: var(--bg); }
.hb-seikyu-dir { font-weight: 700; }
.hb-seikyu-amt { margin-top: 2px; }
.hb-seikyu-amt b { font-size: 1.1rem; }
.hb-seikyu-none { color: var(--muted); font-weight: 700; }
.hb-preview { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 6px; background: #fff6e0; color: #8a5a00; font-size: .75rem; font-weight: 700; }
.hb-create-row { margin-top: 12px; }
.hb-create-row .btn { min-height: 52px; }
.hb-create-row .btn:disabled, .mt-hb .btn:disabled { opacity: .5; cursor: not-allowed; }
.hb-form { margin-top: 12px; padding: 12px; border: 1px dashed var(--primary); border-radius: var(--radius); }
.hb-form h3 { margin-top: 0; }
.hb-mode { border: 0; padding: 0; margin: 0 0 8px; }
.hb-mode legend { font-size: .85rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.hb-radio { display: flex !important; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px; margin-bottom: 6px !important;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text) !important; font-size: 1rem !important; cursor: pointer; }
.hb-radio input { width: 22px; height: 22px; margin: 0; }
@media (max-width: 420px) {
  .hb-fields { grid-template-columns: 1fr; }
}
