:root {
  color-scheme: dark;
  --bg: #0b0f14; --card: #121820; --raised: #18212c;
  --text: #edf3fa; --muted: #9caec0; --line: #253140;
  --accent: #66dded; --accent-bg: #102d35;
  --warn: #ff9494; --warn-bg: #301e25; --ok: #83ddba;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
body::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 460px; pointer-events: none; background: radial-gradient(ellipse at 85% 0%, #183d4a65, transparent 62%); z-index: -1; }
button, input, select, textarea { font: inherit; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: var(--accent); text-underline-offset: 3px; }
button, a, input, summary, textarea { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--accent); }
.wrap { max-width: 1320px; margin: auto; padding: 0 40px 48px; }
.topbar { height: 78px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; font: 600 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }
.brand-mark { width: 33px; height: 33px; border: 1px solid var(--accent); border-radius: 9px; display: grid; place-items: center; color: var(--accent); background: var(--accent-bg); }
.topbar-note { font-size: 12px; color: var(--muted); }
.topbar-end { display: flex; align-items: center; gap: 16px; min-width: 0; }
.store-entry { min-height: 36px; padding: 6px 12px; font-size: 12px; max-width: 220px; }
.store-entry span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--muted); }
.store-entry.on { border-color: var(--accent); color: var(--accent); }
.store-entry.on .store-dot { background: var(--accent); border-color: var(--accent); }
.hero { padding: 28px 0 20px; max-width: 880px; }
.eyebrow { color: var(--accent); font: 600 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; margin: 0 0 12px; }
h1 { font-size: clamp(28px, 3.5vw, 42px); line-height: 1.3; letter-spacing: -.04em; margin: 0 0 14px; }
.lead { font-size: 15px; color: var(--muted); max-width: 760px; margin: 0; line-height: 1.9; }
.meta { margin: 0 0 22px; color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.meta b { color: var(--text); font-weight: 500; }
.meta .stale { color: var(--warn); }
.source-dot { width: 6px; height: 6px; display: inline-block; background: var(--accent); border-radius: 50%; margin-right: 7px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 14px; }
.section-heading h2 { margin: 0; font-size: 17px; font-weight: 600; }
.section-heading span, .small { color: var(--muted); font-size: 12px; }
.step { font: 500 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); margin-right: 10px; }
.preset-summary { display: flex; align-items: center; gap: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 14px 18px; margin-bottom: 24px; }
.preset-current { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; flex: 1; }
.preset-current strong { overflow-wrap: anywhere; }
.preset-state { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.preset-amount { text-align: right; font-variant-numeric: tabular-nums; }
.preset-amount span { display: block; color: var(--muted); font-size: 11px; }
.preset-amount strong { font-size: 19px; }
.purpose-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.purposes { display: flex; flex-wrap: wrap; gap: 6px; }
.purpose-button { min-height: 44px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--muted); font-size: 13px; }
.purpose-button[aria-pressed=true] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.shared-return { margin: -12px 0 24px; }
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.tab { position: relative; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; transition: border-color .16s, background .16s; min-width: 0; }
.tab:hover { border-color: #527585; background: var(--raised); }
.tab.on { border-color: var(--accent); background: linear-gradient(120deg, #142b34, #121c25); }
.tab-title { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 17px; }
.tab-check { width: 19px; height: 19px; border: 1px solid #405264; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: transparent; }
.tab.on .tab-check { color: #0b2229; background: var(--accent); border-color: var(--accent); }
.tab small { display: block; color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.tab-price { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.tab-price span { font-size: 11px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 8px; }
.tab.shared { grid-column: 1 / -1; padding: 16px 22px; }
.tab.shared small { margin-bottom: 8px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.parts-panel { min-width: 0; }
.note { color: var(--muted); font-size: 12px; margin: -4px 0 18px; }
.build-note { padding: 0; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.build-note summary { cursor: pointer; width: fit-content; min-height: 32px; display: list-item; align-content: center; }
.build-note .note { margin: 6px 0 12px; }
.parts { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.parts:empty { display: none; }
.scope { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 16px; }
.scope-btn { border: 1px solid var(--line); background: var(--card); color: var(--muted); padding: 6px 14px; font-size: 13px; min-height: 36px; }
.scope-btn:first-child { border-radius: 8px 0 0 8px; }
.scope-btn:nth-child(2) { border-radius: 0 8px 8px 0; margin-left: -9px; }
.scope-btn:hover { color: var(--text); border-color: #456073; }
.scope-btn[aria-pressed=true] { color: var(--accent); background: var(--accent-bg); border-color: var(--accent); position: relative; }
.scope-hint { color: var(--muted); font-size: 12px; }
.more { margin-top: 28px; }
.more .parts { margin-bottom: 12px; }
.add-more { width: 100%; border-style: dashed; color: var(--accent); background: transparent; }
.add-more:hover { background: var(--accent-bg); border-color: var(--accent); }
.part { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.part:last-child { border-bottom: none; }
.part-icon { width: 36px; height: 36px; border: 1px solid var(--line); background: #0e141c; color: var(--muted); display: grid; place-items: center; border-radius: 9px; }
.part-icon svg { width: 22px; height: 22px; }
.part.empty .part-icon { border-style: dashed; }
.part-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.part-role { font-weight: 600; font-size: 12px; color: var(--muted); }
.part-name { margin: 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.empty .part-name { color: var(--muted); font-size: 13px; }
.part-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.text-button { border: 0; padding: 2px 0; color: var(--accent); background: transparent; font-size: 12px; min-height: 28px; }
.text-button.remove { color: var(--muted); }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.part-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 8px; }
.quantity { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
input[type=number] { width: 58px; height: 32px; padding: 3px 5px 3px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: #0d131b; font-size: 13px; }
.part-price { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.unit-price { color: var(--muted); font-size: 11px; margin-right: 10px; }
.subtotal { font-size: 16px; font-weight: 600; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.flags:empty { display: none; }
.flag { display: inline-block; font-size: 10px; border: 1px solid #344152; color: var(--muted); border-radius: 4px; padding: 1px 5px; }
.flag.hot { color: #edc87e; border-color: #605132; background: #292417; }
.flag.cond { color: var(--warn); border-color: #6a3b43; background: var(--warn-bg); }
.d { display: block; font-size: 11px; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.d.inl { display: inline; margin-left: 6px; }
.up, .gone, .d.up, .d.gone { color: var(--warn); }
.down, .d.down { color: var(--ok); }
.renamed, .d.renamed { color: var(--accent); }
.hist { color: var(--muted); }
.hist .spark { display: inline-block; vertical-align: middle; margin-left: 6px; color: var(--accent); }
.picker-item .hist { margin-top: 4px; }
.summary-card { position: sticky; top: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.summary-card h2 { font-size: 16px; margin: 0 0 16px; }
.summary-label { color: var(--muted); font-size: 12px; }
.total { font-size: 38px; font-weight: 600; line-height: 1.35; letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.summary-footnote { color: var(--muted); font-size: 11px; margin: 0 0 12px; }
.summary-detail { display: flex; align-items: baseline; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; font-size: 12px; }
.summary-detail > span { color: var(--muted); flex: 1; min-width: 0; }
.summary-detail strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.btns { display: grid; gap: 8px; margin-top: 18px; }
.b { display: inline-flex; align-items: center; justify-content: center; text-align: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--text); padding: 10px 12px; text-decoration: none; font-size: 13px; min-height: 42px; }
.b:hover { background: #243140; border-color: #456073; }
.b.primary { color: #072229; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.b.primary:hover { background: #98edf5; }
.summary-secondary { display: flex; flex-wrap: wrap; gap: 8px 16px; padding-top: 12px; }
.summary-secondary .b { width: 100%; }
.btns .wide { grid-column: 1 / -1; }
.warns { list-style: none; padding: 0; margin: 16px 0 0; }
.warns li { border-left: 2px solid var(--warn); background: var(--warn-bg); color: var(--warn); border-radius: 0 6px 6px 0; padding: 10px 12px; font-size: 12px; margin-top: 8px; overflow-wrap: anywhere; }
.warns li.ok { background: #102821; color: var(--ok); border-color: var(--ok); }
.chg { background: var(--accent-bg); border: 1px solid #315967; border-radius: 8px; margin-bottom: 16px; padding: 14px 16px; font-size: 13px; }
.chg.same { border-color: var(--line); background: var(--card); }
.chg .small { display: block; margin-top: 4px; }
.chg ul { margin: 10px 0 0; list-style: none; padding: 0; }
.chg li { padding: 3px 0; font-variant-numeric: tabular-nums; }
/* #diff (這張單跟分享時的內容比) 跟 #chg (跟分享時的報價比) 是兩回事：換個邊框色與記號，別看成同一框 */
.chg.diff { border-color: #6a5a2e; background: #1c1810; }
.chg-mark { display: inline-block; margin-right: 6px; color: #e3b341; }
.chg .from { color: var(--muted); text-decoration: line-through; }
.chg .added { color: var(--ok); }
.chg .removed { color: var(--warn); }
.info-card { border-top: 1px solid var(--line); margin-top: 36px; padding: 12px 0; }
details { padding: 12px 0; }
summary { cursor: pointer; font-weight: 500; font-size: 13px; }
#notes { padding-left: 20px; line-height: 1.9; }
#notes li { margin: 8px 0; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { padding: 10px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); font-size: 12px; overflow-wrap: anywhere; }
th { color: var(--muted); }
.req th:first-child { width: 65px; }
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.footer p { margin: 0; }
.mobile-bar { display: none; }
.mobile-amount { min-width: 0; flex: 1; }
.mobile-net { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.mobile-actions { flex-shrink: 0; }
.sheet-top-total { display: none; }
.load-state { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 28px; margin-bottom: 24px; }
.load-state h2 { margin: 0 0 8px; font-size: 17px; }
.load-state p { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); width: max-content; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 5; }
#toast.show { opacity: 1; }
dialog { inset: 0 0 0 auto; width: min(600px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; background: var(--bg); color: var(--text); border: 0; border-left: 1px solid var(--line); }
dialog::backdrop { background: #03070dba; backdrop-filter: blur(3px); }
body:has(dialog[open]) { overflow: hidden; }
.picker-shell { display: flex; flex-direction: column; height: 100%; }
.picker-header { padding: 20px 24px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0; max-height: 65%; overflow-y: auto; }
.picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.picker-heading h2 { font-size: 22px; margin: 4px 0 0; }
.close-button { width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 20px; }
.picker-current { color: var(--muted); font-size: 12px; margin: 10px 0 12px; overflow-wrap: anywhere; }
.search-label { color: var(--muted); font-size: 12px; }
#picker-search, #picker-cat, .picker-filters select { display: block; width: 100%; min-width: 0; border: 1px solid #3b5365; border-radius: 8px; padding: 12px 14px; margin-top: 6px; background: var(--card); color: var(--text); font-size: 14px; }
.picker-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 12px; }
.picker-filters label { min-width: 0; }
.picker-filters select { min-height: 44px; padding: 9px 8px; font-size: 12px; }
.picker-delta-note { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.picker-item-group { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; overflow-wrap: anywhere; }
.picker-delta { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.picker-delta.down { color: var(--ok); }
.picker-cat { margin-bottom: 12px; }
.picker-count { color: var(--muted); font-size: 11px; margin-top: 10px; }
.picker-results { overflow-y: auto; padding: 8px 24px 28px; flex: 1; min-height: 0; }
.picker-group { color: var(--muted); font-size: 12px; font-weight: 500; margin: 22px 0 10px; }
.picker-item { display: block; width: 100%; text-align: left; color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 14px; margin-bottom: 8px; }
.picker-item:hover { border-color: var(--accent); background: var(--raised); }
.picker-item[aria-pressed=true] { border-color: var(--accent); background: var(--accent-bg); }
.picker-name { display: block; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.picker-price { display: flex; align-items: center; justify-content: space-between; color: var(--accent); font-size: 16px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.picker-price small { color: var(--muted); font-size: 11px; }
.no-results { padding: 48px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.mobile-actions { display: flex; gap: 8px; }
/* ---- 店家模式：左欄店家報價、店家設定對話框 ---- */
.biz { margin-top: 28px; }
.biz-card { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 16px 18px; }
.biz-card > p { margin: 0 0 10px; font-size: 13px; }
.biz-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; color: var(--muted); }
.biz-row strong { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.biz-final { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; color: var(--text); font-weight: 600; }
.biz-final strong { font-size: 22px; color: var(--accent); }
.biz-field { display: block; margin-top: 14px; font-size: 12px; color: var(--muted); }
.biz-field > span { display: block; margin-bottom: 6px; }
.biz-field small { color: var(--muted); font-weight: 400; }
.biz-field input, .biz-field textarea, .biz-extra input { display: block; width: 100%; min-width: 0; min-height: 44px; border: 1px solid #3b5365; border-radius: 8px; padding: 9px 12px; background: #0d131b; color: var(--text); font-size: 14px; scroll-margin-bottom: calc(var(--mobile-bar-height, 0px) + 16px); }
.biz-field textarea { resize: vertical; line-height: 1.6; }
.biz-field input[type=date] { color-scheme: dark; }
.biz-price input { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
[aria-invalid=true] { border-color: var(--warn) !important; }
.biz-hint { color: var(--muted); font-size: 11.5px; margin: 6px 0 0; }
.biz-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; border-left: 2px solid var(--warn); background: var(--warn-bg); color: var(--warn); border-radius: 0 6px 6px 0; padding: 10px 12px; font-size: 12px; }
.biz-stale p { margin: 0; flex: 1 1 220px; }
.biz-extras { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.biz-extras legend { padding: 0; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.biz-extra { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.biz-extra input { min-height: 40px; }
.biz-extra-amount { text-align: right; font-variant-numeric: tabular-nums; }
.biz-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 5px 12px; border: 1px dashed #3b5365; border-radius: 999px; background: transparent; color: var(--accent); font-size: 12px; }
.chip:hover:not(:disabled) { background: var(--accent-bg); border-color: var(--accent); }
.biz-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.biz-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.biz-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.shop-points { padding-left: 20px; line-height: 1.9; }
.shop-points li { margin: 6px 0; }
.store-shell { display: flex; flex-direction: column; height: 100%; }
.store-intro { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.store-import { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #315967; border-radius: 8px; background: var(--accent-bg); font-size: 12.5px; }
.store-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 20px; }
.store-body .biz-field.changed > span { color: var(--accent); }
.store-body .biz-field.changed input { border-color: var(--accent); }
.store-was { display: block; margin-top: 4px; font-size: 11px; }
.store-error { color: var(--warn); font-size: 12px; min-height: 1.6em; margin: 8px 0 0; }
.store-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.store-actions .b { min-width: 96px; min-height: 44px; }
.store-actions .text-button { min-height: 44px; }
/* ---- 唯讀估價單 (檢視模式 #v=1&q=)：深色頁面中間一張白色紙本單據 ---- */
body.view-mode .hero, body.view-mode #meta, body.view-mode .info-card { display: none; }
.sheet-view { max-width: 920px; margin: 32px auto 0; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin: 0 0 16px; }
.sheet-actions-end { display: flex; flex-wrap: wrap; gap: 10px; }
/* 紙張內重新宣告同名 token：既有的 .d / .up / .down / .gone / .renamed、表格框線、焦點外框自動換成淺色版 (對白底皆達 AA) */
.sheet {
  --bg: #fff; --card: #fff; --raised: #f3f5f7; --text: #1b2027; --muted: #56606c; --line: #d9dee4;
  --accent: #0a6876; --accent-bg: #e6f4f6; --warn: #b42318; --warn-bg: #fdf1f0; --ok: #0b6b4f;
  color-scheme: light; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
  border-radius: 6px; box-shadow: 0 30px 80px #0009, 0 0 0 1px #ffffff14; padding: 52px 56px 40px;
}
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 32px; padding-bottom: 18px; border-bottom: 2px solid var(--text); }
.sheet-kicker { color: var(--accent); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .26em; margin: 0 0 6px; }
.sheet h1 { font-size: 30px; line-height: 1.2; letter-spacing: .14em; margin: 0; }
.sheet h1:focus:not(:focus-visible) { outline: none; }
.sheet-issuer { margin: 0; text-align: right; color: var(--muted); font-size: 12px; }
.sheet-issuer strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.sheet-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 24px; margin: 22px 0 28px; }
.sheet-meta div { min-width: 0; }
.sheet-meta dt { color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.sheet-meta dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.sheet-meta dd .d { font-weight: 400; }
.sheet-table { table-layout: fixed; margin: 0; }
.sheet-table caption { caption-side: top; text-align: left; color: var(--muted); font-size: 12px; padding: 0 0 8px; }
.sheet-table col.c-item { width: 92px; }
.sheet-table col.c-qty { width: 56px; }
.sheet-table col.c-unit { width: 104px; }
.sheet-table col.c-sub { width: 112px; }
.sheet-table th, .sheet-table td { font-size: 13px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.sheet-table thead th { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; padding: 0 8px 8px; border-bottom: 1.5px solid var(--text); }
.sheet-table tbody th { color: var(--text); font-weight: 600; }
.sheet-table .c-name { line-height: 1.65; }
.sheet-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-table td.c-sub { font-weight: 600; }
.sheet .d { font-size: 11.5px; margin-top: 3px; }
.sheet .d.inl { margin-top: 0; }
.sheet-totals { width: min(100%, 380px); margin: 18px 0 0 auto; }
.sheet-totals div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; }
.sheet-totals dt { color: var(--muted); font-size: 13px; }
.sheet-totals dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet-totals .t-main { border-bottom: 2px solid var(--text); padding: 4px 0 12px; }
.sheet-totals .t-main dt { color: var(--text); font-size: 14px; font-weight: 600; }
.sheet-totals .t-main dd { font-size: 26px; letter-spacing: -.02em; }
.sheet-totals .t-net dd { font-size: 18px; }
.sheet-notes { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.sheet-notes h2 { font-size: 13px; letter-spacing: .08em; margin: 0 0 8px; }
.sheet-notes ul { margin: 0; padding-left: 18px; font-size: 12.5px; }
.sheet-notes li { margin: 4px 0; overflow-wrap: anywhere; }
.sheet-notes li.warn { color: var(--warn); }
.sheet-foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sheet-foot p { margin: 0 0 4px; }
/* 店家估價單：抬頭換成店家區塊、合計最後一列是本店合計、店家備註保留換行 */
.sheet-store { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 1px; max-width: 360px; font-size: 12.5px; color: var(--muted); }
.sheet-head > div:first-child { margin-right: auto; }
/* QR：svg 自帶 width/height (每格 2px，版本 23 約 234px)，不在這裡定死；--qr-n = 含留白的格數，列印每格 0.4mm */
.sheet-qr { text-align: center; }
.sheet-qr svg { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 4px; }
.sheet-qr small { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); }
.sheet-qr .qr-none { max-width: 200px; margin: 0 auto; font-size: 11px; }
.recent-clear { grid-column: 1 / -1; justify-self: start; }
.sheet-store .store-name { color: var(--text); font-size: 18px; font-weight: 700; letter-spacing: .02em; overflow-wrap: anywhere; }
.sheet-store .store-tag { color: var(--accent); font-size: 12px; margin-bottom: 4px; overflow-wrap: anywhere; }
.sheet-store .store-line { overflow-wrap: anywhere; }
.sheet-store a.store-link { color: var(--text); font-weight: 600; text-decoration: underline 1px var(--line); text-underline-offset: 4px; }
.sheet-store a.store-link:hover { color: var(--accent); text-decoration-color: var(--accent); }
.sheet-totals .t-final { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 12px; }
.sheet-totals .t-final dt { color: var(--text); font-size: 14px; font-weight: 600; }
.sheet-totals .t-final dd { font-size: 26px; letter-spacing: -.02em; }
.sheet-totals dd .d { text-align: right; }
.sheet-notes li.memo { color: var(--text); white-space: pre-wrap; list-style: none; margin-left: -18px; padding: 8px 12px; margin-bottom: 8px; border-left: 2px solid var(--accent); background: var(--raised); }
@media (max-width: 1023px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .summary-card { position: static; }
  .summary-card .btns { grid-template-columns: 1fr 1fr; }
  .summary-secondary { grid-column: 1 / -1; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: fixed; inset: auto 0 0; padding: 10px 24px calc(10px + env(safe-area-inset-bottom)); background: #111a24f5; border-top: 1px solid #36485a; backdrop-filter: blur(16px); z-index: 3; }
  .mobile-bar .summary-label { font-size: 10px; }
  .mobile-total { display: block; font-size: 23px; line-height: 1.4; font-weight: 600; font-variant-numeric: tabular-nums; }
  .mobile-bar .b { padding-inline: 20px; }
  body { padding-bottom: calc(var(--mobile-bar-height, 100px) + 16px); }
  #toast { bottom: calc(var(--mobile-bar-height, 100px) + 12px); }
  /* 檢視模式沒有底部列，不用留空間 */
  body.view-mode { padding-bottom: env(safe-area-inset-bottom); }
  body.view-mode #toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
  .sheet { padding: 40px 32px 32px; }
  .sheet-table col.c-item { width: 72px; }
  .sheet-table col.c-qty { width: 44px; }
  .sheet-table col.c-unit { width: 86px; }
  .sheet-table col.c-sub { width: 94px; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 18px 30px; }
  .topbar-note { display: none; }
  .store-entry { min-height: 44px; max-width: 170px; }
  .biz-card { padding: 14px; }
  .biz-grid { grid-template-columns: 1fr; }
  .biz-extra { grid-template-columns: minmax(0, 1fr) 96px; }
  .biz-extra .remove { grid-column: 1 / -1; justify-self: end; min-height: 44px; min-width: 44px; margin-top: -4px; }
  .biz-extra input { min-height: 44px; }
  .chip { min-height: 44px; }
  .store-body { padding-inline: 18px; }
  .store-actions { padding-inline: 18px; }
  .sheet-store { order: -1; flex-basis: 100%; align-items: flex-start; text-align: left; max-width: none; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .sheet-qr { flex-basis: 100%; }
  .sheet-store a.store-link { display: inline-flex; align-items: center; min-height: 44px; }
  .topbar { height: 64px; }
  .topbar-note { font-size: 10px; }
  .brand { font-size: 11px; gap: 9px; }
  .brand-mark { width: 28px; height: 28px; }
  .hero { padding: 16px 0 12px; }
  h1 { font-size: 28px; }
  .lead { font-size: 13px; }
  .meta { font-size: 11px; gap: 6px 14px; margin-bottom: 18px; }
  .section-heading > span { font-size: 10px; }
  .section-heading h2 { font-size: 15px; }
  .tabs { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
  .purpose-toolbar { gap: 4px; flex-wrap: wrap; }
  .purpose-button { padding: 7px 10px; font-size: 12px; }
  .purpose-toolbar > .text-button { margin-left: auto; }
  .preset-summary { padding: 12px 14px; gap: 8px 12px; flex-wrap: wrap; }
  .preset-current { flex-basis: 100%; }
  .preset-amount { text-align: left; margin-right: auto; }
  .tab { padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: center; }
  .tab-title { font-size: 14px; justify-content: flex-start; gap: 8px; }
  .tab-check { width: 15px; height: 15px; font-size: 9px; order: -1; }
  .tab small { grid-column: 1; margin: 0; font-size: 10px; }
  .tab-price { grid-column: 2; grid-row: 1 / 3; font-size: 17px; }
  .tab-price span { display: block; font-size: 10px; text-align: right; margin: 2px 0 0; }
  .tab.shared { padding: 14px 16px; }
  .tab.shared small { margin: 0; }
  .part { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
  .part-icon { width: 30px; height: 30px; border-radius: 7px; }
  .part-icon svg { width: 18px; height: 18px; }
  .part-name { font-size: 13px; }
  .part-actions { gap: 4px; }
  .part-actions .text-button { min-width: 44px; min-height: 44px; padding: 6px; }
  input[type=number] { min-height: 44px; }
  .scope-btn, .mobile-actions .b, .purpose-toolbar > .text-button, .build-note summary, .recent-clear { min-height: 44px; }
  .part-price { max-width: 100%; }
  .unit-price { font-size: 10px; }
  .subtotal { font-size: 15px; }
  .summary-card { padding: 22px; }
  .summary-card .btns { grid-template-columns: 1fr; }
  .total { font-size: 34px; }
  .mobile-bar { padding-inline: 18px; }
  .mobile-bar .b { padding-inline: 14px; font-size: 12px; }
  .picker-header { padding: 16px 18px 12px; }
  .picker-heading .eyebrow { margin-bottom: 6px; }
  .picker-heading h2 { font-size: 20px; }
  .picker-results { padding-inline: 18px; }
  dialog { border: 0; }
  .mobile-actions .b { padding-inline: 12px; }
  .sheet-view { margin-top: 22px; }
  .sheet-actions-end { width: 100%; }
  .sheet-actions .b { flex: 1 1 auto; }
  .sheet { padding: 26px 18px 22px; border-radius: 4px; }
  .sheet h1 { font-size: 24px; }
  .sheet-issuer { text-align: left; }
  .sheet-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 14px 0 16px; }
  .sheet-meta .sheet-meta-name { grid-column: 1 / -1; }
  .sheet-meta dd { font-size: 12px; }
}
/* 手機的估價明細改成一列一張：項目 / 品名 / 數量・單價・小計 (只在螢幕上，列印維持表格) */
@media screen and (max-width: 600px) {
  .sheet-top-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-top: 1px solid var(--line); margin-bottom: 16px; padding-top: 10px; }
  .sheet-top-total span { color: var(--muted); font-size: 12px; }
  .sheet-top-total strong { font-size: 23px; font-variant-numeric: tabular-nums; }
  .sheet-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sheet-table, .sheet-table tbody, .sheet-table caption { display: block; }
  .sheet-table tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "item item item" "name name name" "qty unit sub"; gap: 4px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .sheet-table tbody th, .sheet-table td { display: block; padding: 0; border: 0; }
  .sheet-table .c-item { grid-area: item; color: var(--muted); font-size: 11px; }
  .sheet-table .c-name { grid-area: name; }
  .sheet-table .c-qty { grid-area: qty; text-align: left; }
  .sheet-table .c-unit { grid-area: unit; text-align: left; }
  .sheet-table .c-sub { grid-area: sub; }
  .sheet-table td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 11px; font-weight: 400; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
/* 列印 / 存成 PDF：檢視模式只印紙張；編輯模式至少不印底部列 */
@media print {
  @page { margin: 12mm; }
  .mobile-bar, #toast, dialog { display: none !important; }
  body { padding-bottom: 0 !important; }
  /* :root 是 color-scheme: dark，不改的話 PDF 的頁邊會印成深色畫布 */
  :root:has(body.view-mode) { color-scheme: light; background: #fff; }
  body.view-mode { background: #fff; color: #000; }
  body.view-mode::before, body.view-mode .topbar, body.view-mode .load-state, body.view-mode .footer, body.view-mode .sheet-actions { display: none !important; }
  body.view-mode .wrap { max-width: none; padding: 0; }
  .sheet-view { max-width: none; margin: 0; }
  .sheet { box-shadow: none; border-radius: 0; padding: 0 1mm; --text: #000; --muted: #333; --line: #999; }
  .sheet-table thead { display: table-header-group; }
  .sheet-qr svg { width: calc(var(--qr-n, 117) * 0.4mm); height: calc(var(--qr-n, 117) * 0.4mm); max-width: none; }
  .sheet-table tr, .sheet-totals, .sheet-notes li, .sheet-meta, .sheet-store { break-inside: avoid; }
  .sheet-store a.store-link { text-decoration: none; }
  .sheet-notes li.memo { background: none; }
  .sheet h2 { break-after: avoid; }
  .sheet a { color: inherit; text-decoration: none; }
}
