/* 色は現場にある物から：墨（文字）、養生テープの緑（操作）、合板（選択・強調の地） */
:root {
  --ink: #24211d;
  --ink2: #5d574f;
  --tape: #2d6a3e;
  --tape-d: #224f2f;
  --ply: #c79a5b;
  --ply-l: #f4ecdd;
  --ply-ll: #faf6ee;
  --warn: #a3361f;
  --paper: #fff;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
.demo-band { background: var(--ink); color: #fff; font-size: 12px; padding: 3px 16px; }
.loading { padding: 40px; }

/* 上部 */
.top { padding: 10px 16px 0; background: var(--ply-ll); }
.brand { font-size: 18px; font-weight: 700; display: inline-block; margin-right: 24px; }
.brand span { font-size: 12px; font-weight: 400; color: var(--ink2); margin-left: 12px; }
.case { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.case select { max-width: 360px; }
nav { display: flex; gap: 2px; margin-top: 8px; overflow-x: auto; }
nav a { padding: 8px 16px 9px; text-decoration: none; color: var(--ink2); font-weight: 500; white-space: nowrap; }
nav a b { font-size: 11px; margin-right: 6px; color: var(--ink2); }
nav a.on { background: var(--paper); color: var(--ink); font-weight: 700; }
nav a.on b { color: var(--tape); }
nav a:hover { color: var(--ink); }

.body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 28px; padding: 12px 16px 60px; }
main section { margin-bottom: 26px; }
h3 { font-size: 15px; margin: 0 0 6px; }
h3 small, .hint { font-size: 12px; font-weight: 400; color: var(--ink2); }
h4 { font-size: 12px; margin: 16px 0 2px; color: var(--ink2); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 28px; }
.scroll { overflow-x: auto; }
.sep { display: inline-block; width: 14px; }
.nowrap { white-space: nowrap; }

/* 部品 */
button { font: inherit; color: var(--ink); background: var(--ply-l); border: 0; border-radius: 3px; padding: 5px 10px; cursor: pointer; }
button:hover { background: #ebdfc8; }
button.on { background: var(--ink); color: #fff; }
button.go { background: var(--tape); color: #fff; font-weight: 600; }
button.go:hover { background: var(--tape-d); }
button.quiet { background: transparent; color: var(--ink2); text-decoration: underline; }
button.x { background: transparent; padding: 2px 6px; color: var(--ink2); }
button.x:hover { color: var(--ink); background: var(--ply-l); }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--ply-ll); border: 0; border-bottom: 1px solid #d9ccb4; padding: 3px 5px; border-radius: 2px 2px 0 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--tape); outline-offset: 1px; }
input.n { width: 84px; text-align: right; }
input.s { width: 60px; }
input.w { width: 100%; min-width: 160px; }
input.warn { background: #fbe9e3; }
textarea { width: 100%; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--tape); }
.err { color: var(--warn); font-weight: 600; }
.status { color: var(--tape); font-weight: 600; min-height: 1.5em; margin: 4px 0; }
.r { text-align: right; }
.c { text-align: center; }

/* 表（枠を使わず、余白と文字の太さで区切る） */
table { border-collapse: collapse; }
.grid { width: 100%; }
.grid th { font-size: 11px; font-weight: 600; color: var(--ink2); text-align: left; padding: 4px 6px; white-space: nowrap; }
.grid td { padding: 3px 6px; vertical-align: middle; }
.grid tbody tr:nth-child(even) td { background: var(--ply-ll); }
.grid tr.hl td, .grid tr.sel td, .grid tr.sel th { background: var(--ply-l) !important; }
.grid tr.off td { color: #9a948b; }
.grid tfoot td { padding-top: 8px; font-weight: 700; }
.grid .preview { font-size: 11px; color: var(--ink2); padding: 1px 5px; }
.items .name { min-width: 340px; }
.form th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink2); padding: 3px 10px 3px 0; white-space: nowrap; }
.form td { padding: 3px 14px 3px 0; }
.case-head .form { width: 100%; }
.kv { width: 100%; }
.kv th { text-align: left; font-weight: 400; color: var(--ink2); padding: 2px 0; }
.kv td { text-align: right; padding: 2px 0; font-variant-numeric: tabular-nums; }
.kv.wide td { text-align: left; }
.kv.wide th { width: 120px; vertical-align: middle; }
.kv tr.sub th { padding-left: 12px; font-size: 12px; }

/* 右の集計 */
aside { position: sticky; top: 8px; align-self: start; }
.big dt { font-size: 12px; color: var(--ink2); }
.big dd { margin: 0; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.msg { color: var(--tape); font-weight: 600; min-height: 3em; }

/* 図面 */
.plan-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.plan-view { overflow: auto; max-height: 78vh; background: var(--ply-ll); }
.plan-view svg { display: block; min-width: 600px; touch-action: none; }
.plan-empty { background: var(--ply-ll); padding: 40px 24px; color: var(--ink2); }
#planSvg.mode-scale, #planSvg.mode-note, #planSvg.mode-measure { cursor: crosshair; }
.pin circle { fill: var(--tape); opacity: .85; }
.pin text { fill: var(--tape-d); font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 6px; }
.pin.hl circle { fill: var(--warn); }
.pin.hl text { fill: var(--warn); }
.mark circle { fill: var(--warn); }
.mark text { fill: var(--warn); font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 6px; }
.scl line { stroke: var(--ply); }
.scl text { fill: #8a6430; font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 6px; }
.pick { fill: var(--warn); }
.pickline { stroke: var(--warn); }
.meas { fill: rgba(45, 106, 62, .12); stroke: var(--tape); }
.meas-t { fill: var(--tape-d); font-weight: 700; paint-order: stroke; stroke: #fff; stroke-width: 6px; }
.toolp { background: var(--ply-l); padding: 8px 10px; margin-bottom: 8px; }
.reading { background: var(--ply-ll); padding: 12px; margin-bottom: 10px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.thumbs button { display: flex; flex-direction: column; align-items: center; padding: 4px; background: var(--paper); }
.thumbs button.on { background: var(--ink); color: #fff; }
.thumbs img { height: 90px; display: block; }
.thumbs span { font-size: 11px; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mini { position: relative; }
.mini img { width: 100%; display: block; }
.mini svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 材料 */
.sw { width: 56px; height: 40px; object-fit: cover; display: block; }
.sw.none { background: var(--ply-ll); }
.filters { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.filters input[type=search] { max-width: 460px; }
.grp { display: flex; gap: 4px; flex-wrap: wrap; }
.grp button { padding: 3px 8px; font-size: 12px; }
.cat { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 10px; }
.cat .item { display: flex; flex-direction: column; align-items: stretch; text-align: left; background: transparent; padding: 0; }
.cat .item img { width: 100%; aspect-ratio: 240 / 168; object-fit: cover; display: block; margin-bottom: 4px; }
.cat .item:hover img { outline: 3px solid var(--tape); }
.cat .item.used b::after { content: "　使用中"; color: var(--tape); font-size: 11px; }
.cat .item b { font-size: 14px; }
.cat .item small { font-size: 11px; color: var(--ink2); }
.cat .item span { font-size: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cat .item .fn { margin-top: 2px; }

/* 工程 */
.bigline { font-size: 18px; font-weight: 700; margin: 4px 0; }

/* 書類（画面ではA4の紙として並べる） */
.docs-bar { position: sticky; top: 0; background: var(--paper); padding: 6px 0; z-index: 2; }
.sheet-wrap { background: #e9e4da; padding: 20px; overflow-x: auto; margin-bottom: 18px; }
.sheet { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 13mm; color: #111; font-size: 10.5px; }
.sheet table { width: 100%; }

.quote h1 { text-align: center; font-size: 22px; letter-spacing: .4em; margin: 0 0 8mm; font-weight: 700; }
.qhead { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8mm; margin-bottom: 6mm; }
.qhead .name { font-size: 18px; font-weight: 700; border-bottom: 1.5px solid #111; padding-bottom: 2px; margin: 0 0 3mm; }
.qhead .meta th { text-align: left; font-weight: 400; width: 18mm; color: #444; padding: 1px 0; }
.qhead .meta td { padding: 1px 0; }
.qhead .lead { margin: 3mm 0 1mm; }
.qhead .amount { font-size: 20px; font-weight: 700; border-bottom: 1.5px solid #111; margin: 0; padding-bottom: 2px; }
.qhead .amount span { font-size: 12px; font-weight: 400; margin-right: 6mm; }
.qhead .amount small { font-size: 11px; font-weight: 400; }
.from { position: relative; font-size: 10px; }
.from p { text-align: right; margin: 0 0 3mm; }
.co { line-height: 1.55; }
.co b { font-size: 12.5px; }
.stamp { position: absolute; right: 2mm; bottom: 0; width: 15mm; height: 15mm; border: 1px solid #c55; color: #c55; display: grid; place-items: center; font-size: 10px; }
.lines { border: 1.2px solid #111; }
.lines th { background: #e6e6e6; border: 1px solid #111; font-weight: 600; padding: 2px 4px; font-size: 10.5px; }
.lines th:first-child { width: 58%; }
.lines td { border-left: 1px solid #111; border-right: 1px solid #111; border-bottom: 1px solid #bbb; padding: 1.5px 4px; height: 4.9mm; font-variant-numeric: tabular-nums; }
.lines tfoot th, .lines tfoot td { border: 1px solid #111; background: #fff; text-align: left; font-weight: 400; }
.lines tfoot td.r { text-align: right; }
.lines tfoot td.blank { border: 0; border-top: 1.2px solid #111; }
.notes { font-size: 9.5px; margin-top: 5mm; line-height: 1.6; }

.spec .band { background: #7a7a7a; color: #fff; text-align: center; font-size: 15px; padding: 3mm; line-height: 1.5; margin-bottom: 6mm; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm 8mm; }
.swatches figure { margin: 0; text-align: center; }
.swatches figcaption { font-size: 12.5px; font-weight: 700; margin-bottom: 2mm; line-height: 1.5; }
.swatches .card { background: #fff; box-shadow: 0 0 0 1px #ddd; padding: 3mm; }
.swatches .card b { display: block; font-size: 10px; margin-bottom: 2mm; }
.swatches .card img { width: 100%; aspect-ratio: 240 / 168; object-fit: cover; display: block; }
.swatches .card.manual { min-height: 38mm; display: flex; flex-direction: column; justify-content: center; gap: 2mm; }
.swatches small { font-size: 9px; color: #555; display: block; margin-top: 1mm; }
.spec-bottom { display: grid; grid-template-columns: 62mm 1fr; gap: 6mm; margin-top: 8mm; align-items: start; }
.other { border: 1px solid #333; padding: 3mm 4mm; font-size: 11px; }
.other ul { list-style: none; padding: 0; margin: 2mm 0 0; line-height: 2.1; }
.splan svg { width: 100%; display: block; }
.smark circle { fill: #c33; }
.smark rect { fill: #d9433a; }
.smark text { fill: #fff; font-weight: 700; }


/* ---------- 工程表（画面・印刷共通） ---------- */
.tl-wrap { overflow-x: auto; }
.tl { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; font-size: 12px; }
.tl col { width: 26px; }
.tl col.c-no { width: 30px; } .tl col.c-nm { width: 170px; } .tl col.c-pd { width: 150px; } .tl col.c-dy { width: 46px; }
.tl th, .tl td { padding: 0; height: 30px; text-align: center; font-weight: 400; vertical-align: middle; }
.tl thead th { font-size: 11px; color: var(--ink2); }
.tl tr.tm th { text-align: left; font-weight: 700; color: var(--ink); padding-left: 3px; border-left: 1px solid #cfc6b6; height: 22px; }
.tl tr.tm th:first-child { border-left: 0; }
.tl tr.td th { line-height: 1.15; height: 34px; border-bottom: 1px solid #cfc6b6; }
.tl tr.td th i { font-style: normal; font-size: 10px; }
.tl th.l { text-align: left; padding-left: 4px; }
.tl tbody tr:nth-child(even) td, .tl tbody tr:nth-child(even) th { background-color: var(--ply-ll); }
.tl td.no { color: var(--ink2); }
.tl th.nm { text-align: left; padding-left: 4px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl td.pd { text-align: left; padding-left: 4px; white-space: nowrap; color: var(--ink2); font-size: 11.5px; }
.tl td.dy { font-weight: 600; }
.tl .off { background-color: #ece7de !important; }
.tl .sat { background-color: #f4f1ea; }
.tl .wk { border-left: 1px solid #cfc6b6; }
.tl td { position: relative; }
.tl .bar { position: absolute; left: 0; right: 0; top: 8px; bottom: 8px; background: var(--tape); }
.tl .bar.bs { left: 3px; border-radius: 4px 0 0 4px; }
.tl .bar.be { right: 3px; border-radius: 0 4px 4px 0; }

/* スマホ用の工程表 */
.tls { position: relative; }
.tls-scale { position: relative; height: 18px; font-size: 11px; color: var(--ink2); margin-left: 0; }
.tls-scale span { position: absolute; top: 0; }
.tls-row { padding: 8px 0; }
.tls-row + .tls-row { border-top: 1px solid #eee7da; }
.tls-t { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.tls-t span { color: var(--ink2); font-size: 12px; white-space: nowrap; }
.tls-track { position: relative; height: 12px; background: var(--ply-ll); border-radius: 6px; margin-top: 5px; }
.tls-track i { position: absolute; top: -3px; bottom: -3px; width: 1px; background: #d9ccb4; }
.tls-track em { position: absolute; top: 0; bottom: 0; background: var(--tape); border-radius: 6px; }

/* 印刷用の工程表（A4横） */
.sheet.sched { width: 297mm; min-height: 210mm; padding: 10mm 10mm 8mm; font-size: 10px; display: flex; flex-direction: column; }
.g-top { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 2mm; }
.g-top h2 { font-size: 18px; margin: 0; letter-spacing: .3em; }
.g-info { display: grid; grid-template-columns: 1.3fr 1.6fr 1.6fr .9fr 1.2fr; gap: 2mm 5mm; margin: 3mm 0 4mm; }
.g-info dt { font-size: 8.5px; color: #555; }
.g-info dd { margin: 0; font-size: 10.5px; }
.g-body { flex: 1; }
.sheet .tl { width: 100%; font-size: 9px; }
.sheet .tl col { width: auto; }
.sheet .tl col.c-no { width: 6mm; } .sheet .tl col.c-nm { width: 34mm; } .sheet .tl col.c-pd { width: 31mm; } .sheet .tl col.c-dy { width: 9mm; }
.sheet .tl th, .sheet .tl td { height: 7mm; }
.sheet .tl tr.td th { height: 8mm; font-size: 8px; }
.sheet .tl tr.td th i { font-size: 7px; }
.sheet .tl td.pd { font-size: 8.5px; }
.sheet .tl .bar { top: 1.8mm; bottom: 1.8mm; background: #2d6a3e; }
.g-legend { font-size: 9px; color: #444; margin-top: 3mm; display: flex; align-items: center; gap: 1.5mm; }
.g-legend .lg { display: inline-block; width: 7mm; height: 3mm; margin-left: 3mm; }
.g-legend .lg.bar { background: #2d6a3e; border-radius: 2px; } .g-legend .lg.off { background: #ece7de; } .g-legend .lg.sat { background: #f4f1ea; border: 1px solid #ddd; }
.g-note { color: #b0201a; font-size: 9.5px; margin: 2mm 0 0; }
.g-foot { font-size: 8.5px; color: #444; margin: 2mm 0 0; border-top: 1px solid #999; padding-top: 1.5mm; }

/* ---------- スマホ用の画面 ---------- */
.fld { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fld > span { font-size: 11px; color: var(--ink2); }
.fld input, .fld select, .fld output { width: 100%; min-width: 0; font-size: 16px; padding: 7px 8px; }
.fld output { background: var(--ply-l); font-weight: 700; border-radius: 2px; }
.sp-top { position: sticky; top: 0; z-index: 20; background: var(--ply-ll); padding: 6px 10px 6px; box-shadow: 0 1px 0 #e3d9c6; }
.sp-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.sp-brand { font-size: 14px; white-space: nowrap; }
.sp-row select { width: 100%; min-width: 0; font-size: 14px; padding: 6px; }
.sp-row button { padding: 7px 10px; }
.sp-menu { display: flex; gap: 6px; padding: 6px 0 2px; }
.sp-total { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.sp-total small { display: block; font-size: 10px; color: var(--ink2); }
.sp-total b { font-size: 20px; font-variant-numeric: tabular-nums; }
.sp-q { font-size: 11px; color: var(--ink2); text-align: right; line-height: 1.4; }
.sp-total .msg { flex-basis: 100%; margin: 2px 0 0; min-height: 0; font-size: 12px; }
.sp-main { padding: 10px 12px 90px; }
.sp-main section { margin-bottom: 22px; }
.sp-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--ink); padding-bottom: env(safe-area-inset-bottom); }
.sp-nav a { color: #d8d2c8; text-decoration: none; text-align: center; padding: 13px 0 14px; font-size: 13px; font-weight: 600; }
.sp-nav a.on { color: #fff; background: var(--tape); }
.sp-case { background: var(--ply-ll); margin: 0 -12px 14px; padding: 0 12px; }
.sp-case summary { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 10px 0; cursor: pointer; list-style: none; }
.sp-case summary::-webkit-details-marker { display: none; }
.sp-case summary span { color: var(--ink2); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sp-case summary em { font-style: normal; color: var(--tape); font-size: 12px; font-weight: 700; }
.fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 8px; padding-bottom: 14px; }
.fields .fld { grid-column: span 6; }
.fields .fld.half { grid-column: span 3; }
.fields .fld.wide2 { grid-column: span 4; }
.fields .fld.narrow { grid-column: span 2; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--ply-ll); padding: 10px; border-radius: 4px; display: flex; flex-direction: column; gap: 8px; }
.card.hl { background: var(--ply-l); }
.card.off { opacity: .55; }
.c-head { display: flex; gap: 6px; align-items: center; }
.c-head .c-name { flex: 1; font-size: 16px; font-weight: 700; padding: 7px 8px; min-width: 0; }
.c-head select { font-size: 15px; padding: 7px 4px; }
.c-grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.c-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.c-grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.c-grid3 .fld select, .c-grid2 .fld select { font-size: 14px; padding: 7px 2px; }
.c-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.c-calc { color: var(--ink2); font-size: 12px; }
.c-note { font-size: 14px; padding: 6px 8px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; }
.chk input { width: 20px; height: 20px; }
.item-c textarea { font-size: 15px; }
.item-c .c-amt { margin-left: auto; font-size: 18px; font-variant-numeric: tabular-nums; }
.item-c .c-yen { font-size: 12px; color: var(--ink2); }
.c-tools { display: flex; gap: 4px; justify-content: flex-end; }
.c-tools .x { padding: 6px 10px; }
.card.rr { display: grid; grid-template-columns: auto 1fr auto 64px; gap: 6px; align-items: center; }
.card.rr input, .card.rr select { font-size: 15px; padding: 6px; min-width: 0; }
.card.st { display: grid; grid-template-columns: 1fr 76px auto; gap: 4px 10px; align-items: center; }
.card.st > b { grid-column: 1 / -1; font-size: 14px; }
.card.st > span { font-size: 12px; color: var(--ink2); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 8px; }
.slot-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.slot-card { display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto auto; gap: 0 8px; text-align: left; background: var(--ply-ll); padding: 8px; align-items: center; }
.slot-card .sw { grid-row: 1 / 4; width: 52px; height: 52px; }
.slot-card b { font-size: 13px; }
.slot-card span { font-size: 11px; color: var(--ink2); }
.slot-card em { font-style: normal; font-size: 11px; color: var(--tape); font-weight: 700; }
.slot-card.on { background: var(--ink); color: #fff; } .slot-card.on span, .slot-card.on em { color: #e8e2d8; }
.slot-card.manual { grid-column: span 2; display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.slot-card.manual .fld { grid-column: span 2; }
.sp-sticky { position: sticky; top: 104px; z-index: 5; background: var(--ink); color: #fff; padding: 6px 10px; margin: 0 0 8px; font-size: 13px; border-radius: 3px; }
.fn.hide { display: none; }
.sp-docs { flex-direction: column; align-items: stretch; position: static; }
.sp-docs button { padding: 11px; font-size: 15px; }

@media (max-width: 760px) {
  body { font-size: 14px; }
  .demo-band { font-size: 11px; padding: 3px 10px; }
  h3 { font-size: 16px; }
  h3 small { display: block; margin-top: 2px; }
  button { padding: 7px 12px; }
  .plan-tools { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .plan-tools button { white-space: nowrap; }
  .plan-tools .hint { white-space: nowrap; }
  .plan-view { max-height: none; margin: 0 -12px; }
  .plan-view svg { width: 100% !important; min-width: 0; }
  #planSvg.mode-none { touch-action: auto; }
  .toolp { font-size: 14px; line-height: 2; }
  .toolp input, .toolp select { font-size: 16px; }
  .reading .row { flex-direction: column; align-items: stretch; }
  .reading .row .hint { text-align: left; }
  .cat { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
  .cat .item span { -webkit-line-clamp: 2; font-size: 12px; }
  .filters .grp { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .filters .grp button { white-space: nowrap; }
  .filters input[type=search] { font-size: 16px; padding: 8px; }
  .kv.wide th { width: 70px; }
  .kv.wide input { font-size: 15px; }
  textarea { font-size: 16px; }
  .sheet-wrap { padding: 8px; margin: 0 -12px 14px; }
  .sheet-wrap .sheet { zoom: .44; }
  .sheet-wrap .sheet.sched { zoom: .32; }
  .form input, .form select { font-size: 16px; }
}

#printArea { display: none; }

@media (max-width: 1000px) {
  .body { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .form tbody, .form tr { display: flex; flex-wrap: wrap; align-items: center; width: 100%; }
  .form th, .form td { display: block; }
  .form td { flex: 0 0 68%; min-width: 0; padding-right: 0; }
  .form th { flex: 0 0 32%; padding-right: 6px; white-space: normal; }
  .form td:only-child, .form td:first-child:not(:last-child) + td { flex-basis: auto; }
  aside .msg { min-height: 0; }
  input.w { min-width: 0; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  table.grid { display: block; overflow-x: auto; }
  .plan-view svg { min-width: 0; }
  .top { padding: 8px 10px 0; }
  .case select { max-width: 100%; }
  aside { position: static; order: -1; }
  aside .kv, aside h4 { display: none; }
  .big dd { font-size: 20px; }
  .split { grid-template-columns: 1fr; }
  .brand span { display: none; }
}

@page { size: A4; margin: 0; }
@page sched { size: A4 landscape; margin: 0; }
.sheet.sched { page: sched; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  .sheet { margin: 0; box-shadow: none; break-after: page; width: 210mm; min-height: 0; }
  .sheet.sched { width: 297mm; height: 209mm; overflow: hidden; }
  .sheet:last-child { break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.rooms td, .items td { white-space: nowrap; }
.items td:nth-child(2) { white-space: normal; }
/* PCの画面では工期全体が1画面に収まるよう日付の列を縮める */
.tl-wrap .tl { width: 100%; min-width: calc(400px + var(--days, 40) * 15px); }
.tl-wrap .tl col:not([class]) { width: auto; }
.tl-wrap .tl tr.td th { font-size: 10.5px; }
.splan svg { max-height: 118mm; width: auto; max-width: 100%; margin: 0 auto; }
.sheet .tl th, .sheet .tl td { height: 9mm; }
.sheet .tl { font-size: 10px; }
.sheet .tl td.pd { font-size: 9px; }
.sheet .tl .bar { top: 2.4mm; bottom: 2.4mm; }
.swatches { grid-template-columns: repeat(auto-fit, minmax(33mm, 1fr)); gap: 5mm 4mm; }
.swatches figcaption { font-size: 11px; }
.swatches .card.manual { min-height: 26mm; }
.splan svg { max-height: 150mm; }

.sheet .tl tbody th, .sheet .tl tbody td { height: var(--rh, 9mm); }
.sheet .tl .bar { top: calc(var(--rh, 9mm) * .26); bottom: calc(var(--rh, 9mm) * .26); }

/* ---------- 設定のタブ・会社・カタログ ---------- */
.stabs { display: flex; gap: 2px; margin-bottom: 10px; overflow-x: auto; }
.stabs button { white-space: nowrap; background: transparent; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 14px; font-weight: 600; color: var(--ink2); }
.stabs button.on { color: var(--ink); border-bottom-color: var(--tape); background: transparent; }
.co-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.co-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; background: var(--ply-ll); padding: 10px 12px; }
.co-item span { grid-column: 1; font-size: 12px; color: var(--ink2); }
.co-item em { grid-column: 2; grid-row: 1 / 3; align-self: center; font-style: normal; font-size: 12px; color: var(--tape); font-weight: 700; }
.co-item.on { background: var(--ink); color: #fff; } .co-item.on span, .co-item.on em { color: #e8e2d8; }
.cat-rows { display: flex; flex-direction: column; gap: 2px; }
.cat-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 8px 6px; }
.cat-row:nth-child(odd) { background: var(--ply-ll); }
.cat-row.on .cat-main b { color: var(--tape-d); }
.cat-main span { display: block; font-size: 12px; color: var(--ink2); }
.cat-tools { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.modes { margin-bottom: 10px; }
.imp { margin-top: 12px; background: var(--ply-ll); padding: 10px; }
.imp h4 { margin: 0 0 8px; color: var(--ink); font-size: 13px; }
.cat.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px 8px; }
.cat.small .item span { -webkit-line-clamp: 2; font-size: 11px; }
.sw-big { display: block; width: 100%; aspect-ratio: 240 / 168; margin-bottom: 4px; }
.cat-edit { background: var(--ply-ll); padding: 10px 12px; }
.ci-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow: auto; margin-bottom: 10px; }
.ci { display: grid; grid-template-columns: 56px 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.ci span { color: var(--ink2); }
.btnlike { display: inline-flex; align-items: center; background: var(--ply-l); padding: 5px 10px; border-radius: 3px; cursor: pointer; }
.btnlike.go { background: var(--tape); color: #fff; font-weight: 600; }
.thumb { height: 40px; width: auto; background: #fff; padding: 2px; }
.manual-slot { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 12px; max-width: 640px; }

/* 単価表から足す欄 */
details.master { background: var(--ply-ll); padding: 0 12px; margin-bottom: 16px; }
details.master > summary { cursor: pointer; padding: 10px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
details.master[open] { padding-bottom: 10px; }
.m-sets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.m-sets button { background: var(--paper); }
.m-list { display: flex; flex-direction: column; max-height: 320px; overflow: auto; background: var(--paper); }
.m-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 5px 8px; cursor: pointer; }
.m-row:nth-child(even) { background: var(--ply-ll); }
.m-row input { width: 18px; height: 18px; }
.m-cat { font-size: 11px; color: var(--ink2); }
.m-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
details.set { margin-bottom: 6px; background: var(--ply-ll); padding: 0 10px; }
details.set > summary { padding: 8px 0; cursor: pointer; display: flex; gap: 10px; align-items: center; }
details.set > summary input { font-weight: 700; min-width: 0; flex: 0 1 320px; }

/* 見積書の雛形 */
.layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.layout { display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--ply-ll); padding: 8px; }
.layout.on { outline: 3px solid var(--tape); background: var(--ply-l); color: var(--ink); }
.layout .mini { height: 170px; overflow: hidden; background: #e9e4da; display: flex; justify-content: center; pointer-events: none; }
.layout .mini .sheet { zoom: .2; margin: 10px auto 0; }
.layout span { font-size: 12px; color: var(--ink2); }
.cswatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; }
.cswatch.on { outline: 3px solid var(--ply); outline-offset: 2px; }

/* 見積書の書式：共通（ロゴ・印影）と、色帯つき・シンプル */
.quote .logo { display: block; max-height: 14mm; max-width: 45mm; margin-bottom: 2mm; }
.quote .stamp-img { position: absolute; right: 2mm; bottom: 0; width: 17mm; height: 17mm; object-fit: contain; }
.q-classic .qc-top { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid var(--qc); padding-bottom: 3mm; margin-bottom: 6mm; }
.q-classic .qc-top h1 { font-size: 24px; margin: 0; letter-spacing: .15em; color: var(--qc); }
.q-classic .qc-top p { margin: 0; text-align: right; font-size: 10px; }
.q-classic .amount-box { display: flex; justify-content: space-between; align-items: center; background: var(--qc); color: #fff; padding: 3mm 4mm; margin: 2mm 0 0; }
.q-classic .amount-box b { font-size: 20px; }
.q-classic .lines { border: 0; }
.q-classic .lines th { background: var(--qc); color: #fff; border: 1px solid var(--qc); }
.q-classic .lines td { border-left: 0; border-right: 0; border-bottom: 1px solid #ccc; }
.q-classic .lines tbody tr:nth-child(even) td { background: #f6f6f4; }
.q-classic .lines tfoot th { background: #f0f0ee; color: #111; border: 1px solid #ccc; }
.q-classic .lines tfoot td { border: 1px solid #ccc; }
.q-classic .lines tfoot td.blank { border: 0; }
.q-simple .qs-top { display: flex; justify-content: space-between; gap: 8mm; margin-bottom: 6mm; }
.q-simple .qs-top h1 { font-size: 13px; letter-spacing: .3em; margin: 0 0 6mm; color: var(--qc); font-weight: 700; }
.q-simple .qs-top .name { font-size: 20px; font-weight: 700; margin: 0; }
.q-simple .qs-top .from { min-width: 70mm; }
.q-simple .qs-sum { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8mm; align-items: end; border-top: 1px solid #111; border-bottom: 1px solid #111; padding: 3mm 0; }
.q-simple .qs-sum span { display: block; font-size: 10px; color: #555; }
.q-simple .qs-sum b { font-size: 24px; color: var(--qc); }
.q-simple .qs-sum small { display: block; font-size: 9px; color: #555; }
.q-simple .lines { border: 0; }
.q-simple .lines th { background: transparent; border: 0; border-bottom: 1.5px solid #111; text-align: left; }
.q-simple .lines td { border: 0; border-bottom: 1px solid #ddd; }
.q-simple .lines tfoot th, .q-simple .lines tfoot td { border: 0; border-bottom: 1px solid #ddd; }
.q-simple .lines tfoot td.blank { border: 0; }
.lines th.no { width: 7mm; }

@media (max-width: 760px) {
  .layouts { grid-template-columns: 1fr; }
  .layout .mini { height: 140px; }
  .cat-row { grid-template-columns: auto 1fr; }
  .cat-tools { grid-column: 1 / -1; flex-wrap: wrap; }
  .ci { grid-template-columns: 52px 1fr auto; }
  .ci span { grid-column: 2; }
  .manual-slot { grid-template-columns: 1fr; }
  .m-row { grid-template-columns: auto 1fr; }
  .m-row .m-cat, .m-row .m-price { grid-column: 2; }
  .sp-menu { flex-direction: column; align-items: stretch; }
  .sp-menu > div { display: flex; gap: 6px; }
  .stabs button { padding: 8px 10px; }
}
