/* 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 button { padding: 5px 16px; font-size: 13px; font-weight: 600; border: 0; border-right: 1px solid var(--line); background: #fff; cursor: pointer; }
.func-kind button:last-child { border-right: 0; }
.func-kind 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; }
.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; }
.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; }
@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; }

/* 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; }

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

@page { size: A4 portrait; margin: 0; }

.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; }
.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; }
  main { padding: 0; max-width: none; }
  .paper-wrap { gap: 0; display: block; }
  .paper { box-shadow: none; margin: 0; page-break-after: always; break-after: page; min-height: 0; height: 297mm; overflow: hidden; }
  .paper:last-child { page-break-after: auto; break-after: auto; }
  .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-stamp-box { position: absolute; left: 14mm; top: 12mm; width: 18mm; height: 20mm; 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; }

/* 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-template-columns: repeat(5, 1fr); gap: 2px;
    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: 10px 2px; border-radius: 8px; font-size: 11.5px; text-align: center; }
  .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 1fr 1fr;
    grid-template-areas: "no name name" ". disc amt" ". remark ops";
  }
  #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 input { width: 110px !important; }

  /* 仕入金額 (原価) */
  #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: 220px; }
  .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 no cost" "pick where rate" "pick meta ops";
  }
  #ls-body table.list td { display: block; padding: 0; border: 0; min-width: 0; }
  #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-no { grid-area: no; font-size: 12px; color: var(--muted); }
  #ls-body .c-date { display: none !important; }
  #ls-body .c-where { grid-area: where; font-size: 12px; color: var(--muted); }
  #ls-body .c-meta { grid-area: meta; font-size: 12px; }
  #ls-body .c-amt { grid-area: amt; font-weight: 700; font-size: 15px; }
  #ls-body .c-cost { grid-area: cost; font-size: 12px; color: var(--muted); }
  #ls-body .c-cost::before { content: "原価 "; }
  #ls-body .c-rate { grid-area: rate; font-size: 12px; }
  #ls-body .c-rate::before { content: "粗利率 "; color: var(--muted); }
  #ls-body .c-ops { grid-area: ops; }
  #ls-body .c-cust, #ls-body .c-site, #ls-body .c-cat, #ls-body .c-staff { display: none !important; }
  #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; }
  .toolbar input[type=date] { flex: 1 1 38%; 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; }
}
