/* css/app.css */
/* ボーイ見積〜る - 画面用スタイル。配色は元の Excel 見積入力画面に合わせている */

:root {
  --brand: #2f7d32;
  --brand-dark: #1b5e20;
  --brand-soft: #eef6e8;
  --band: #8fb04c;          /* Excel の緑の帯 */
  --sales: #f9ad3c;         /* 提出金額 (オレンジ) */
  --sales-soft: #fff6e8;
  --cost: #1e95ad;          /* 仕入金額 (青緑) */
  --cost-soft: #e8f5f8;
  --ink: #1f2a1f;
  --muted: #6b766b;
  --line: #cfd8cf;
  --line-soft: #e6ebe6;
  --bg: #f4f6f2;
  --card: #fff;
  --ok: #2e7d32;
  --ng: #c62828;
  --warn: #c77700;
  --sample: #7b5ea7;
  --radius: 6px;
  font-size: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}
a { color: var(--brand-dark); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[readonly] { background: #f3f3f3; color: var(--muted); }
textarea { width: 100%; resize: vertical; }

/* ---------- ヘッダー ---------- */
.app-head {
  display: flex; align-items: center; gap: 24px; padding: 6px 20px;
  background: #fff; border-bottom: 3px solid var(--band); position: sticky; top: 0; z-index: 20;
}
.brand img { height: 46px; display: block; }
.nav { display: flex; gap: 4px; }
.nav a { white-space: nowrap;
  padding: 8px 16px; border-radius: 20px; text-decoration: none; color: var(--ink); font-weight: 600;
}
.nav a:hover { background: var(--brand-soft); }
.nav a.on { background: var(--brand); color: #fff; }
.proto-badge {
  margin-left: auto; font-size: 12px; padding: 3px 10px; border-radius: 10px;
  background: #fff3cd; color: #7a5a00; border: 1px solid #f0d27a;
}

main { padding: 16px 20px 60px; max-width: 1680px; margin: 0 auto; }

/* ---------- 共通部品 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; color: var(--ink);
  font-weight: 600; white-space: nowrap; box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.btn:hover { background: #f6f8f5; border-color: #b9c4b9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--ng); border-color: var(--ng); color: #fff; }
.btn.danger-ghost { color: var(--ng); }
.btn.danger-ghost:hover { background: #fdecec; border-color: #f2b8b8; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.icon-btn { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.band {
  margin: 0; padding: 6px 12px; background: var(--band); color: #fff; font-size: 15px; letter-spacing: .3em;
  text-align: center; text-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.band-sub { letter-spacing: .05em; text-align: left; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.band-sub .btn { margin-left: auto; letter-spacing: 0; text-shadow: none; }
.band small { font-weight: 400; opacity: .9; letter-spacing: 0; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.r { text-align: right; }
.warn { color: var(--warn) !important; font-weight: 700; }
.ng-text { color: var(--ng); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0 0 10px; }
.empty-page { padding: 60px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 8px; font-weight: 600; vertical-align: middle; }
.badge-sample { background: #efe8f7; color: var(--sample); border: 1px solid #d6c8ea; }
.badge-order { background: #e6f2fb; color: #1d5f8a; border: 1px solid #b9d7ec; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.state { font-size: 12px; padding: 2px 10px; border-radius: 10px; background: #eef0ee; color: var(--muted); }
.state-dirty { background: #fff3e0; color: var(--warn); }
.state-ok { background: #e8f5e9; color: var(--ok); }
.est-no { color: var(--muted); }
.est-no b { color: var(--ink); font-size: 16px; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.search { flex: 1; min-width: 260px; padding: 8px 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 12px; cursor: pointer; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 見積入力 ---------- */
.est-top { display: grid; grid-template-columns: minmax(360px, 1.15fr) minmax(300px, .9fr) minmax(320px, 1fr); gap: 12px; align-items: stretch; }
.info-grid { display: grid; grid-template-columns: 92px 1fr; gap: 5px 8px; padding: 10px 12px; align-items: center; }
.info-grid label { font-size: 12px; color: var(--muted); text-align: right; }
.with-unit { display: flex; align-items: center; gap: 6px; }
.with-unit input { width: 90px; }

.summary { display: flex; flex-direction: column; }
.sum-total {
  display: flex; align-items: baseline; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.sum-total span { font-size: 16px; letter-spacing: .3em; }
.sum-total b { font-size: 30px; margin-left: auto; font-variant-numeric: tabular-nums; }
.sum-total small { color: var(--muted); }
.sum-detail { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; padding: 10px 16px; font-variant-numeric: tabular-nums; }
.sum-detail dt { color: var(--muted); font-size: 13px; }
.sum-detail dd { margin: 0; text-align: right; font-weight: 600; }
.func { margin: auto 12px 12px; border: 2px solid var(--band); border-radius: var(--radius); background: #f6faef; position: relative; padding: 18px 10px 10px; }
.func-title {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--band); color: #fff;
  padding: 2px 16px; border-radius: 4px; font-size: 13px; font-weight: 700; border: 2px solid #5f7d2a;
}
.func-row { display: flex; align-items: flex-start; gap: 8px; }
.func-row + .func-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #c9d9a8; }
.func-label { flex: 0 0 56px; font-size: 12px; font-weight: 700; color: #4a6b1f; padding-top: 8px; }
.func-slip .func-label { color: #8a1f1f; }
.func-btns { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.func-kind { grid-column: 1 / -1; justify-self: start; }
.func-kind .seg button { padding: 5px 16px; font-size: 13px; font-weight: 600; border: 0; border-right: 1px solid var(--line); background: #fff; cursor: pointer; }
.func-kind .seg button:last-child { border-right: 0; }
.func-kind .seg button.on { background: var(--brand); color: #fff; }
.func-btns .btn { justify-content: center; }

.similar { display: flex; flex-direction: column; min-height: 0; }
.sim-list { padding: 8px; overflow: auto; max-height: 330px; display: flex; flex-direction: column; gap: 6px; }
.sim-list-modal { max-height: 60vh; padding: 8px 0 0; }
.sim-list .muted { padding: 8px; line-height: 1.7; font-size: 13px; }
.sim-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; background: #fff; }
.sim-card:hover { border-color: var(--brand); background: #fbfdf9; }
.sim-top { display: flex; align-items: center; gap: 6px; }
.sim-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sim-foot small { color: var(--muted); margin-left: 6px; }
.sim-foot .btn { margin-left: 4px; }
.sim-view .table-scroll { overflow-x: auto; }
.sim-view table { width: 100%; display: table !important; } /* スマホ用の横スクロール (display:block) は外側の .table-scroll で行う */
.sim-view h4 { margin: 14px 0 6px; font-size: 13px; color: var(--brand); }
.sim-view-head { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.sim-view-note { margin: 0; white-space: normal; font-size: 13px; }
.sim-view tfoot th { text-align: right; }
.score { background: var(--brand); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 8px; font-weight: 700; }

.band-wide {
  margin: 14px 0 8px; background: var(--band); color: #fff; text-align: center; padding: 6px; font-size: 18px;
  letter-spacing: .5em; border-radius: var(--radius); text-shadow: 0 1px 0 rgba(0,0,0,.15);
}

.est-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.t-head { padding: 6px 12px; color: #fff; font-weight: 700; font-size: 15px; border-radius: var(--radius) var(--radius) 0 0; text-align: center; }
.t-head small { font-weight: 400; font-size: 12px; opacity: .92; margin-left: 8px; }
.t-head-sales { background: var(--sales); color: #3d2a00; }
.t-head-cost { background: var(--cost); }

table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; font-variant-numeric: tabular-nums; }
.grid th { font-size: 12px; font-weight: 700; padding: 4px; border: 1px solid var(--line); }
.t-sales .grid thead th { background: var(--sales-soft); }
.t-cost .grid thead th { background: var(--cost-soft); }
.grid td { border: 1px solid var(--line-soft); padding: 0; height: 30px; }
.grid td input { width: 100%; border: 0; border-radius: 0; padding: 5px 6px; background: transparent; height: 30px; }
.grid td input[type=number], .grid td input[data-num] { text-align: right; }
.grid td input:focus { background: #fffde7; outline: 2px solid var(--brand); }
.grid td input.manual { color: var(--warn); font-weight: 700; }
/* 仕入金額は列が多い (型式あり) ので、少し詰めて数字や型式が切れないように */
.t-cost .grid td input { padding: 5px 3px; font-size: 13px; }
.t-cost .grid td.amt { padding: 0 4px; font-size: 13px; }
.grid td.no { text-align: center; font-size: 12px; color: var(--muted); }
.grid td.amt { text-align: right; padding: 0 8px; font-weight: 600; background: #fafbf9; }
.grid td.ops { white-space: nowrap; text-align: center; padding: 0 2px; overflow: hidden; }
.grid td.ops .mini { margin: 0 1px; }
.grid tfoot td { border: 1px solid var(--line); padding: 5px 8px; height: auto; font-weight: 700; }
.grid tfoot .foot-label { text-align: right; letter-spacing: .1em; }
.t-sales tfoot .foot-label { background: var(--sales); color: #3d2a00; }
.t-cost tfoot .foot-label { background: var(--cost); color: #fff; }
.profit-row td { background: #f6faef; }
.name-cell { position: relative; }
.name-cell input { padding-right: 18px !important; }
.linked-dot { position: absolute; right: 5px; top: 8px; color: var(--brand); font-size: 9px; }
tr.linked td { background: #f7fbfc; }
.link-tag { display: inline-block; margin-left: 2px; font-size: 10px; color: var(--cost); font-weight: 700; }

.mini {
  border: 1px solid var(--line); background: #fff; border-radius: 3px; padding: 1px 4px; font-size: 11px; cursor: pointer;
  color: var(--muted); min-width: 20px;
}
.mini:hover { border-color: var(--brand); color: var(--brand); }
.mini.on { background: var(--sales); border-color: var(--sales); color: #3d2a00; font-weight: 700; }
.mini.del:hover { border-color: var(--ng); color: var(--ng); }

/* 掛け率項目 */
#rate-body tr:first-child td { border-top: 2px solid var(--sales); }
.rate-row td { background: var(--sales-soft); }
.rate-row .name-cell input { font-weight: 600; }
.rate-cell { text-align: right; white-space: nowrap; padding-right: 6px !important; }
.rate-cell input { width: 64px !important; display: inline-block; text-align: right; background: #fff !important; border: 1px solid var(--line) !important; border-radius: 3px !important; height: 24px !important; padding: 2px 4px !important; }
.rate-cell span { margin-left: 3px; font-size: 12px; color: var(--muted); }
.rate-price input { text-align: right; color: var(--muted); }
.rate-row.fixed .rate-price input { color: var(--ink); font-weight: 700; }
.rate-fixed { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 8px; background: #fff3e0; color: #9a5b00; margin-right: 4px; vertical-align: middle; }
.rate-cell .mini { vertical-align: middle; }
.rate-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 4px 0; }
.rate-bar-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.rate-chip { border: 1px dashed #d99a2b; background: #fff; color: #7a4f00; border-radius: 16px; padding: 4px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.rate-chip:hover { background: var(--sales-soft); }
.rate-chip.on { background: var(--sales); border: 1px solid var(--sales); color: #3d2a00; }
.rate-setting { margin-left: auto; font-size: 12px; }

/* 出精値引き */
.disc-row td { background: #fafafa; border-top: 2px solid var(--line); }
.disc-row.on td { background: #fdeeee; }
.disc-row .name-cell input { font-weight: 600; }
.disc-cell { text-align: right; white-space: nowrap; padding: 0 6px !important; }
.disc-cell input { width: 84px !important; display: inline-block; text-align: right; background: #fff !important; border: 1px solid var(--line) !important; border-radius: 3px !important; height: 24px !important; padding: 2px 6px !important; }
.disc-cell span { margin: 0 6px 0 3px; font-size: 12px; color: var(--muted); }
.disc-cell .mini { margin-left: 2px; }
.disc-amt { color: var(--ng); }
.row-tools { display: flex; align-items: center; gap: 10px; padding: 8px 4px 0; }

.est-bottom { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; }
.est-bottom textarea { border: 0; border-radius: 0; padding: 10px 12px; }

/* ---------- 一覧 ---------- */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.list th { background: #f0f4ec; font-size: 12px; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list th.r { text-align: right; }
.list td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.list tfoot td { background: #f8faf6; border-top: 2px solid var(--line); }
.list tr.clickable { cursor: pointer; }
.list tr.clickable:hover td { background: #f7fbf3; }
.list.small td, .list.small th { padding: 4px 6px; font-size: 12px; }
.ops-cell { white-space: nowrap; text-align: right; }
.ops-cell .btn { margin-left: 4px; }
.list.editable td { padding: 3px 6px; }
.list.editable input { width: 100%; border-color: transparent; background: transparent; }
.list.editable input:hover { border-color: var(--line); }
.list.editable input:focus { background: #fffde7; }
.r-text { display: block; text-align: right; padding-right: 8px; }

.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--band); margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 18px; text-decoration: none; color: var(--ink); border-radius: 6px 6px 0 0; font-weight: 600; }
.tab:hover { background: var(--brand-soft); }
.tab.on { background: var(--band); color: #fff; }

.form-grid { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; align-items: center; }
.form-grid label { color: var(--muted); font-size: 13px; text-align: right; }
.form-grid label em { color: var(--ng); font-style: normal; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.company-form, .data-card { padding: 16px 20px; max-width: 760px; }
.data-card h3 { margin-top: 0; }
/* 運営の画面 (申込コード・契約): 列が多いので広く、1行で見せる。狭い画面では横に動かせる */
.data-card.op-wide { max-width: 1200px; overflow-x: auto; }
.op-status { width: auto; min-width: 230px; }
.data-card p { line-height: 1.8; }
.seal-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seal-box img { width: 64px; height: 64px; object-fit: contain; border: 1px dashed var(--line); }
.sub-title { margin: 18px 0 6px; font-size: 14px; }
.sub-title small { color: var(--muted); font-weight: 400; }

/* ---------- モーダル・候補・トースト ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20,30,20,.35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 18px; }
.modal-body .grid td { border-color: var(--line); }
.modal-body .grid thead th { background: #f0f4ec; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.modal-foot .danger-ghost { margin-right: auto; }
.confirm-msg { line-height: 1.8; margin: 0; }
.radio { display: block; margin: 8px 0; cursor: pointer; }
.radio input { margin-right: 8px; vertical-align: middle; }
.import-mode { margin: 10px 0; }
.import-preview { margin-top: 10px; }

.suggest {
  position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0,0,0,.16); max-height: 340px; overflow: auto; padding: 4px;
}
.sg-item { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.sg-item:hover, .sg-item.active { background: var(--brand-soft); }
.sg-main { flex: 1; min-width: 0; }
.sg-main small { display: block; color: var(--muted); font-size: 11px; }
.sg-right { font-weight: 700; font-variant-numeric: tabular-nums; }

#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { background: #263826; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.2); transition: opacity .4s, transform .4s; max-width: 420px; }
.toast-ng { background: var(--ng); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- 印刷プレビュー画面 ---------- */
.print-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: 61px; z-index: 10;
  background: var(--bg); padding: 8px 0 12px;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg-btn { padding: 7px 14px; text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); font-weight: 600; }
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--brand); color: #fff; }
.paper-wrap { display: flex; flex-direction: column; align-items: center; gap: 20px; }

@media (max-width: 1200px) {
  .est-top { grid-template-columns: 1fr 1fr; }
  .similar { grid-column: 1 / -1; }
  .est-tables, .est-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main { padding: 12px; }
  .app-head { flex-wrap: wrap; gap: 8px; padding: 6px 12px; }
  .est-top { grid-template-columns: 1fr; }
  .est-tables { overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { text-align: left; }
}

/* 現場フォルダへの保存 */
.folder-btn { border-color: #9cc0a0; background: #f2f8f2; }
.slip-btn { border-color: #e2a0a0; background: #fdf3f3; color: #8a1f1f; }
.radio.inline { display: inline-block; margin-right: 18px; }
.pdf-render { position: fixed; left: -10000px; top: 0; width: 210mm; background: #fff; }
.pdf-render .paper { box-shadow: none; }

/* 必須項目 */
.req { color: var(--ng); font-style: normal; }
input.required-ng, select.required-ng { border-color: var(--ng); background: #fdecec; }

/* 見積台帳: 現場ごと */
.seg-sm .seg-btn { padding: 5px 14px; font-size: 13px; border: 0; background: #fff; cursor: pointer; }
.seg-sm .seg-btn.on { background: var(--brand); color: #fff; }
.nowrap { white-space: nowrap; }
.site-layout { display: grid; grid-template-columns: 300px 1fr; gap: 12px; align-items: start; }
.site-list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 230px); overflow: auto; position: sticky; top: 76px; }
.site-list-head { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); background: #f6f8f4; position: sticky; top: 0; }
.site-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-soft); background: #fff; padding: 9px 12px; cursor: pointer; border-left: 4px solid transparent; }
.site-item:hover { background: #f7fbf3; }
.site-item.on { background: var(--brand-soft); border-left-color: var(--brand); }
.site-name { display: block; font-weight: 700; }
.site-sub { display: block; font-size: 12px; color: var(--muted); }
.site-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.site-meta b { color: var(--ink); }
.site-detail-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.site-detail-head h3 { margin: 0; font-size: 18px; }
.site-stats { display: flex; gap: 22px; margin-left: auto; font-variant-numeric: tabular-nums; }
.site-stats small { display: block; color: var(--muted); font-size: 11px; }
.site-stats b { font-size: 16px; }
.pattern-row td { background: #fafcf8; }
.pattern-row td:first-child { padding-left: 22px; }
.pattern-mark { font-size: 11px; color: var(--brand-dark); font-weight: 700; }
@media (max-width: 900px) { .site-layout { grid-template-columns: 1fr; } .site-list { position: static; max-height: 260px; } }

/* ---- 過去の見積の取り込み (#/import) ---- */
.imp-intro p, .imp-intro ol { line-height: 1.8; margin: 0 0 10px; }
.imp-intro code, .imp-sum code { background: #f3f5f1; padding: 1px 5px; border-radius: 4px; }
.imp-progress { margin-top: 12px; }
.imp-phase { font-weight: 700; margin-bottom: 8px; }
.imp-bar { height: 10px; background: #eef0ee; border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.imp-bar > div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.imp-progress .muted { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 8px; }
.imp-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.imp-chips .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.imp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.imp-q { flex: 1; min-width: 240px; padding: 8px 12px; }
.imp-table-wrap { margin-top: 12px; overflow-x: auto; }
.imp-table { min-width: 1040px; }
.imp-table td { vertical-align: middle; }
.imp-table tr.off td { color: var(--muted); background: #fafafa; }
.imp-path { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge.imp-new, .dot.imp-new { background: #e3f1e4; color: #2e6b31; }
.badge.imp-exists, .dot.imp-exists, .badge.imp-dup, .dot.imp-dup { background: #eceeec; color: #6b6f6b; }
.badge.imp-empty, .dot.imp-empty, .badge.imp-ledger, .dot.imp-ledger { background: #fff1dc; color: #9a5b00; }
.badge.imp-error, .dot.imp-error { background: #fde6e6; color: #a32020; }
.dot.imp-new { background: #4a9a4e; } .dot.imp-exists, .dot.imp-dup { background: #a9ada9; }
.dot.imp-empty, .dot.imp-ledger { background: #e3a13a; } .dot.imp-error { background: #d24b4b; }

.rate-round { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-left: 8px; }
.rate-round select { font-size: 12px; padding: 3px 6px; width: auto !important; }

/* 練習用の会社 (?tenant=) で操作中の帯 */
.demo-bar { background: #fff3e0; border-bottom: 2px solid #f0a33a; color: #7a4a00; padding: 6px 16px; font-size: 13px; }
.demo-bar a { margin-left: 10px; font-weight: 700; }

/* ---- クラウド版: ログイン中の人・保存の状態 ---- */
.account { position: relative; display: flex; align-items: center; gap: 8px; }
.sync { font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.sync-ok { color: var(--ok); background: #e8f5e9; }
.sync-saving { color: var(--muted); background: #eef0ee; }
.sync-ng { color: var(--ng); background: #fde6e6; font-weight: 700; }
.acct-btn { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 12px; cursor: pointer; white-space: nowrap; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 8px; min-width: 220px; z-index: 50; display: flex; flex-direction: column; gap: 4px; }
.acct-menu[hidden] { display: none; }
.acct-menu button { text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.acct-menu button:hover { background: var(--brand-soft); }
.acct-sep { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }

/* ---- ログイン画面 ---- */
body.login-mode .nav, body.login-mode .co-badge { display: none !important; }
.login-wrap { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px 28px 22px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-logo { display: block; height: 64px; margin: 0 auto 8px; }
.login-card h2 { text-align: center; margin: 4px 0 16px; font-size: 20px; }
.login-card h3 { font-size: 15px; margin: 0 0 4px; }
.login-tabs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.login-tabs button { flex: 1; border: 0; background: #fff; padding: 9px; cursor: pointer; font-weight: 600; }
.login-tabs button.on { background: var(--brand); color: #fff; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-form input { padding: 10px 12px; font-size: 15px; }
.login-form .btn.big { padding: 11px; font-size: 15px; justify-content: center; }
.login-choice { display: flex; flex-direction: column; gap: 18px; margin: 12px 0; }
.login-choice form + form { border-top: 1px dashed var(--line); padding-top: 16px; }
.link-btn { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--brand-dark); text-decoration: underline; cursor: pointer; font-size: 13px; }
.login-foot { margin-top: 16px; }

/* 社員アカウント: 招待 */
.invite-box { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; align-items: center; margin: 10px 0; }
.invite-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.invite-row input { flex: 1; min-width: 200px; padding: 6px 10px; background: #f7f9f5; }
.invite-row .inv-code { flex: 0 1 180px; min-width: 140px; font-family: monospace; font-size: 15px; letter-spacing: .08em; }
.invite-box .inv-note { grid-column: 1 / -1; margin: 0; }
@media (max-width: 640px) { .invite-box { grid-template-columns: 1fr; } }

.login-pick { display: grid; gap: 8px; margin: 12px 0 4px; }
.login-pick button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 14px; cursor: pointer; display: grid; gap: 2px; }
.login-pick button span { font-size: 12px; color: var(--muted); }
.login-pick button.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.login-choice form[hidden] { display: none; }
.login-choice form + form { border-top: 0; padding-top: 0; }

/* 見積台帳: 現場名の表記ゆれ */
.site-variants { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.site-variants span { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px; padding: 0 8px; }
.site-merge { background: #fff8ec; border: 1px solid #f0d3a4; border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; font-size: 13px; }
.site-merge-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.site-merge-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.site-merge-item small { color: var(--muted); }
.site-merged { margin: 6px 0 10px; }
.link-btn.inline { display: inline; margin: 0 0 0 4px; padding: 0; font-size: 12px; }

/* スマホだけで使う欄 (見積台帳のカード)。パソコンでは出さない */
.m-only { display: none; }
@media (max-width: 720px) { span.m-only { display: inline; } td.m-only { display: block; } }

/* 内訳書: コピー・貼り付け */
.bd-clip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.bd-clip .btn[disabled] { opacity: .45; cursor: default; }

/* 印刷画面: 承認者を選ぶ */
.approver-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.approver-pick select { width: auto; padding: 6px 8px; }

/* 起動時の読み込み中 */
.loading-page { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.loading-spin { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: bm-spin .8s linear infinite; }
@keyframes bm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spin { animation: none; } }

/* ゴミ箱 */
.trash-tabs { margin: 0 0 12px; display: inline-flex; }
.trash-table td { vertical-align: middle; }
.empty-trash { padding: 30px 0; text-align: center; }

/* 見積台帳: ゴミ箱のアイコンボタン */
.icon-btn-trash { padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn-trash:hover { color: var(--ng); border-color: var(--ng); }

/* ログイン画面: 左に説明 (広い画面)・上に説明 (スマホ) */
.login-main { display: flex; justify-content: center; align-items: center; gap: 48px; width: 100%; max-width: 1040px; }
.login-wrap.with-intro .login-card { flex: 0 0 420px; }
.login-intro { flex: 1; min-width: 0; max-width: 520px; display: flex; flex-direction: column; gap: 14px; }
.login-intro .li-eyebrow { margin: 0; color: var(--brand); font-weight: 700; letter-spacing: .04em; }
.login-intro h1 { margin: 0; font-size: 34px; line-height: 1.35; color: var(--ink); }
.login-intro ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 12px; }
.login-intro li { display: grid; gap: 2px; padding-left: 16px; border-left: 4px solid var(--band); }
.login-intro li span { color: var(--muted); font-size: 13px; }
.login-intro .li-new { margin: 6px 0 0; font-size: 13px; color: var(--brand-dark); background: var(--brand-soft); border-radius: 8px; padding: 10px 12px; }
.login-pick + .login-choice form { margin-top: 4px; }
@media (max-width: 860px) {
  .login-main { flex-direction: column; gap: 18px; }
  .login-wrap.with-intro .login-card { flex: none; width: 100%; max-width: 440px; }
  .login-intro { max-width: 440px; gap: 8px; }
  .login-intro h1 { font-size: 24px; }
  .login-intro ul { gap: 8px; }
  .login-intro .li-new { display: none; }
}

/* ---- チェックで選んで、まとめて統一・削除 ---- */
.pick-cell { width: 34px; text-align: center; }
.pick-cell input, .site-pick input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--brand); }
tr.picked > td { background: #fff8e1 !important; }
.pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px;
  background: #fff8e1; border: 1px solid #f0d3a4; border-radius: var(--radius); font-size: 13px; position: sticky; top: 64px; z-index: 6; }
.pick-bar[hidden] { display: none; }
.pick-bar-site { margin: 0; border-radius: 0; border-width: 0 0 1px; top: 33px; }
.site-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line-soft); }
.site-row .site-item { border-bottom: 0; flex: 1; min-width: 0; }
.site-row.picked, .site-row.picked .site-item:not(.on) { background: #fff8e1; }
.site-pick { display: flex; align-items: center; padding: 0 2px 0 8px; cursor: pointer; }
.unify-pick { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.unify-opt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.unify-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.unify-opt #uni-new { flex: 1; min-width: 160px; }
.sup-aliases { margin-top: 10px; }
.sup-aliases span { white-space: nowrap; }

/* ---- AIチャットサポート (オプション) ---- */
body.has-chat #toast-root { bottom: 76px; }
.chat-open {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font: inherit; font-weight: 700; padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
.chat-open:hover { background: var(--brand-dark); }
.chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; width: 360px; max-width: calc(100vw - 32px);
  height: 480px; max-height: calc(100vh - 100px); display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 36px rgba(0,0,0,.2); overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--brand); color: #fff; }
.chat-x { background: none; border: none; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-msg { padding: 8px 12px; border-radius: 10px; line-height: 1.6; max-width: 88%; white-space: normal; word-break: break-word; }
.chat-msg.bot { background: #fff; border: 1px solid var(--line-soft); align-self: flex-start; }
.chat-msg.me { background: var(--brand-soft); align-self: flex-end; }
.chat-msg.err { background: #fdecec; color: var(--ng); align-self: stretch; max-width: none; font-size: 13px; }
.chat-wait { color: var(--muted); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line-soft); }
.chat-form textarea { flex: 1; resize: none; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.chat-note { margin: 0; padding: 0 12px 10px; font-size: 11px; color: var(--muted); }

/* ---- 注文書の画面 (オプション) ---- */
.o-rows { width: 100%; margin: 8px 0; }
.o-rows td, .o-rows th { padding: 4px 6px; }
.o-rows { table-layout: fixed; }
.o-rows input[data-to] { width: 100%; }
.o-rows input[type=checkbox] { width: 16px; height: 16px; padding: 0; }
.o-rows .r { text-align: right; } .o-rows .c { text-align: center; }
.o-rows tr.o-off td { color: var(--muted); background: #f6f6f4; }
.o-warn { background: #fff6e0; border: 1px solid #f0d28a; border-radius: var(--radius); padding: 6px 10px; }
.o-cards { display: grid; gap: 12px; margin-top: 12px; }
.o-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fbfcfa; }
.o-card-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.o-card-head b { font-size: 15px; }
.o-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; }
.o-fields label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.o-fields input { color: var(--ink); }
.o-fields .o-wide { grid-column: 1 / -1; }
.o-fields .o-check { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.o-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---- 申込コード (運営者) ---- */
.code-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.code-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.code-form input { min-width: 220px; color: var(--ink); }
.code-issued { margin-top: 10px; padding: 10px 14px; background: var(--brand-soft); border: 1px solid #cfe3c4; border-radius: var(--radius); }
.code-issued p { margin: 4px 0; }
.code-big { font-size: 20px; font-weight: 700; letter-spacing: .08em; margin: 0 6px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---- 運営者 (ST CONSULTING) の自社の画面: ST のロゴの青と黄色 (お客様の会社と取り違えないように) ---- */
body.st-home {
  --brand: #1f4e96; --brand-dark: #163a70; --brand-soft: #eaf0fa; --band: #d4a017;
  --bg: #f3f5f9; --line: #cfd6e2; --line-soft: #e4e8ef;
}
body.st-home .app-head { border-bottom-width: 4px; }
body.st-home .co-badge { background: #fff6d6; border-color: #d4a017; color: #163a70; }
body.st-home .band, body.st-home .band-sub { background: var(--brand); }
/* 運営者がお客様の会社に入っているときの帯 */
.demo-bar.op-bar { background: #fff6d6; border-bottom-color: #d4a017; color: #5a4300; }
/* 納品書の画面 */
.dv-h { margin: 12px 0 4px; font-size: 14px; }
.o-rows input.dv-qty { width: 70px; text-align: right; }
/* 見積台帳: 見出しで並べ替え */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--brand-soft); }
th.sorted { color: var(--brand-dark); }
.sort-mark { font-size: 10px; margin-left: 3px; }
/* 顧客管理 (運営) */
.cl-log-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.cl-log-form #cl-note { flex: 1; min-width: 240px; }
#cl-q { margin: 6px 0 10px; width: 100%; max-width: 420px; }
/* 候補の「最安」の印 (同じ品を2社以上から仕入れているとき) */
.sg-badge { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: #E8590C; color: #fff; font-size: 11px; font-weight: 700; line-height: 1.6; vertical-align: 1px; }
/* 摘要: 押して入力している間だけ、左へ広げて全文を見せる (PC の幅のときだけ) */
@media (min-width: 721px) {
  td.rem-cell { position: relative; }
  td.rem-cell input:focus { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: min(440px, 60vw); z-index: 6; background: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
}
.role-table { max-width: 640px; }
.role-table td.c, .role-table th.c { width: 90px; text-align: center; }
/* 管理者だけの操作: メンバーにはグレーで出し、乗せると吹き出しで知らせる */
.lock-wrap { position: relative; display: inline-block; cursor: not-allowed; }
.lock-wrap > .btn:disabled { opacity: .45; pointer-events: none; filter: grayscale(1); }
.lock-wrap:hover::after { content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); white-space: nowrap; background: #333; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; z-index: 30; pointer-events: none; }
.lock-note { background: #f3f4f2; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; color: var(--muted); font-size: 13px; }
.lock-fs { border: 0; padding: 0; margin: 0; min-width: 0; opacity: .6; filter: grayscale(.6); cursor: not-allowed; }
.lock-fs * { cursor: not-allowed !important; }
.sg-badge-old { background: #8a8f87; }
.est-who { margin-left: auto; }

/* 新しい版が公開されたときの帯 (画面の下) */
.update-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px;
  background: #263238; color: #fff; padding: 10px 14px 10px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px; max-width: calc(100% - 32px); }

/* ---- 受注 (見積入力の情報欄・見積台帳の列) ---- */
.won-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.won-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.won-check input, .won-tick input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.won-row.on .won-check { color: var(--brand-dark); font-weight: 700; }
.won-row input[type=date] { width: auto; }
.c-won { white-space: nowrap; text-align: center; }
.won-tick { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.c-won.on .won-tick { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }

/* 見積入力: 「見積書の1枚目に入るのは○行まで」 */
.row-tools { flex-wrap: wrap; }
.sheet-info { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sheet-info.near { color: var(--warn); font-weight: 700; }
.sheet-info.over { color: #c62828; font-weight: 700; }

/* ---- 「選んだ明細だけ」に掛ける掛け率 (法定福利費など) ---- */
/* 名称の列はせまいので、ボタンは名前の下に置く */
.name-cell.has-target { padding-bottom: 3px; vertical-align: top; }
.name-cell.has-target .target-btn { display: block; margin: 1px 0 0 4px; white-space: nowrap; font-size: 11px; }
.target-btn.none { background: #fdecea; border-color: #e57373; color: #c62828; font-weight: 700; }
.target-tag { display: inline-block; margin-left: 2px; padding: 0 3px; border-radius: 3px; background: var(--brand-soft); color: var(--brand-dark); font-size: 10px; font-weight: 700; line-height: 1.5; vertical-align: middle; }
.target-tools { display: flex; gap: 6px; margin: 6px 0; }
.target-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; max-height: 50vh; overflow: auto; }
.target-opt { display: grid; grid-template-columns: 22px 28px 1fr auto; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.target-opt:last-child { border-bottom: 0; }
.target-opt:has(input:checked) { background: var(--brand-soft); }
.target-opt .no { color: var(--muted); font-size: 12px; text-align: right; }
.target-opt .amt { font-variant-numeric: tabular-nums; }
.target-sum { margin-top: 10px; }

/* 掛け率項目の追加 */
.ri-q { margin: 14px 0 4px; }

/* 見積入力: 見積書の1枚目の終わりの線と、2枚目に回る行 */
tr.sheet-end > td { border-bottom: 2px dashed #e53935 !important; }
tr.sheet-end > td:nth-child(2) { position: relative; }
tr.sheet-end > td:nth-child(2)::after {
  content: attr(data-label); position: absolute; left: 4px; bottom: -9px; z-index: 3; pointer-events: none;
  background: #fff; color: #c62828; font-size: 10.5px; font-weight: 700; padding: 0 4px; white-space: nowrap; line-height: 16px;
}
tr.sheet-over > td { background: #fdecea !important; }
tr.sheet-over input { background: transparent; }

/* 法定福利費などの対象: 内訳の行 */
.target-group { border-bottom: 1px solid var(--line-soft); }
.target-group .target-opt { border-bottom: 0; }
.target-bd { padding-left: 34px; font-size: 13px; background: #fafbf9; }
.target-bd.off { opacity: .45; }
.target-tag.part { background: #fff; border: 1px dashed var(--brand); }
/* 請求・売上 (オプション) */
.badge-invoice { background: #e3f0fb; color: #1f5f99; }
.iv-st { display: inline-block; padding: 0 2mm; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.iv-st-open { background: #eef1ee; color: #444; }
.iv-st-part { background: #fff3d6; color: #8a5a00; }
.iv-st-over { background: #fde4e1; color: #b3261e; }
.iv-st-paid { background: #e2f3e4; color: #1f6b2a; }
.iv-st-cancel { background: #eee; color: #888; text-decoration: line-through; }
.iv-row-cancel td { color: #999; }
.iv-warn { background: #fff7e6; border: 1px solid #e0b56b; border-radius: 6px; padding: 6px 10px; color: #7a4b00; font-size: 13px; }
.iv-cancel-note { text-align: center; color: #b3261e; font-weight: 700; }
.sl-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0; }
.sl-cards > div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; }
.sl-cards small { color: var(--muted); }
.sl-cards b { font-size: 22px; font-variant-numeric: tabular-nums; }
.sl-cards .sl-warn b { color: #b3261e; }
@media (max-width: 720px) { .sl-cards { grid-template-columns: 1fr 1fr; } }
/* 見積台帳のプレビュー: 左に一覧、右に見積書 */
.pv-layout { display: grid; grid-template-columns: var(--pv-left, minmax(380px, 40%)) 10px minmax(0, 1fr); gap: 4px; align-items: start; }
.pv-split { align-self: stretch; min-height: 200px; cursor: col-resize; border-radius: 4px; position: relative; touch-action: none; }
.pv-split::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: var(--line); border-radius: 1px; }
.pv-split:hover::after, .pv-split.dragging::after { background: var(--brand); width: 4px; left: 3px; }
.pv-list { max-height: calc(100vh - 230px); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.pv-table { margin: 0; }
.pv-table thead th { position: sticky; top: 0; z-index: 1; }
.pv-table tbody tr { cursor: pointer; }
.pv-table tbody tr.on td { background: #e6f2e2; }
.pv-table tbody tr.on td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.pv-cu { font-size: 12px; color: var(--muted); }
.pv-cu .pv-site { margin-left: 1em; color: var(--ink); }
.pv-cu .pv-site::before { content: "現場："; color: var(--muted); }
.pv-subj { font-weight: 700; }
.pv-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 2px; }
.pv-tags .badge { margin: 0; }
.badge-won { background: #e2f3e4; color: #1f6b2a; }
.pv-count { padding: 6px 10px; margin: 0; }
.pv-doc { position: sticky; top: 8px; background: #e9ece6; border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 230px); display: flex; flex-direction: column; }
.pv-bar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; min-height: 60px; background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
/* プレビューの上のボタンは、押しやすいように普通の大きさに (見積台帳・請求書の両方) */
.pv-bar .btn.sm { padding: 7px 14px; font-size: 14px; }
.pv-bar .seg .seg-btn { padding: 6px 14px; font-size: 14px; }
.pv-bar .iv-st { font-size: 13px; padding: 3px 12px; }
.pv-bar > .muted.small { font-size: 13px; }
.pv-paper { overflow: auto; padding: 12px; }
.pv-paper .paper { box-shadow: 0 2px 8px rgba(0,0,0,.15); margin: 0 auto 12px; }
.pv-empty { padding: 60px 0; }
@media (max-width: 900px) {
  /* 狭い画面: 一覧の下に書類。中身 (表・A4の紙) の幅で横にはみ出さないよう、列を画面の幅までにする */
  .pv-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .pv-layout > * { min-width: 0; }
  .pv-split { display: none; }
  .pv-list, .pv-doc { max-height: none; position: static; }
}
.badge-plan { background: #fff3d6; color: #8a5a00; }
.bk-cu { min-width: 320px; }
.iv-st-draft { background: #eef1ee; color: #555; }
.iv-st-sent { background: #e3f0fb; color: #1f5f99; }

/* ---- 状態の印 (請求予定・請求書作成済・請求済・入金確認など)。2026-10-15 見直し ----
   形はすべて同じ: 白地に色の枠と、左に色の丸。進むほど色が濃く、終わり (入金確認) は塗りつぶし。注意 (期限切れ) は赤の塗り */
.iv-st, .badge-plan, .badge-won, .badge-order {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px 0 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1; white-space: nowrap; vertical-align: middle;
  background: #fff; border: 1px solid currentColor; text-decoration: none;
}
.iv-st::before, .badge-plan::before, .badge-won::before, .badge-order::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none;
}
.badge-plan { color: #9a6a00; border-style: dashed; }          /* 請求予定: まだ請求書はない (点線) */
.iv-st-draft { color: #5b6b7a; }                               /* 請求書作成済: まだ送っていない */
.iv-st-sent { color: #1f6fb2; }                                /* 請求済: 入金待ち */
.iv-st-part { color: #b06a00; background: #fff8ec; }           /* 一部入金 */
.iv-st-paid { color: #fff; background: #2e7d32; border-color: #2e7d32; } /* 入金確認: 完了は塗り */
.iv-st-over { color: #fff; background: #c62828; border-color: #c62828; } /* 期限切れ: 注意は赤の塗り */
.iv-st-cancel { color: #9aa09a; text-decoration: line-through; }
.iv-st-open { color: #5b6b7a; }                                /* 定期請求の「未請求」 */
.badge-won { color: #2e7d32; }
.badge-order { color: #1f6fb2; }
.pv-tags { gap: 6px; }
.pv-bar .iv-st { height: 26px; font-size: 13px; padding: 0 12px 0 10px; }
/* プレビューの上の帯: 縮まないように (ボタンが2段になっても下の書類に重ならない) */
.pv-bar { flex: none; }
.pv-more { position: relative; }
.pv-more > summary { list-style: none; cursor: pointer; }
.pv-more > summary::-webkit-details-marker { display: none; }
.pv-more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.12); min-width: 240px; padding: 4px; display: flex; flex-direction: column; }
.pv-more-menu > a, .pv-more-menu > button { display: block; text-align: left; padding: 8px 12px; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink); text-decoration: none; border-radius: 6px; cursor: pointer; }
.pv-more-menu > a:hover, .pv-more-menu > button:hover { background: #f1f5ef; }
.pv-more-menu > .danger { color: #c62828; }
.pv-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-left: auto; }

/* 請求・売上: 請求ボックス → 請求書作成済 → 請求済 → 入金管理 */
.bl-tabs { align-items: center; flex-wrap: wrap; }
.bl-arrow { color: #9aa5b1; padding: 0 2px; font-size: 13px; }
.bl-tab-sep { width: 1px; height: 20px; background: #d5dbe1; margin: 0 10px; }
.bl-count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 6px; border-radius: 9px; background: #1f6fb2; color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.bx-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px; background: #fff; border: 1px solid #c9d6e3; border-radius: 8px; box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
.bx-bar.off { opacity: .7; }
.bx-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pv-field { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #555; }
.pv-field input { padding: 3px 6px; font-size: 12px; }
.bl-cu { display: inline-flex; align-items: center; gap: 4px; }
.bl-cu-sum { margin: 0 0 10px; padding: 8px 12px; background: #eef5fb; border-left: 4px solid #1f6fb2; border-radius: 4px; font-size: 14px; }

/* ---- 見積台帳の一覧 (2026-10-15 見直し): 関係するものを上下2段に、状態は1列、複製・削除は「⋯」の中 ---- */
.badge-quote { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; line-height: 1; white-space: nowrap; background: #fff; border: 1px solid #b8bfb8; color: #7a837a; }
.badge-quote::before { content: ''; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; flex: none; }
.st-btn { cursor: pointer; font-family: inherit; }
.st-btn:hover { box-shadow: 0 0 0 2px rgba(46,125,50,.18); }
#ls-body table.list td { vertical-align: top; }
#ls-body table.list .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
#ls-body table.list .sub.nocost { color: #b06a00; font-weight: 700; }
#ls-body table.list .sub.warn { color: #b06a00; }
#ls-body table.list .one { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ls-body .c-date { width: 118px; }
#ls-body .c-cust { width: 190px; max-width: 190px; }
#ls-body .c-amt { width: 120px; }
#ls-body .c-state { width: 130px; white-space: nowrap; }
#ls-body .c-state > div { margin-top: 4px; }
#ls-body .c-ops { width: 44px; text-align: right; }
#ls-body .c-subj .tag { margin-left: 4px; vertical-align: 1px; }
.sort-sub { cursor: pointer; }
.sort-sub:hover, .sort-sub.sorted { color: var(--brand-dark); text-decoration: underline; }
.row-more > summary { padding: 2px 10px; font-size: 15px; line-height: 1.2; }
.row-more .pv-more-menu { min-width: 220px; }
#ls-body .c-cust.narrow { width: 96px; max-width: 96px; }
#ls-body .c-subj { min-width: 170px; }
.site-detail #ls-body .c-date, #ls-body .site-detail .c-date { width: 100px; }

/* 自社品目: 表示順・ドラッグで並べ替え */
.it-order { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.it-order select { width: auto; padding: 6px 8px; }
.it-order-hint { margin: 0 0 8px; }
.it-table .it-handle { width: 74px; white-space: nowrap; color: #9aa09a; }
.it-table .it-handle span { cursor: grab; font-size: 16px; padding: 0 4px; vertical-align: middle; }
.it-table .it-handle .mini { padding: 0 5px; }
.it-table tr.dragging { opacity: .4; }
.it-table tr.drop-before > td { box-shadow: inset 0 3px 0 var(--brand); }
.it-table tr.drop-after > td { box-shadow: inset 0 -3px 0 var(--brand); }
.it-table tr.just-moved > td { background: #fff8e1; }

/* 見積台帳のプレビュー: 左の一覧にゆとりを (2026-10-15)。件名を主役に、客先・場所はその下に小さく */
.pv-table tbody td { padding-top: 12px; padding-bottom: 12px; vertical-align: top; border-bottom-color: #edf0ec; }
.pv-table .pv-date { font-size: 13px; color: var(--muted); padding-right: 14px; width: 1%; }
.pv-table .pv-pat { font-size: 11px; color: #8a6d00; margin-top: 3px; }
.pv-table .pv-main { line-height: 1.45; }
.pv-table .pv-subj { font-size: 15px; font-weight: 700; color: var(--ink); }
.pv-table .pv-where { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.pv-table .pv-dot { margin: 0 4px; color: #b8bfb8; }
.pv-table .pv-tags { margin-top: 7px; gap: 8px; }
.pv-table .pv-tags:empty { display: none; }
.pv-table .pv-staff { font-size: 12px; color: var(--muted); }
.pv-table .pv-amt { padding-left: 14px; }
.pv-table .pv-amt b { font-size: 15px; }
.pv-table .pv-amt div { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pv-table .pv-amt div.warn { color: #b06a00; }
.pv-table .pv-amt div.nocost { color: #b06a00; font-weight: 700; }
.pv-table .pv-main { width: 100%; max-width: 0; }
.pv-table .pv-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 見積台帳「現場ごと」: 現場でまとめる／客先でまとめる */
.group-seg { display: flex; margin: 8px 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.group-seg .seg-btn { flex: 1; }
/* 体験版の帯 */
.demo-bar.trial-bar { background: #e8f4fd; border-bottom-color: #1f6fb2; color: #0c447c; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.demo-bar.trial-bar .trial-acts { margin-left: auto; display: inline-flex; gap: 14px; align-items: center; }
.demo-bar.trial-bar .trial-acts a, .demo-bar.trial-bar .link-btn { margin: 0; font-weight: 700; color: #1f6fb2; font-size: 13px; }
/* 体験版: ブラウザの印刷メニュー (Ctrl+P) からも印刷・PDF にできないように */
@media print {
  body.trial > * { display: none !important; }
  body.trial::before { content: "体験版では印刷・PDF の保存はできません。お申し込み後にお使いいただけます。"; display: block; padding: 40mm 20mm; font-size: 16pt; text-align: center; }
}

/* 体験版の使い方ツアー: 案内する場所を光らせ、吹き出しで次の操作を出す */
.tour-spot { position: absolute; z-index: 45; border-radius: 8px; pointer-events: none; box-shadow: 0 0 0 4px #f0a33a, 0 0 0 200vmax rgba(20,30,20,.38); } /* ページに貼りつける (スクロールしてもずれない)。固定のメニューなどを光らせるときだけ fixed */
.tour-spot.on-fixed { position: fixed; }
.tour-spot[hidden] { display: none; }
.tour-bubble { position: fixed; z-index: 48; width: 340px; max-width: calc(100vw - 20px); background: #fff; border-radius: 12px; padding: 16px 18px 14px; box-shadow: 0 12px 32px rgba(0,0,0,.25); border-top: 5px solid #f0a33a; font-size: 14px; line-height: 1.7; transition: left .25s, top .25s; }
.tour-bubble.center { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); width: 420px; box-shadow: 0 0 0 200vmax rgba(20,30,20,.45), 0 12px 32px rgba(0,0,0,.25); }
.tour-bubble.bottom { left: 10px !important; right: 10px; width: auto; }
.tour-bubble .tour-count { font-size: 12px; color: #b06a00; font-weight: 700; margin-bottom: 2px; }
.tour-bubble .tour-title { display: block; font-size: 16px; color: var(--brand-dark); margin-bottom: 4px; }
.tour-bubble p { margin: 0 0 12px; color: var(--ink); }
.tour-bubble .tour-acts { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.tour-bubble .tour-acts .link-btn { margin-right: auto; font-size: 12px; color: var(--muted); }
/* 大きい窓 (内訳書の入力など): 画面いっぱい近くまで広げる */
.modal-back.modal-back-xl { padding: 2vh 2vw; }
.modal.xl { max-width: min(1500px, 96vw); }
.modal.xl .modal-head h3 { font-size: 18px; }
.modal.xl .hint { font-size: 14px; }
.modal.xl .bd-grid { font-size: 15px; }
.modal.xl .bd-grid input { font-size: 15px; padding-top: 8px; padding-bottom: 8px; }
.modal.xl .bd-grid th { font-size: 13px; padding-top: 8px; padding-bottom: 8px; }
/* 請求書作成済: まとめて印刷・PDF */
.ps-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: flex-start; gap: 8px 14px; flex-wrap: wrap; padding: 8px 10px; background: #f6f9fc; border-bottom: 1px solid var(--line); font-size: 13px; }
.ps-bar .ps-btns { display: flex; gap: 6px; }
.ps-bar .btn[disabled] { opacity: .45; cursor: default; }
.pv-table .pick-cell { width: 34px; }
.bx-open { color: inherit; text-decoration: underline; text-decoration-color: #b8c4b8; text-underline-offset: 3px; }
.bx-open:hover { color: var(--brand-dark); text-decoration-color: currentColor; }
.bx-paper { background: #eef0ec; padding: 12px; border-radius: 8px; }
/* 請求済: 日付で絞り込む */
.bl-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bl-range select, .bl-range input[type=date] { width: auto; }
.func-btns .func-state { grid-column: 1 / -1; }
.func-btns .func-state:empty { display: none; }
/* 仕入金額のメモ: ふだんは1行 (… で切る)。入力中は左へ広げて折り返し、全文を見せる */
.grid td.memo-cell textarea { display: block; width: 100%; height: 30px; border: 0; border-radius: 0; padding: 5px 3px; background: transparent; font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.grid td.memo-cell textarea:focus { background: #fffde7; outline: 2px solid var(--brand); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (min-width: 721px) {
  td.memo-cell { position: relative; }
  .grid td.memo-cell textarea:focus { position: absolute; right: 2px; top: 2px; width: min(420px, 60vw); min-height: 30px; z-index: 6; box-shadow: 0 6px 18px rgba(0,0,0,.18); font-size: 14px; padding: 6px 8px; }
}
@media (max-width: 720px) {
  .est-tables .grid td.memo-cell textarea { height: auto; min-height: 38px; border: 1px solid var(--line-soft); border-radius: 6px; background: #fff; padding: 8px 5px; white-space: pre-wrap; }
}
/* 自社品目の登録: 仕入原価の表は、狭い画面では横に動かして見る (項目の欄がつぶれないように) */
.ie-costs-wrap { overflow-x: auto; }
.ie-costs { min-width: 760px; }
.ie-costs td.c { text-align: center; }
.ie-costs [data-prod], #ie-prod-all { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
/* 見積台帳の絞り込み: パソコンはそのまま横に並べる。スマホは「絞り込み ▾」で開く (mobile.css) */
.ls-filter-btn { display: none; }
.ls-filters { display: contents; }
.ls-dates { display: inline-flex; align-items: center; gap: 6px; }
.site-back { display: none !important; }

/* 体験版の帯: パソコンは長い説明、スマホは短く1〜2行に */
.demo-bar .tb-short { display: none; }
/* 見積入力のスマホ用タブ・下の帯 (パソコンでは出さない。mobile.css で出す) */
.est-mtabs, .est-mbar, .est-msheet-back { display: none; }
/* 請求書の「請求ボックスに戻す」「取り消す」: その他にしまわず、帯の下の段に分けて出す (2026-10-18) */
.pv-undo { flex-basis: 100%; display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 8px; margin-top: 2px; border-top: 1px dashed var(--line); }
.pv-undo .btn.sm { padding: 5px 12px; font-size: 13px; }
/* 仕入の価格: 3か月以上たったものは赤 (1か月以上は灰色の「要確認」) */
.sg-badge-old3 { background: #c62828; }
.stale-red, .stale-red b { color: #c62828; }
.r-text.warn.stale-red { color: #c62828 !important; }
/* 現場の「表記」: 押すと統一先を選び直せる (2026-10-19) */
.site-variants .site-variant { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 10px; padding: 0 8px; font: inherit; color: inherit; cursor: pointer; }
.site-variants .site-variant:hover { border-color: var(--accent, #2f7d32); color: var(--ink); }
.site-variants .site-variant.on { border-color: var(--accent, #2f7d32); color: var(--ink); font-weight: 700; }
/* 自社情報の振込先 (2026-10-19) */
.bank-card { margin-top: 14px; }
.bank-card h3 { margin: 0 0 6px; font-size: 15px; }
.bank-card h3 small { font-weight: 400; font-size: 12px; }
.bank-table td input, .bank-table td select { width: 100%; min-width: 70px; }
.bank-table td.c { text-align: center; width: 64px; }
.bank-table tr.bank-old td { border-top: 0; padding-top: 0; }
.bank-preview { margin-top: 8px; padding: 8px 12px; background: #f6f8f4; border: 1px solid var(--line-soft); border-radius: 8px; font-size: 13px; line-height: 1.6; }
/* 入力欄のすぐ下の注意 (登録番号など。2026-10-19) */
.field-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-msg { font-size: 12px; line-height: 1.5; }
.field-msg:empty { display: none; }
.field-msg.ng { color: #c62828; }
.field-msg.warn { color: #b06a00; }
input.field-ng { border-color: #c62828 !important; background: #fff6f6; }
input.field-warn { border-color: #e0a030 !important; }
.bank-mode { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 13px; }
/* 請求書作成済: 注文番号・行ごとの消費税 (2026-10-19) */
/* 顧客管理（運営）: 広い表・折り返さない・状態の札 (2026-10-19) */
.cl-card .cl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; margin-bottom: 4px; }
.cl-card .cl-head h3 { margin: 0; }
.cl-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.cl-stats span { display: inline-flex; align-items: baseline; gap: 4px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; }
.cl-stats small { color: var(--muted); margin-right: 2px; }
.cl-stats b { font-size: 16px; }
.cl-stats .st-active { border-color: #9cc9a0; background: #f1f8f1; }
.cl-stats .st-soon { border-color: #e0a030; background: #fff8ec; }
.cl-stats .st-ended { border-color: #ccc; background: #f5f5f5; }
.cl-table td { vertical-align: middle; }
.cl-table td.cl-name { min-width: 180px; white-space: nowrap; }
.cl-table .cl-soon { color: #b06a00; font-weight: 700; }
.cl-opts { white-space: normal; min-width: 120px; max-width: 170px; line-height: 1.7; }
.cl-opt { display: inline-block; font-size: 11px; padding: 0 6px; margin: 1px 3px 1px 0; border-radius: 4px; background: #eef4ec; border: 1px solid #cfe0cb; }
.cl-st { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 10px; border-radius: 999px; border: 1px solid; }
.cl-st-active { color: #2e7d32; border-color: #9cc9a0; background: #f1f8f1; }
.cl-st-ended { color: #8a6d00; border-color: #e6cf7a; background: #fffbea; }
.cl-st-stopped { color: #666; border-color: #ccc; background: #f3f3f3; }
/* 請求書作成済の「請求書の内容」の段: 見出しを上に、同じ高さでそろえる (2026-10-20) */
.pv-fmt { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; padding: 10px 12px; margin-top: 4px; background: #f7f9f6; border: 1px solid var(--line-soft); border-radius: 8px; }
.pv-f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #555; }
.pv-f > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pv-f input, .pv-f select { height: 32px; padding: 0 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-sizing: border-box; }
.pv-f input[type=date] { width: 150px; }
.pv-f-bank select { min-width: 170px; max-width: 240px; }
.pv-f-po input { width: 170px; }
.pv-f-po.need input { border-color: #e0a030; background: #fffaf0; }
.pv-need { font-size: 10.5px; color: #b06a00; background: #fff3dc; border: 1px solid #f0cf8a; border-radius: 4px; padding: 0 5px; font-weight: 700; }
.pv-f-btn { height: 32px; }
.pv-f-check { display: inline-flex; align-items: center; gap: 6px; height: 32px; font-size: 13px; color: #333; cursor: pointer; }
.pv-undo { border-top: 0; padding-top: 6px; }
/* 明細を分ける (2026-10-20) */
.split-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 12px; max-height: 50vh; overflow: auto; }
.split-row { display: grid !important; grid-template-columns: 20px 1fr auto 110px; gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--line-soft); border-radius: 6px; }
.split-row .split-amt { text-align: right; }
.split-opts { display: flex; flex-direction: column; gap: 6px; }
/* 請求書に行を足す窓 (2026-10-20) */
.ar-table input { width: 100%; height: 30px; padding: 0 6px; box-sizing: border-box; }
.ar-table td:nth-child(1) { min-width: 220px; }
.ar-table td:nth-child(2), .ar-table td:nth-child(3) { width: 70px; }
.ar-table td:nth-child(4), .ar-table td:nth-child(6) { width: 110px; }
.ar-table .ar-amt { width: 100px; white-space: nowrap; }
.ar-head { margin-bottom: 10px; }
/* 予定・車両 (2026-10-21) */
.sc-alerts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sc-alert { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: #fff6e5; border: 1px solid #f0cf8a; color: #8a5a00; }
.sc-alert.ng { background: #fdecec; border-color: #f2b8b8; color: #b3261e; }
.sc-bar { align-items: center; flex-wrap: wrap; gap: 6px; }
.sc-range { font-size: 15px; margin-left: 6px; }
.sc-who { width: auto; }
.sc-week, .sc-month { border-collapse: collapse; width: 100%; table-layout: fixed; min-width: 760px; }
.sc-week th, .sc-week td, .sc-month th, .sc-month td { border: 1px solid var(--line); vertical-align: top; }
.sc-week thead th, .sc-month thead th { font-size: 12px; padding: 4px; background: #f6f8f4; }
.sc-week thead th.today { background: #e6f2e4; }
.sc-week thead th.we { color: #b3261e; }
.sc-week .sc-who-h { width: 110px; text-align: left; font-size: 12.5px; padding: 6px; background: #fafbf9; }
.sc-week .sc-who-h small { display: block; color: var(--muted); font-weight: 400; }
.sc-week .sc-sep th { background: #eef1ec; font-size: 12px; text-align: left; padding: 3px 6px; }
.sc-cell { padding: 3px; height: 54px; cursor: pointer; position: relative; }
.sc-cell.today { background: #f3faf2; }
.sc-cell:hover .sc-add { opacity: 1; }
.sc-add { position: absolute; right: 4px; bottom: 2px; font-size: 13px; color: var(--muted); opacity: 0; }
.sc-month .sc-cell { height: 96px; }
.sc-month .sc-cell.out { background: #fafafa; color: var(--muted); }
.sc-day { font-size: 12px; font-weight: 700; }
.sc-chip { display: block; width: 100%; text-align: left; font: inherit; font-size: 11.5px; line-height: 1.35; margin-bottom: 3px; padding: 2px 5px; border-radius: 5px; border: 1px solid #b9d4b6; background: #eef6ec; color: var(--ink); cursor: pointer; overflow: hidden; }
.sc-chip .sc-t { color: var(--muted); margin-right: 4px; }
.sc-chip .sc-n { font-weight: 700; }
.sc-chip .sc-v { display: block; color: var(--muted); }
.sc-chip.k-inspect { background: #eaf2fb; border-color: #b6cde8; }
.sc-chip.k-meeting { background: #f4effa; border-color: #d1c2e6; }
.sc-chip.k-off { background: #f2f2f2; border-color: #d4d4d4; }
/* 予定ごとに選んだ色 (--ev) */
.sc-chip.colored, .sc-li.colored { border-color: var(--ev); border-left: 4px solid var(--ev); background: color-mix(in srgb, var(--ev) 12%, #fff); }
.sc-est { display: flex; gap: 6px; align-items: center; }
.sc-est input { flex: 1; min-width: 0; }
.sc-colors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sc-color input { position: absolute; opacity: 0; pointer-events: none; }
.sc-color span { display: inline-block; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.sc-color.none span { width: auto; height: 24px; line-height: 20px; border-radius: 12px; padding: 0 10px; font-size: 12px; background: #fff; }
.sc-color input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.sc-color input:focus-visible + span { outline: 2px solid var(--accent, #2f7d32); outline-offset: 2px; }
.sc-chip[draggable] { cursor: grab; }
.sc-chip.dragging { opacity: .45; }
.sc-cell.sc-drop { background: #e8f1fd; outline: 2px dashed #1a73e8; outline-offset: -2px; }
.sc-undo { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; background: #fff8e1; border: 1px solid #f3d27a; font-size: 13px; }
.sc-undo span { flex: 1; }
.sc-chip.clash, .sc-li.clash { border-color: #d93025; background: #fdecec; }
.sc-x { display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff; background: #d93025; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.sc-ld h4 { margin: 14px 0 6px; font-size: 14px; }
.sc-ld h4.today { color: var(--accent, #2f7d32); }
.sc-li { display: flex; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fff; cursor: pointer; }
.sc-li .sc-t { min-width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.sc-lb { min-width: 0; }
.sc-k { font-size: 11px; padding: 0 6px; border-radius: 4px; background: #eef1ec; }
.sc-empty { padding: 30px 0; }
.sc-form .sc-time { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sc-form .sc-time input[type=time] { width: 120px; }
.sc-people { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sc-clash { margin-top: 10px; padding: 8px 12px; border: 1px solid #f2b8b8; background: #fdecec; border-radius: 8px; color: #b3261e; font-size: 13px; }
.sc-clash ul { margin: 4px 0 0; padding-left: 18px; }
.sc-veh input { width: 100%; min-width: 110px; }
.sc-b { display: inline-block; font-size: 11px; margin-top: 2px; padding: 0 6px; border-radius: 4px; }
.sc-b.warn { background: #fff3dc; color: #8a5a00; }
.sc-b.ng { background: #fdecec; color: #b3261e; }

/* 見積の行の並べ替え (No. をつかんでドラッグ) */
td.no[draggable] { cursor: grab; }
tr.row-dragging { opacity: .4; }
tr.drop-above > td { box-shadow: inset 0 2px 0 #1a73e8; }
tr.drop-below > td { box-shadow: inset 0 -2px 0 #1a73e8; }

/* 見積のロック */
.lock-banner { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: #fff4e5; border: 1px solid #f0c27b; font-size: 13px; }
.est-locked td.no[draggable], .est-locked td.no { cursor: default; }
.est-locked .est-tables input:disabled, .est-locked .est-tables textarea:disabled, .est-locked .info input:disabled, .est-locked .info select:disabled, .est-locked .est-bottom :disabled { background: transparent; color: var(--ink); opacity: 1; -webkit-text-fill-color: var(--ink); }
.lock-mark { font-size: 12px; }
.func-btns .btn:disabled { opacity: .45; cursor: default; filter: grayscale(1); }
.est-locked #btn-lock { background: #fff4e5; border-color: #f0c27b; }

/* 発注台帳と請求の照合 (purchase.js) */
.po-alert { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: #fff4e5; border: 1px solid #f0c27b; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.po-table td { vertical-align: top; }
.po-table tr.po-cancel td { color: #999; }
.po-form .seg { width: max-content; }
.po-form #po-sup, .po-form #po-est { width: 100%; }
.po-form .po-for-site { display: flex; gap: 6px; }
.po-form .po-for-site[hidden] { display: none; }
.po-recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.po-recent .chip { font-size: 12px; padding: 2px 10px; }
.po-amt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.po-amt input { max-width: 160px; }
.po-sum { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 10px; font-size: 13px; }
.po-bad { color: #b3261e; font-weight: 700; }
.po-warn { color: #8a5a00; font-weight: 700; }
.po-good { color: #1f6b2a; font-weight: 700; }
.po-billhead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.po-big { font-size: 22px; }
.po-total { margin: 10px 0; font-size: 14px; }
.po-h { margin: 22px 0 4px; font-size: 15px; }
.po-doc { display: flex; flex-direction: column; gap: 6px; }
.po-rows input { width: 100%; }
.po-rows .po-n { width: 60px; } .po-rows .po-u { width: 50px; } .po-rows .po-n2 { width: 96px; }
.po-docf { display: flex; gap: 6px; flex-wrap: wrap; } .po-docf input { flex: 1; min-width: 200px; }
/* 発注を入れる窓を見やすく (2026-10-22) */
.po-form { grid-template-columns: 110px 1fr; gap: 10px 14px; }
.po-sec { grid-column: 1 / -1; font-weight: 700; font-size: 14px; color: var(--ink); border-bottom: 1px solid var(--line); padding: 6px 0 4px; margin-top: 4px; }
.po-sec:first-child { margin-top: 0; }
.po-pair { display: flex; gap: 8px; align-items: center; }
.po-pair > input, .po-pair > select { flex: 1; min-width: 0; }
.po-pair #po-date { flex: 0 0 170px; }
.po-l { color: var(--muted); font-size: 13px; white-space: nowrap; }
.po-short { max-width: 240px; }
.po-amt { gap: 8px; }
.po-amt input { max-width: 200px; }
.po-amt .check { color: var(--muted); font-size: 13px; text-align: left; }
.po-docbox { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: #fafbf8; margin-top: 4px; }
.po-docbox summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 2px 0; }
.po-docbox[open] summary { margin-bottom: 8px; }
.po-rows { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.po-rows th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.po-rows th.r { text-align: right; }
.po-rows td { padding: 4px 4px; border-bottom: 1px solid #eef0ea; }
.po-rows input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; }
.po-rows .po-n, .po-rows .po-u, .po-rows .po-n2 { width: 100%; }
.po-rows .po-ra { padding-right: 8px; font-variant-numeric: tabular-nums; }
.po-docf { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.po-docf label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); text-align: left; }
.po-docf input { min-width: 0; }
@media (max-width: 640px) { .po-docf { grid-template-columns: 1fr; } .po-pair { flex-wrap: wrap; } .po-pair #po-date { flex: 1 1 100%; } }
/* 見積書の「丸印」(2026-10-23) */
.func-kind { display: flex; gap: 6px; }
.func-kind .seg { overflow: hidden; }
.pr-round { margin-left: 8px; }
/* ドラッグで動かせる印 (2026-10-23 寺井さん): 数字の横に「⠿」。つかめる所だと分かるように */
td.no[draggable="true"] { white-space: nowrap; }
td.no[draggable="true"]::before { content: "⠿"; display: inline-block; margin-right: 3px; color: #8f9a8d; font-size: 12px; line-height: 1; vertical-align: -1px; }
td.no[draggable="true"]:hover::before { color: var(--brand); }
td.no[draggable="true"]:hover { background: #eef5ee; }
.sc-chip[draggable="true"]::before { content: "⠿"; float: right; margin-left: 4px; color: #a9b3a7; font-size: 11px; line-height: 1.35; }
.sc-chip[draggable="true"]:hover::before { color: var(--brand); }
/* 発注台帳: 期間と、発注一覧の印刷 (2026-10-23) */
.po-period { gap: 6px; align-items: center; flex-wrap: wrap; }
.po-period input[type=date] { width: 150px; }
.po-paper { width: 210mm; min-height: 297mm; padding: 12mm 12mm; background: #fff; color: #1b2420; font-size: 9.5pt; box-sizing: border-box; }
.po-ph { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #2e7d32; padding-bottom: 2mm; margin-bottom: 3mm; }
.po-ph h1 { font-size: 16pt; letter-spacing: .3em; margin: 0; }
.po-pmeta { text-align: right; font-size: 9pt; }
.po-pcond { margin: 0 0 3mm; font-size: 9.5pt; }
.po-ptable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.po-ptable td, .po-ptable th { word-break: break-all; font-size: 8.8pt; }
.po-ptable thead th { white-space: nowrap; font-size: 9pt; }
.po-ptable th, .po-ptable td { border: 1px solid #888; padding: 1.2mm 1.6mm; vertical-align: top; }
.po-ptable thead th { background: #eef4ec; font-weight: 600; }
.po-ptable tfoot th, .po-ptable tfoot td { background: #f6f8f4; }
.po-ptable .r { text-align: right; } .po-ptable .c { text-align: center; }
.po-ptable tr.po-pcancel td { color: #999; text-decoration: line-through; }
.po-ptable thead { display: table-header-group; }
.po-ptable tr { break-inside: avoid; }
/* テスト環境の印 (staging.boymeetsmall.com) */
.proto-badge.staging-badge { background: #d93025; color: #fff; border-color: #d93025; }
/* ご契約・お支払い (subscription.js、テスト環境) */
.sub-test { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: #fdecec; border: 1px solid #f3b4ae; font-size: 13px; }
.sub-plans { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sub-plan { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.sub-plan input { align-self: flex-start; }
.sub-plan em { font-style: normal; font-weight: 700; color: var(--brand); }
.sub-opts { display: flex; flex-direction: column; gap: 4px; }
.sub-total { margin: 12px 0; font-size: 15px; }

/* css/setup.css */
/* 初期設定ウィザード・機能のオン/オフ・ヘッダーの会社名 */

/* 機能のオン/オフ */
[hidden] { display: none !important; }
.est-tables.single { grid-template-columns: 1fr; max-width: 1000px; }
.est-top.no-similar { grid-template-columns: minmax(360px, 1.15fr) minmax(300px, .9fr); }

/* ヘッダー: 会社名・初期設定 */
.co-badge {
  margin-left: auto; font-size: 13px; font-weight: 700; color: var(--brand-dark); padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.co-badge:not([hidden]) ~ .proto-badge { margin-left: 8px; }
.nav a.todo { position: relative; }
.nav a.todo::after { content: ""; position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--ng); }

/* ---------- ウィザードの枠 ---------- */
.setup { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.setup-nav { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 76px; }
.setup-nav-head { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); background: var(--brand-soft); }
.setup-nav-head b { display: block; font-size: 16px; }
.setup-step { display: flex; gap: 10px; align-items: center; padding: 10px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line-soft); border-left: 4px solid transparent; }
.setup-step:hover { background: #f7fbf3; }
.setup-step.on { background: var(--brand-soft); border-left-color: var(--brand); }
.setup-step small { display: block; color: var(--muted); font-size: 11px; }
.setup-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #e6ebe6; font-weight: 700; font-size: 13px; flex: none; }
.setup-step.on .setup-num { background: var(--brand); color: #fff; }
.setup-step.done:not(.on) .setup-num { background: #cfe8d0; color: var(--brand-dark); }
.setup-main { min-width: 0; }
.setup-head { margin-bottom: 10px; }
.setup-head h2 { margin: 2px 0 0; font-size: 22px; }
.setup-foot { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.setup-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.setup-card h3 { margin: 0 0 12px; font-size: 15px; }
.setup-card h3 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.setup-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.warn-card { background: #fff8e6; border-color: #f0d27a; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.radio-row { display: flex; flex-wrap: wrap; }
.ok-text { color: var(--ok); font-weight: 600; }

/* ---------- ロゴ・印鑑 ---------- */
.img-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.img-box {
  width: 120px; height: 120px; border: 1px dashed var(--line); border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  background-color: #fff;
  background-image: linear-gradient(45deg, #f1f1f1 25%, transparent 25%, transparent 75%, #f1f1f1 75%), linear-gradient(45deg, #f1f1f1 25%, transparent 25%, transparent 75%, #f1f1f1 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.img-box.wide { width: 280px; height: 100px; }
.img-box { overflow: hidden; }
.img-box img { width: 100%; height: 100%; padding: 6px; box-sizing: border-box; object-fit: contain; display: block; }
.img-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.seal-table td { vertical-align: middle; }
.seal-thumb { width: 44px; height: 44px; object-fit: contain; display: block; }
.plain-input { border-color: transparent; background: transparent; width: 100%; max-width: 220px; }
.plain-input:hover { border-color: var(--line); }
.seal-maker { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.seal-maker img { width: 120px; height: 120px; }

/* ---------- 見積書のデザイン ---------- */
.tpl-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.tpl-card { border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px; font: inherit; color: inherit; }
.tpl-card:hover { border-color: #9cc0a0; }
.tpl-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl-name { display: flex; align-items: center; gap: 8px; }
.badge-on { background: var(--brand); color: #fff; }
/* A4 の紙 (210mm) を枠の幅に合わせて縮小表示する */
.tpl-thumb, .tpl-big { width: 100%; overflow: hidden; position: relative; border: 1px solid var(--line-soft); background: #fff; container-type: inline-size; }
.tpl-thumb { aspect-ratio: 210 / 150; }
.tpl-big { max-width: 640px; aspect-ratio: 210 / 297; margin: 0 auto; }
.tpl-thumb .paper, .tpl-big .paper { position: absolute; top: 0; left: 0; transform-origin: top left; transform: scale(calc(100cqw / 210mm)); box-shadow: none; pointer-events: none; }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.swatch-custom { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: 6px; }
.swatch-custom input { width: 40px; height: 32px; padding: 0; border: 0; background: none; }

/* ---------- 使う機能 ---------- */
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.feat-card { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.feat-card.on { border-color: #9cc0a0; background: #f7fbf3; }
.feat-card input { display: none; }
.feat-card small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.6; }
.feat-switch { flex: none; width: 40px; height: 22px; border-radius: 11px; background: #cfd5cf; position: relative; margin-top: 2px; transition: background .2s; }
.feat-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.feat-card.on .feat-switch { background: var(--brand); }
.feat-card.on .feat-switch::after { left: 21px; }

/* ---------- 番号・呼び方 ---------- */
.no-formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 8px; }
.no-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.no-card.on { border-color: var(--brand); background: var(--brand-soft); }
.no-card input { display: none; }
.no-card code { font-size: 15px; color: var(--brand-dark); }

/* ---------- データ取り込み・確認 ---------- */
.data-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 14px; }
.data-card-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.dc-head { display: flex; justify-content: space-between; align-items: center; }
.dc-count { font-weight: 700; color: var(--brand-dark); }
.dc-count.zero { color: var(--ng); }
.dc-actions { display: flex; gap: 6px; }
.check-table { border-collapse: collapse; width: 100%; }
.check-table th, .check-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.check-table th { width: 170px; font-weight: 600; }
.ck { width: 30px; text-align: center !important; font-weight: 700; }
.ck.ok { color: var(--ok); }
.ck.ng { color: var(--ng); }
.ck.opt { color: var(--muted); }

@media (max-width: 900px) {
  .setup { grid-template-columns: 1fr; }
  .setup-nav { position: static; }
  .tpl-cards, .setup-grid-2 { grid-template-columns: 1fr; }
}
.seal-cell { white-space: nowrap; }
.seal-cell .seal-thumb { display: inline-block; vertical-align: middle; width: 36px; height: 36px; margin-right: 6px; }
.seal-cell .btn { margin-right: 4px; }
.sm-fonts { display: flex; gap: 8px; flex-wrap: wrap; }
.sm-fonts button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 8px; cursor: pointer; display: grid; justify-items: center; gap: 2px; font-size: 12px; }
.sm-fonts button img { width: 48px; height: 48px; }
.sm-fonts button.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
/* 有料オプション (お客様の画面では切り替えられない) */
.feat-card.locked { cursor: default; opacity: .75; }
.feat-lock { font-style: normal; color: var(--warn); font-weight: 600; }
.img-box.mascot { width: 120px; height: 140px; }

/* css/print.css */
/* 帳票 (A4 縦)。サイズは mm 指定 */

/* 用紙の端は少し空ける (2026-10-16): 余白 0 だと、端の数mmを印刷できないプリンター (FUJIFILM Apeos など) で
   Chrome が印刷できる範囲に合わせてページを分け、表の続きと白紙が2枚目・3枚目に出た。
   紙 (.paper) は印刷のときだけその分小さくし、内側の余白も同じだけ減らすので、紙の上の位置は変わらない */
@page { size: A4 portrait; margin: 6mm 5mm; }

.paper {
  width: 210mm; min-height: 297mm; padding: 14mm 14mm 12mm; background: #fff; color: #000;
  box-shadow: 0 2px 14px rgba(0,0,0,.15); font-size: 10pt; line-height: 1.45;
  font-family: "BIZ UDPMincho", "Yu Mincho", "MS PMincho", serif;
  font-variant-numeric: tabular-nums;
}
.paper table { border-collapse: collapse; }

/* ---- 御見積書 ---- */
.d-title {
  text-align: center; font-size: 22pt; letter-spacing: .6em; margin: 0 0 8mm; padding-bottom: 1.5mm;
  border-bottom: 3px double #000; width: 80mm; margin-left: auto; margin-right: auto; font-weight: 700;
}
.d-head { display: flex; justify-content: space-between; gap: 8mm; }
.d-left { flex: 1; }
.d-right { width: 74mm; }
.d-to { display: flex; align-items: flex-end; gap: 4mm; border-bottom: 1.5px solid #000; padding-bottom: 1mm; margin-bottom: 5mm; min-height: 10mm; }
.d-to-name { font-size: 15pt; font-weight: 700; flex: 1; }
.d-onchu { font-size: 12pt; }
.d-kv { width: 100%; }
.d-kv th { text-align: left; font-weight: 400; width: 26mm; padding: 1.2mm 0; border-bottom: .5px solid #888; white-space: nowrap; }
.d-kv td { padding: 1.2mm 2mm; border-bottom: .5px solid #888; }
.d-meta { margin-left: auto; margin-bottom: 3mm; }
.d-meta th { font-weight: 400; text-align: left; padding: .5mm 3mm 0 0; }
.d-meta td { text-align: right; padding: .5mm 0; min-width: 32mm; border-bottom: .5px solid #888; }
.d-company { position: relative; font-size: 8.5pt; line-height: 1.6; padding: 1mm 0 2mm; }
.d-co-name { font-size: 13pt; font-weight: 700; letter-spacing: .05em; font-family: "BIZ UDPGothic", "Yu Gothic", sans-serif; }
.d-co-rep { font-size: 10pt; margin: .5mm 0; }
.d-seal { position: absolute; right: 0; top: -1mm; width: 21mm; height: 21mm; object-fit: contain; opacity: .9; }
.d-stamps { margin-left: auto; margin-top: 1mm; }
.d-stamps th, .d-stamps td { border: .5px solid #000; width: 17mm; text-align: center; font-weight: 400; font-size: 8pt; }
.d-stamps td { height: 15mm; }
.d-staff { font-size: 7.5pt; vertical-align: bottom; }

.d-grand { display: flex; align-items: baseline; gap: 6mm; margin: 6mm 0 4mm; padding: 2mm 4mm; border: 1.5px solid #000; }
.d-grand-label { font-size: 12pt; letter-spacing: .3em; }
.d-grand-val { font-size: 18pt; font-weight: 700; }
.d-grand-note { margin-left: auto; font-size: 8.5pt; }

.d-lines { width: 100%; table-layout: fixed; }
.d-lines th, .d-lines td { border: .5px solid #000; padding: 1mm 1.5mm; height: 7.2mm; font-size: 9pt; overflow: hidden; }
.d-lines thead th { background: #eee; font-weight: 400; text-align: center; }
.d-lines tfoot th { font-weight: 400; text-align: center; letter-spacing: .2em; background: #f6f6f6; }
.d-lines .r { text-align: right; }
.d-lines .c { text-align: center; }
/* 長い摘要: 文字を小さくして、行が縦に伸びすぎないように (print.js の remCls) */
.d-lines td.rm-s { font-size: 8pt; line-height: 1.25; }
.d-lines td.rm-xs { font-size: 7pt; line-height: 1.2; }
.d-lines td.rm-xxs { font-size: 6pt; line-height: 1.15; }
.d-total td, .d-total th { font-weight: 700 !important; border-top: 1.5px solid #000; }
.d-disc td { color: #b00000; }
.d-cont-note { text-align: right !important; font-size: 8.5pt; letter-spacing: 0 !important; background: #fff !important; border-left: 0 !important; border-right: 0 !important; border-bottom: 0 !important; }
.d-bdref { font-size: 7.5pt; color: #444; margin-left: 2mm; }
.d-notes { margin-top: 4mm; border: .5px solid #000; }
.d-notes-h { padding: .8mm 2mm; border-bottom: .5px solid #000; background: #f6f6f6; font-size: 9pt; }
.d-notes-b { padding: 2mm; min-height: 20mm; font-size: 9pt; }
.d-bd-title { text-align: center; font-size: 16pt; letter-spacing: .6em; margin: 0 0 4mm; }
.d-bd-sub { display: flex; justify-content: space-between; gap: 4mm; border-bottom: 1px solid #000; padding-bottom: 1mm; margin-bottom: 3mm; }

/* ---- 売上伝票 ---- */
.doc-slip { font-family: "BIZ UDPGothic", "Yu Gothic", sans-serif; font-size: 9.5pt; }
.s-top { display: flex; align-items: center; gap: 6mm; margin-bottom: 4mm; }
.s-title { font-size: 18pt; letter-spacing: .5em; margin: 0; border-bottom: 3px double #000; }
.s-internal { border: 1px solid #000; padding: .5mm 3mm; font-size: 9pt; }
.s-date { margin-left: auto; }
.s-info { width: 100%; margin-bottom: 4mm; }
.s-info th { width: 24mm; text-align: left; font-weight: 400; background: #f2f2f2; border: .5px solid #000; padding: 1.2mm 2mm; white-space: nowrap; }
.s-info td { border: .5px solid #000; padding: 1.2mm 2mm; }
.s-big { font-size: 11pt; font-weight: 700; }
.s-band { background: #333; color: #fff; padding: .8mm 3mm; letter-spacing: .4em; font-weight: 700; margin-top: 3mm; }
.s-grid { width: 100%; table-layout: fixed; }
.s-grid th, .s-grid td { border: .5px solid #000; padding: .8mm 1.5mm; height: 6.6mm; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.s-grid thead th { background: #f2f2f2; font-weight: 400; }
.s-grid tfoot th { background: #f2f2f2; font-weight: 400; text-align: left; }
.s-grid .r { text-align: right; }
.s-grid .c { text-align: center; }
.s-calc { color: #555; font-size: 8pt; margin-left: 1.5mm; }
.s-strong { font-weight: 700; }
.s-profit { width: 100%; margin-top: 4mm; }
.s-profit th { background: #f2f2f2; border: .5px solid #000; font-weight: 400; padding: 1.5mm; width: 14mm; }
.s-profit td { border: .5px solid #000; padding: 1.5mm 2mm; text-align: right; }


/* ---- ロゴ・印鑑 ---- */
.d-logo { display: block; max-height: 12mm; max-width: 50mm; object-fit: contain; margin-bottom: 1mm; }
.d-seal-round { position: absolute; right: 23mm; top: 3mm; width: 19mm; height: 19mm; object-fit: contain; opacity: .9; }
.d-stamp-img { width: 13mm; height: 13mm; object-fit: contain; display: block; margin: 0 auto; }
.d-stamps td { vertical-align: middle; text-align: center; }

/* ---- テンプレート: モダン (ロゴ入りの帯・テーマ色) ---- */
.tpl-modern { font-family: 'BIZ UDPGothic', 'Yu Gothic', sans-serif; }
.tpl-modern .d-mhead { display: flex; align-items: center; justify-content: space-between; border-bottom: 1.6mm solid var(--doc-accent); padding-bottom: 3mm; margin-bottom: 6mm; min-height: 14mm; }
.tpl-modern .d-mlogo { max-height: 16mm; max-width: 80mm; object-fit: contain; }
.tpl-modern .d-title { border: 0; width: auto; margin: 0; padding: 0; letter-spacing: .35em; color: var(--doc-accent); font-size: 24pt; }
.tpl-modern .d-to { border-bottom: 1.5px solid var(--doc-accent); }
.tpl-modern .d-grand { border: 0; border-left: 2mm solid var(--doc-accent); background: var(--doc-accent-soft); }
.tpl-modern .d-lines thead th { background: var(--doc-accent); color: #fff; border-color: var(--doc-accent); }
.tpl-modern .d-lines tfoot th { background: var(--doc-accent-soft); }
.tpl-modern .d-total th, .tpl-modern .d-total td { color: var(--doc-accent); border-top-color: var(--doc-accent); }
.tpl-modern .d-notes-h { background: var(--doc-accent-soft); }
.tpl-modern .d-bd-title { color: var(--doc-accent); }

/* ---- テンプレート: シンプル (罫線少なめ・左寄せ) ---- */
.tpl-simple { font-family: 'BIZ UDPGothic', 'Yu Gothic', sans-serif; }
.tpl-simple .d-title { border: 0; width: auto; margin: 0 0 8mm; text-align: left; letter-spacing: .12em; font-size: 18pt; font-weight: 600; }
.tpl-simple .d-lines th, .tpl-simple .d-lines td { border-left: 0; border-right: 0; border-color: #c8c8c8; }
.tpl-simple .d-lines thead th { background: none; border-bottom: 1px solid #000; border-top: 1px solid #000; }
.tpl-simple .d-lines tfoot th { background: none; text-align: right; }
.tpl-simple .d-grand { border: 0; border-bottom: 1.5px solid #000; padding-left: 0; }
.tpl-simple .d-notes { border: 0; border-top: .5px solid #c8c8c8; }
.tpl-simple .d-notes-h { background: none; border: 0; padding-left: 0; font-weight: 600; }
.tpl-simple .d-kv th, .tpl-simple .d-kv td { border-bottom-color: #ddd; }

/* ---- 導入ヒアリングシート ---- */
.sheet { font-family: "BIZ UDPGothic", "Yu Gothic", sans-serif; font-size: 9.5pt; }
.sh-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #2f7d32; padding-bottom: 2mm; margin-bottom: 4mm; }
.sh-head h1 { margin: 0; font-size: 17pt; }
.sheet h2 { font-size: 11pt; margin: 4mm 0 1.5mm; color: #1b5e20; }
.sh-table { width: 100%; }
.sh-table th { width: 38mm; text-align: left; font-weight: 400; background: #f2f5ef; border: .5px solid #999; padding: 1.2mm 2mm; vertical-align: top; }
.sh-table td { border: .5px solid #999; padding: 1.2mm 2mm; }
.sh-logo { max-height: 12mm; max-width: 60mm; }
.sh-seal { width: 14mm; height: 14mm; object-fit: contain; }
.sh-staff { display: inline-flex; align-items: center; gap: 1mm; margin: 0 3mm 1mm 0; }
.sh-staff img { width: 7mm; height: 7mm; object-fit: contain; }
.sh-color { display: inline-block; width: 4mm; height: 4mm; border-radius: 50%; vertical-align: middle; }
.sh-feat { display: inline-block; margin: 0 3mm 1mm 0; color: #999; }
.sh-feat.on { color: #000; }

@media print {
  .paper-wrap { zoom: 1 !important; } /* スマホで縮めて見せていても、印刷は原寸 */
  body { background: #fff; }
  .no-print, .app-head, .print-bar { display: none !important; }
  /* スマホ用の見た目 (mobile.css) の「下のタブの分の余白 84px」などが、印刷でも効くことがあった
     (プリンターによって印刷の幅が狭いと判定され、余白が2枚目の白紙になった)。印刷では必ず消す */
  main, #view { padding: 0 !important; margin: 0 !important; max-width: none !important; min-height: 0 !important; }
  .nav { display: none !important; }
  .pdf-render, .update-bar, #chat-root, .tour-bubble, .tour-spot, #toast-root, #modal-root { display: none !important; } /* 画面だけのもの (見えない測定用の枠・更新のお知らせなど) は印刷に出さない */
  .paper-wrap { gap: 0; display: block; }
  /* 用紙の余白 (上下 6mm・左右 5mm) の内側に、1枚ちょうどに収める。高さは余白の内側 (285mm) より 1mm 小さく
     中身の位置は画面と同じ: 余白 + 内側の余白 = 上 14mm・左右 14mm・下 12mm */
  html, body { margin: 0 !important; padding: 0 !important; height: auto !important; min-height: 0 !important; }
  /* 改ページは「2枚目からの紙の前」で入れる (最後の紙のあとに改ページを入れないので、白紙が付かない) */
  .paper { box-shadow: none; margin: 0 !important; min-height: 0; width: 200mm; height: 283mm; padding: 8mm 9mm 5mm; overflow: hidden; break-after: auto; page-break-after: auto; }
  .paper + .paper { break-before: page; page-break-before: always; }
  .paper-wrap + *, .paper-wrap ~ * { display: none !important; }
  .paper.long { height: auto; overflow: visible; }
  .paper.long tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- 注文書・注文請書 (オプション) ---- */
.o-lead { margin: 0 0 3mm; font-size: 9.5pt; }
.o-model { margin-left: 2mm; font-size: 8pt; color: #444; }
.doc-accept { position: relative; }
/* 注文請書: 収入印紙の枠を題名と同じ行の左に置く (宛名に重ならないように。右は同じ幅のすき間で題名を真ん中に) */
.o-title-row { display: flex; align-items: center; gap: 4mm; margin-bottom: 7mm; }
.o-title-row .d-title { flex: 1; margin-top: 0; margin-bottom: 0; }
.o-title-row { justify-content: space-between; }
.tpl-standard .o-title-row .d-title { flex: 0 0 80mm; margin-left: 0; margin-right: 0; }
.o-stamp-box, .o-stamp-space { flex: none; width: 18mm; height: 20mm; }
.o-stamp-box { border: .5px dashed #888; color: #999; font-size: 7.5pt; text-align: center; padding-top: 6mm; line-height: 1.4; }
.o-blank-date { letter-spacing: .1em; }
.o-sign { margin-top: 4mm; font-size: 9pt; }
.o-sign-row { display: flex; align-items: flex-end; gap: 2mm; margin-bottom: 4mm; }
.o-sign-row > span:first-child { width: 14mm; white-space: nowrap; }
.o-line { flex: 1; border-bottom: .5px solid #000; min-height: 6mm; padding-left: 1mm; }
.o-name { font-weight: 700; }
.o-seal { width: 10mm; height: 10mm; border: .5px solid #888; border-radius: 50%; color: #888; font-size: 8pt; display: flex; align-items: center; justify-content: center; }

/* ---- 納品書 (オプション) ---- */
.dv-foot { display: flex; gap: 4mm; align-items: stretch; margin-top: 4mm; }
.dv-foot .d-notes { flex: 1; margin-top: 0; }
.dv-receipt { width: 28mm; border: .5px solid #000; display: flex; flex-direction: column; }
.dv-receipt-h { padding: .8mm 2mm; border-bottom: .5px solid #000; background: #f6f6f6; font-size: 9pt; text-align: center; }
.dv-receipt-b { flex: 1; min-height: 22mm; }

/* ---- 「PDF」ボタン: 見積入力などの画面から、帳票だけを印刷の画面に出す (送信先「PDFに保存」で保存) ---- */
@media screen { .pdf-print { position: fixed; left: -10000px; top: 0; width: 210mm; } }
@media print {
  body.pdf-printing > *:not(.pdf-print) { display: none !important; }
  body.pdf-printing .pdf-print { position: static; width: auto; }
}

/* 明細が多いとき、行を少し詰めて1枚に収める (print.js が実際に測って、入らないときだけ付ける) */
.d-compact .d-lines th, .d-compact .d-lines td { height: 5.6mm; padding: .4mm 1.5mm; font-size: 8.5pt; }
.d-compact .d-grand { margin: 4mm 0 3mm; }
.d-compact .d-notes { margin-top: 3mm; }
.d-compact .d-notes-b { min-height: 12mm; }
/* 請求書: お振込先と備考を横に並べる (dv-foot を使う) */
.doc-invoice .dv-foot .d-notes { flex: 1; }
.doc-invoice .iv-nobank { color: #999; font-size: 8pt; }
.doc-invoice .iv-fee { margin-top: 2mm; font-size: 8pt; }
/* 請求書: 行ごとの注文番号・消費税の注意 */
.iv-row-po { font-size: 7.5pt; color: #444; }
.iv-taxnote td { font-size: 7pt; color: #555; border: 0 !important; padding-top: 1mm; text-align: left; }
/* 会社のキャラクター (見積書の1枚目に重ねて置く。2026-10-19) */
.paper.doc-est { position: relative; }
.d-mascot { position: absolute; width: auto; z-index: 1; pointer-events: none; }
.d-mascot-tl { top: 7mm; left: 8mm; }
.d-mascot-tr { top: 7mm; right: 9mm; }
.d-mascot-br { bottom: 7mm; right: 9mm; }

/* css/mobile.css */
/* スマートフォン向け (幅 720px 以下)。パソコンの画面には影響しない
   - メニューは画面下のタブに
   - 見積の明細・原価は1行ずつカードにして、横にはみ出さないようにする
   - 見積台帳の行もカードに。マスタの表は表の中だけ横に動かせる */

@media (max-width: 720px) {
  /* iPhone で入力欄を押したときに画面が拡大されないよう、文字は 16px 以上 */
  input, select, textarea { font-size: 16px; }

  /* ---- ヘッダーと下のタブ ---- */
  .app-head { gap: 8px; padding: 4px 12px; flex-wrap: nowrap; }
  .brand img { height: 34px; }
  .co-badge { font-size: 11px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .proto-badge { font-size: 11px; padding: 2px 8px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; /* 出ているメニューの数で等分 (請求・売上があると6つ) */
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .nav a { padding: 8px 1px; border-radius: 8px; font-size: 11px; line-height: 1.25; text-align: center; letter-spacing: -.02em; display: flex; align-items: center; justify-content: center; min-height: 44px; word-break: keep-all; overflow-wrap: anywhere; }
  .nav a.on { background: var(--brand-soft); color: var(--brand-dark); }
  .nav a.todo::after { right: 6px; top: 6px; }
  main { padding: 10px 12px calc(84px + env(safe-area-inset-bottom, 0px)); }
  body.login-mode main { padding-bottom: 24px; }
  body.printing-view .nav { display: none; }
  .account { gap: 4px; }
  .sync { font-size: 11px; padding: 2px 6px; }
  .acct-btn { padding: 4px 10px; font-size: 13px; }
  .toast-root, #toast-root { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }

  .page-head h2 { font-size: 18px; }
  .form-grid > * { min-width: 0; }
  .form-grid input, .form-grid select, .form-grid textarea { width: 100%; max-width: 100%; }
  .card { min-width: 0; }

  /* ---- 見積入力: 明細・掛け率・値引き・原価を1行ずつカードに ---- */
  .est-tables { overflow: visible; }
  .est-tables .grid, .est-tables .grid tbody, .est-tables .grid tfoot,
  .bd-grid, .bd-grid tbody, .bd-grid tfoot { display: block; width: 100%; }
  .est-tables .grid colgroup, .est-tables .grid thead, .bd-grid colgroup, .bd-grid thead { display: none; }
  .est-tables .grid tbody tr, .bd-grid tbody tr {
    display: grid; gap: 4px 6px; align-items: end;
    padding: 8px; margin-bottom: 8px; background: #fff;
    border: 1px solid var(--line); border-radius: 8px;
  }
  .est-tables .grid td, .bd-grid td { display: block; border: 0; height: auto; padding: 0; min-width: 0; background: none; }
  .est-tables .grid td input, .bd-grid td input { height: 38px; border: 1px solid var(--line-soft); border-radius: 6px; background: #fff; padding: 4px 5px; }
  .est-tables .grid td.no, .bd-grid td.no { align-self: center; font-size: 13px; font-weight: 700; }
  .est-tables .grid td.amt, .bd-grid td.amt { text-align: right; font-size: 15px; padding: 0 2px 8px; background: none; }
  .est-tables .grid td.ops, .bd-grid td.ops { display: flex; justify-content: flex-end; gap: 4px; align-self: center; overflow: visible; }
  .est-tables .grid td.ops .mini, .bd-grid td.ops .mini { min-width: 34px; height: 32px; font-size: 13px; }
  /* 欄の名前 (表の見出しの代わり) */
  .grid td[data-cap]::before { content: attr(data-cap); display: block; font-size: 10.5px; color: var(--muted); margin: 0 0 2px 2px; }

  /* 提出金額の明細・内訳 */
  #sales-body tr, .bd-normal tr {
    grid-template-columns: 26px 1fr 1fr 1.3fr 1.3fr;
    grid-template-areas: "no name name name name" ". qty unit price amt" ". remark remark ops ops";
  }
  #sales-body td:nth-child(1), .bd-normal td:nth-child(1) { grid-area: no; }
  #sales-body td:nth-child(2), .bd-normal td:nth-child(2) { grid-area: name; }
  #sales-body td:nth-child(3), .bd-normal td:nth-child(3) { grid-area: qty; }
  #sales-body td:nth-child(4), .bd-normal td:nth-child(4) { grid-area: unit; }
  #sales-body td:nth-child(5), .bd-normal td:nth-child(5) { grid-area: price; }
  #sales-body td:nth-child(6), .bd-normal td:nth-child(6) { grid-area: amt; }
  #sales-body td:nth-child(7), .bd-normal td:nth-child(7) { grid-area: remark; }
  #sales-body td:nth-child(8), .bd-normal td:nth-child(8) { grid-area: ops; }

  /* 掛け率の行 */
  #rate-body tr, .bd-rate tr {
    grid-template-columns: 26px 1.4fr 1.3fr 1.3fr;
    grid-template-areas: "no name name name" ". rate price amt" ". remark remark ops";
  }
  #rate-body td:nth-child(1), .bd-rate td:nth-child(1) { grid-area: no; }
  #rate-body td:nth-child(2), .bd-rate td:nth-child(2) { grid-area: name; }
  #rate-body td:nth-child(3), .bd-rate td:nth-child(3) { grid-area: rate; align-self: center; text-align: left; }
  #rate-body td:nth-child(4), .bd-rate td:nth-child(4) { grid-area: price; }
  #rate-body td:nth-child(5), .bd-rate td:nth-child(5) { grid-area: amt; }
  #rate-body td:nth-child(6), .bd-rate td:nth-child(6) { grid-area: remark; }
  #rate-body td:nth-child(7), .bd-rate td:nth-child(7) { grid-area: ops; }
  .rate-cell input { height: 34px !important; }

  /* 出精値引き */
  #disc-body tr, .bd-disc tr {
    grid-template-columns: 26px minmax(0, 1fr) auto;
    grid-template-areas: "no name name" ". disc disc" ". amt amt" ". remark ops";
    align-items: center; row-gap: 6px;
  }
  #disc-body td:nth-child(1), .bd-disc td:nth-child(1) { grid-area: no; }
  #disc-body td:nth-child(2), .bd-disc td:nth-child(2) { grid-area: name; }
  #disc-body td:nth-child(3), .bd-disc td:nth-child(3) { grid-area: disc; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  #disc-body td:nth-child(4), .bd-disc td:nth-child(4) { grid-area: amt; }
  #disc-body td:nth-child(5), .bd-disc td:nth-child(5) { grid-area: remark; }
  #disc-body td:nth-child(6), .bd-disc td:nth-child(6) { grid-area: ops; }
  .disc-cell { justify-content: flex-start; text-align: left; flex-wrap: nowrap !important; padding: 0 !important; }
  .disc-cell input { width: 120px !important; height: 38px !important; flex: none; }
  .disc-cell span { margin: 0 4px 0 2px; }
  .disc-cell .mini { height: 32px; padding: 0 8px; font-size: 12px; }
  #disc-body td.disc-amt, .bd-disc td.disc-amt { text-align: right; font-weight: 700; padding: 0 2px !important; }
  #disc-body td:nth-child(5) input, .bd-disc td:nth-child(5) input { width: 100%; }
  #disc-body td:nth-child(5) input::placeholder, .bd-disc td:nth-child(5) input::placeholder { color: #aaa; }

  /* 仕入金額 (原価) */
  #cost-body tr {
    grid-template-columns: 26px 1fr 1fr .7fr 1.2fr;
    grid-template-areas: "no supplier supplier supplier supplier" ". content content model model" ". list cost qty amt" ". memo memo memo ops";
  }
  #cost-body td:nth-child(1) { grid-area: no; }
  #cost-body td:nth-child(2) { grid-area: supplier; }
  #cost-body td:nth-child(3) { grid-area: content; }
  #cost-body td:nth-child(4) { grid-area: model; }
  #cost-body td:nth-child(5) { grid-area: list; }
  #cost-body td:nth-child(6) { grid-area: cost; }
  #cost-body td:nth-child(7) { grid-area: qty; }
  #cost-body td:nth-child(8) { grid-area: amt; }
  #cost-body td:nth-child(9) { grid-area: memo; }
  #cost-body td:nth-child(10) { grid-area: ops; }
  #cost-body tr.linked { border-left: 4px solid var(--cost); }

  /* 小計・粗利 */
  .est-tables .grid tfoot tr, .bd-grid tfoot tr { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; }
  .est-tables .grid tfoot td, .bd-grid tfoot td { display: block; border: 0; padding: 0; }
  .est-tables .grid tfoot td:empty, .bd-grid tfoot td:empty { display: none; }
  .t-sales tfoot tr { background: var(--sales); }
  .t-cost tfoot tr { background: var(--cost); color: #fff; }
  .t-head { font-size: 14px; }
  .t-head small { display: block; }
  .rate-bar { flex-wrap: wrap; }
  .row-tools { flex-wrap: wrap; }

  /* 内訳書の画面は全面に */
  .modal-back { padding: 0; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: 100%; border-radius: 0; }
  .modal-body { padding: 12px 10px; }
  .bd-grid tbody tr { padding: 6px; }

  /* ---- 見積台帳: 行をカードに ---- */
  .site-layout { grid-template-columns: minmax(0, 1fr); }
  .site-layout > * { min-width: 0; }
  .site-list { max-height: none; overflow: visible; position: static; } /* スマホは一覧をそのまま縦に (小さな枠の中でスクロールしない)。押すと下の見積へ移る */
  .site-back { display: inline-flex !important; }
  .site-detail-head { gap: 10px; padding: 10px 12px; }
  .site-stats { gap: 12px; }
  #ls-body table.list, #ls-body table.list tbody, #ls-body table.list tfoot { display: block; width: 100%; border: 0; background: none; }
  #ls-body table.list thead { display: none; }
  #ls-body table.list tbody tr {
    display: grid; gap: 2px 10px; padding: 10px 12px; margin-bottom: 8px;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "pick subj amt" "pick cust state" "pick date ops";
  }
  #ls-body table.list td { display: block; padding: 0; border: 0; min-width: 0; width: auto; max-width: none; }
  #ls-body .c-pick { grid-area: pick; width: auto; padding-right: 2px; }
  #ls-body thead .c-pick { display: none; }
  #ls-body .c-subj { grid-area: subj; font-size: 15px; }
  #ls-body .c-cust { grid-area: cust; font-size: 12px; }
  #ls-body .c-date { grid-area: date; font-size: 12px; color: var(--muted); }
  #ls-body .c-date .sub { display: inline; margin-left: 8px; }
  #ls-body .c-amt { grid-area: amt; font-weight: 700; font-size: 15px; }
  #ls-body .c-state { grid-area: state; text-align: right; }
  #ls-body .c-ops { grid-area: ops; }
  #ls-body table.list tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: flex-end; padding: 8px 12px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
  #ls-body table.list tfoot td { border: 0; background: none; padding: 0; }
  #ls-body table.list tfoot td:empty { display: none; }

  /* ---- そのほかの表 (品目・マスタ・取り込み): 表の中だけ横に動かす ---- */
  table.list:not(#ls-body table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .list.editable input { min-width: 110px; }
  .toolbar .search, .imp-q { min-width: 0; width: 100%; flex: 1 1 100%; }
  .toolbar select { flex: 1 1 40%; min-width: 0; }
  .pick-bar { top: 52px; }
  .update-bar { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; justify-content: center; text-align: center; }
  .toolbar input[type=date] { flex: 1 1 38%; min-width: 0; }
  .toolbar .btn { max-width: 100%; white-space: normal; }
  /* ---- 見積入力: タブで「情報」「提出金額」「仕入金額」に分ける (2026-10-18) ---- */
  .est { padding-bottom: 64px; }
  .est-mtabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; position: sticky; top: 45px; z-index: 19; margin: -10px -12px 10px; padding: 6px 8px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.05); }
  .est-mtabs [hidden] { display: none; }
  .est-mtabs button { border: 0; background: #f1f4ef; color: var(--ink); border-radius: 8px; padding: 10px 4px; font: inherit; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 5px; }
  .est-mtabs button b { min-width: 18px; padding: 0 5px; border-radius: 9px; background: #fff; color: var(--brand-dark); font-size: 11px; line-height: 18px; }
  .est-mtabs button b:empty { display: none; }
  .est[data-mt="info"] .est-mtabs [data-mt="info"], .est[data-mt="sales"] .est-mtabs [data-mt="sales"], .est[data-mt="cost"] .est-mtabs [data-mt="cost"] { background: var(--brand); color: #fff; }
  .est .band-wide, .est .card.summary { display: none; }
  .est[data-mt="info"] .est-tables { display: none; }
  /* 情報欄・似た見積は隠すが、その入れ物 (.est-top) は残す (中の「合計・Function」を「⋯」で下から出すため) */
  .est[data-mt="sales"] .est-top > :not(.summary), .est[data-mt="sales"] .est-bottom, .est[data-mt="sales"] .t-cost { display: none; }
  .est[data-mt="cost"] .est-top > :not(.summary), .est[data-mt="cost"] .est-bottom, .est[data-mt="cost"] .t-sales { display: none; }
  .est[data-mt="sales"] .est-top, .est[data-mt="cost"] .est-top { margin: 0; padding: 0; gap: 0; min-height: 0; }
  .est[data-mt="sales"] .est-tables, .est[data-mt="cost"] .est-tables { display: block; }
  /* 下の帯: 合計・粗利・保存・⋯ (下のメニューのすぐ上) */
  .est-mbar { display: flex; align-items: center; gap: 8px; position: fixed; left: 0; right: 0; bottom: calc(54px + env(safe-area-inset-bottom, 0px)); z-index: 35; padding: 6px 10px; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
  body.printing-view .est-mbar { display: none; }
  .est-mbar .mb-sum { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; border: 0; background: none; padding: 4px 2px; font: inherit; text-align: left; }
  .est-mbar .mb-sum b { font-size: 18px; color: var(--ink); }
  .est-mbar .mb-sum small { font-size: 12px; color: var(--muted); }
  .est-mbar .mb-sum small.warn { color: #b06a00; font-weight: 700; }
  .est-mbar .btn { min-height: 40px; padding: 0 16px; }
  /* 「⋯」: 合計の内わけと Function を下から出す */
  .est.msheet-open .card.summary { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 82vh; overflow: auto; margin: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 28px rgba(0,0,0,.25); padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .est-msheet-back:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(20,30,20,.35); }

  /* 体験版の帯を短く */
  .demo-bar .tb-long { display: none; }
  .demo-bar .tb-short { display: inline; }
  .demo-bar.trial-bar { padding: 6px 12px; font-size: 12.5px; gap: 2px 10px; }
  .demo-bar.trial-bar .trial-acts { gap: 12px; margin-left: 0; }
  .demo-bar.trial-bar .trial-acts a, .demo-bar.trial-bar .link-btn { font-size: 12.5px; }
  /* 見積入力の Function: ボタンを小さめにして1行に3〜4つ並べる (縦に長くならないように) */
  .func-row + .func-row { margin-top: 6px; padding-top: 6px; }
  .func-label { flex: 0 0 46px; font-size: 10.5px; padding-top: 9px; line-height: 1.3; letter-spacing: -.03em; }
  .func-btns { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; }
  .func-btns .btn { min-height: 38px; padding: 3px 4px; font-size: 12.5px; line-height: 1.2; white-space: normal; letter-spacing: -.02em; }
  .func-kind button { padding: 6px 12px; }
  /* 見積台帳: 絞り込みはたたむ */
  #ls-q { flex: 1 1 0; }
  .ls-filter-btn { display: inline-flex; flex: none; white-space: nowrap; }
  .ls-filters { display: none; width: 100%; flex-wrap: wrap; gap: 8px; }
  .ls-filters.open { display: flex; }
  .ls-dates { width: 100%; }
  .ls-dates input[type=date] { flex: 1 1 0; min-width: 0; } /* 長いボタン (定期請求の「○月分の請求書をまとめて作る」など) は折り返す */
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; }

  /* 初期設定: 手順の一覧は横1列の小さな丸に (いまの手順の名前だけ出す) */
  .setup-nav { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 6px; }
  .setup-nav-head { display: none; }
  .setup-step { flex: none; border: 0; border-radius: 18px; padding: 4px; gap: 6px; }
  .setup-step > span:not(.setup-num), .setup-step div, .setup-step small { display: none; }
  .setup-step.on { padding-right: 12px; border-left: 0; }
  .setup-step.on > span:not(.setup-num), .setup-step.on div { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; }
  .setup-step.on small { display: none; }
  .setup-head h2 { font-size: 19px; }
  .setup-card { padding: 12px; }
  .setup-foot { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: var(--bg); padding: 8px 0; z-index: 5; }

  /* 印刷画面の上の操作 */
  .print-bar { flex-wrap: wrap; gap: 8px; }
  .print-bar .seg { width: 100%; overflow-x: auto; }
  .print-bar .seg-btn { flex: 1; padding: 8px 2px; font-size: 12px; text-align: center; white-space: nowrap; }
  .print-bar .spacer { display: none; }
  .approver-pick { flex: 1; }
  .approver-pick select { flex: 1; min-width: 0; }
  .proto-badge, .co-badge { white-space: nowrap; }

  /* 帳票の画面: 用紙 (A4) は横に動かして見る */
  .print-scroll, .print-area { overflow-x: auto; }
}
