/*
 * Invoice and quote builder (public/js/inv/invoice.js, public/js/inv/builder/*). Tokens come from app.css; solid colours
 * only. 8px grid, 13 to 14px UI text, tabular numbers for money, 1px borders, shadows only on floating layers.
 */
body.bd-page { --top-h: 60px; background: var(--bg); }
@media (max-width: 1100px) { body.bd-page { --top-h: 56px; } }
body.bd-page > footer, body.bd-page .footer { display: none; }
.bd [hidden], .bd-page .bd-pop [hidden], .bd-panel [hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.bd { --gutter: 40px; display: flex; flex-direction: column; min-height: calc(100vh - var(--header-h)); font-size: 13.5px; }
.bd button { font: inherit; }

/* ---------------- buttons ---------------- */
.bd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.bd-btn:hover { background: var(--surface-2); text-decoration: none; }
.bd-btn:disabled { opacity: .5; cursor: not-allowed; }
.bd-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bd-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.bd-btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.bd-btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.bd-btn.danger { color: var(--danger); }
.bd-btn.danger:hover { background: var(--danger-soft); }
.bd-btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.bd-icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.bd-icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.bd-icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; }
.bd-icon-btn.xs .i { width: 13px; height: 13px; }
.bd-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--accent-text); font-size: 13px; font-weight: 500; cursor: pointer; }
.bd-link:hover { text-decoration: underline; }
.bd-link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.bd-text-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--accent-text); font-size: 13px; font-weight: 500; cursor: pointer; }
.bd-text-btn:hover { background: var(--accent-soft); }
.bd-split { display: inline-flex; }
.bd-split > .bd-btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bd-split > .bd-split-caret { width: 30px; padding: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid color-mix(in srgb, var(--on-accent) 28%, var(--accent)); }
.bd-seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.bd-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 26px; min-width: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.bd-seg button:hover { color: var(--text); }
.bd-seg button.on { background: var(--surface); border-color: var(--border); color: var(--text); }
.bd-seg.xs button { height: 22px; min-width: 26px; padding: 0 6px; font-size: 11.5px; }
.bd-seg.sm button { height: 30px; min-width: 40px; }
.bd kbd, .bd-kbd { margin-left: auto; padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font: 500 11px/18px var(--font); }

/* ---------------- top bar ---------------- */
.bd-top { position: sticky; top: var(--header-h); z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--top-h); padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.bd-top-left, .bd-top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bd-top-right { flex: none; }
.bd-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bd-title h1 { display: flex; align-items: center; gap: 2px; margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.bd-page input.bd-num { width: auto; height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; box-shadow: none; color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.bd-page input.bd-num:not(:disabled):hover { border-color: var(--border); }
.bd-page input.bd-num:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: var(--surface); }
.bd-page input.bd-num:disabled { color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; cursor: default; }
.bd-page input.bd-num::placeholder { color: var(--muted); }
.bd-from { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.bd-save-state { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.bd-save-state.ok .i { color: var(--success); }
.bd-save-state.warn::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.bd-save-state.err { color: var(--danger); }
.bd-status { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.bd-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bd-status.st-sent, .bd-status.st-viewed { background: #e0ecff; color: #1d4ed8; }
.bd-status.st-partial { background: var(--warning-soft); color: var(--warning); }
.bd-status.st-paid, .bd-status.st-accepted, .bd-status.st-converted { background: var(--success-soft); color: var(--success); }
.bd-status.st-overdue, .bd-status.st-declined { background: var(--danger-soft); color: var(--danger); }
.bd-status.st-void, .bd-status.st-expired { background: var(--surface-3); color: var(--muted); }
:root[data-theme="dark"] .bd-status.st-sent, :root[data-theme="dark"] .bd-status.st-viewed { background: #1b2a4a; color: #93b4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bd-status.st-sent, :root:not([data-theme="light"]) .bd-status.st-viewed { background: #1b2a4a; color: #93b4ff; } }
.bd-spin { width: 12px; height: 12px; flex: none; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------------- body: editor sheet and preview ---------------- */
.bd-body { flex: 1; display: grid; grid-template-columns: minmax(560px, 640px) minmax(0, 1fr); align-items: start; }
.bd-editor { min-width: 0; min-height: calc(100vh - var(--header-h) - var(--top-h)); background: var(--surface); border-right: 1px solid var(--border); }
.bd-sheet { padding: 4px var(--gutter) 72px; }
.bd-preview { position: sticky; top: calc(var(--header-h) + var(--top-h)); height: calc(100vh - var(--header-h) - var(--top-h)); display: flex; flex-direction: column; min-width: 0; }
.bd-preview-head { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 24px; flex: none; }
.bd-preview-title { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.bd-updating { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.bd-zoom { margin-left: auto; }
.bd-preview-stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: flex-start; padding: 0 24px 24px; overflow: auto; }
.bd-paper { position: relative; max-width: 100%; cursor: zoom-in; border-radius: 4px; }
.bd-paper .preview-img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100vh - var(--header-h) - var(--top-h) - 68px); background: #fff; border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow-sm); transition: opacity .15s; }
.bd-preview.fill .bd-paper { width: 100%; cursor: zoom-out; }
.bd-preview.fill .preview-img { width: 100%; max-height: none; }
.bd-preview.updating .preview-img { opacity: .72; }
.bd-paper-skel { width: min(100%, calc((100vh - var(--header-h) - var(--top-h) - 68px) / 1.414)); aspect-ratio: 1 / 1.414; padding: 9% 8%; display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 4px; }
.bd-paper-skel span { display: block; height: 10px; border-radius: 4px; background: #eceee8; animation: bd-pulse 1.4s ease-in-out infinite; }
.bd-paper-skel .gap { margin-top: 22px; }
.bd-paper-skel .w25 { width: 25%; } .bd-paper-skel .w35 { width: 35%; } .bd-paper-skel .w40 { width: 40%; height: 16px; } .bd-paper-skel .w50 { width: 50%; } .bd-paper-skel .w60 { width: 60%; } .bd-paper-skel .w70 { width: 70%; } .bd-paper-skel .w90 { width: 90%; }
@keyframes bd-pulse { 50% { opacity: .45; } }
.bd-skel-row { height: 44px; margin-bottom: 8px; border-radius: 8px; background: var(--surface-2); animation: bd-pulse 1.4s ease-in-out infinite; }

/* Layout modes: Edit, Split, Preview (desktop) */
.bd.view-edit .bd-body { grid-template-columns: minmax(0, 1fr); }
.bd.view-edit .bd-preview { display: none; }
.bd.view-edit .bd-editor { width: 100%; max-width: 880px; justify-self: center; border-left: 1px solid var(--border); }
.bd.view-preview .bd-body { grid-template-columns: minmax(0, 1fr); }
.bd.view-preview .bd-editor { display: none; }
.bd.view-preview .bd-paper { max-width: 900px; }
.bd-phone-tabs { display: none; }
.bd-bottom { display: none; }

/* ---------------- sections and fields ---------------- */
.bd-sec { padding: 28px 0; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + var(--top-h) + 16px); }
.bd-sec:first-child, .bd-notice + .bd-sec { border-top: 0; }
.bd-sec-head { margin-bottom: 14px; }
.bd-sec-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.bd-sec-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.bd-notice { display: flex; align-items: center; gap: 10px; margin: 20px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-weight: 500; }
.bd-notice > span { flex: 1; }
.bd-notice > .i { flex: none; }
.bd-profile { flex-wrap: wrap; }
.bd-profile > span:not(.i) { min-width: 200px; }
.bd-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
.bd-details.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
.bd-field { display: flex; flex-direction: column; min-width: 0; }
.bd-field.wide { grid-column: 1 / -1; }
.bd-field[hidden] { display: none; }
.bd-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.bd-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.bd-label-row .bd-label, .bd-label-row h3 { margin: 0; }
.bd-help { margin-top: 5px; color: var(--muted); font-size: 12px; }
.bd-error-text { color: var(--danger); font-size: 12.5px; }
.bd-error-text:not(:empty) { margin-top: 6px; }
.bd-muted-note { display: block; margin: 0; color: var(--muted); font-size: 12.5px; }
span.bd-muted-note { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--muted); font-size: 12.5px; }
.bd-muted-note .i { width: 13px; height: 13px; }
.bd-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.bd-inline { display: flex; gap: 8px; align-items: center; }
.bd-inline > input { flex: 1; min-width: 0; }

/* inputs (scoped above app.css input rules) */
.bd-page .bd-input, .bd-page .bd-panel input[type=text], .bd-page .bd-panel input[type=email], .bd-page .bd-panel input[type=tel], .bd-page .bd-panel textarea, .bd-page .bd-ledger input[type=text], .bd-page .bd-ledger select,
.bd-page .bd-pop input[type=text], .bd-page .bd-textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; box-shadow: none; }
.bd-page .bd-textarea, .bd-page .bd-panel textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: none; line-height: 1.5; overflow: hidden; }
.bd-page .bd-input:hover, .bd-page .bd-textarea:hover { border-color: var(--muted); }
.bd-page .bd-input:focus, .bd-page .bd-textarea:focus, .bd-page .bd-panel input:focus, .bd-page .bd-panel textarea:focus, .bd-page .bd-pop input[type=text]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-page .bd-input:disabled, .bd-page .bd-textarea:disabled { background: var(--surface-2); color: var(--text-2); -webkit-text-fill-color: var(--text-2); opacity: 1; }
.bd-page [aria-invalid="true"] { border-color: var(--danger) !important; }
.bd-select { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; min-height: 34px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer; }
.bd-select:hover:not(:disabled) { border-color: var(--muted); }
.bd-select[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-select:disabled { background: var(--surface-2); color: var(--text-2); cursor: default; }
.bd-select > .i { color: var(--muted); }
.bd-select-text { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; flex: 1; min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.bd-select-text.placeholder { color: var(--muted); }
.bd-date { justify-content: flex-start; }
.bd-date .bd-select-text { font-variant-numeric: tabular-nums; }
.bd-cur-code { font-weight: 600; }
.bd-cur-name { color: var(--muted); font-size: 12.5px; }
.bd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bd-chip-btn { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.bd-chip-btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.bd-chip-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.bd-chip-btn:disabled { cursor: default; opacity: .6; }
.bd-chip-btn.on:disabled { opacity: 1; }

/* ---------------- customer ---------------- */
.bd-combo { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--muted); }
.bd-combo:hover { border-color: var(--muted); }
.bd-combo:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-combo.invalid { border-color: var(--danger); }
.bd-page .bd-combo input.bd-combo-input { flex: 1; height: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--text); font-size: 14px; outline: none; }
.bd-cust-card { display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.bd-cust-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.bd-cust-text b { font-size: 14px; font-weight: 600; }
.bd-cust-text span { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.bd-cust-text .bd-cust-addr { margin-top: 2px; color: var(--muted); font-size: 12.5px; white-space: pre-line; }
.bd-cust-flag { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--warning) !important; font-size: 12px !important; }
.bd-cust-actions { display: flex; gap: 2px; flex: none; }
.bd-avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 600; letter-spacing: .02em; }
.bd-cust-opt { gap: 10px; }
.bd-cust-opt-text { display: flex; flex-direction: column; min-width: 0; }
.bd-cust-opt-text .bd-option-hint { margin-left: 0; }
.bd-create { color: var(--accent-text); font-weight: 500; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.bd-create-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); }

/* ---------------- items table ---------------- */
.bd-table-wrap { margin: 0 calc(var(--gutter) * -1); }
.bd-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.bd-table col.w-grip, .bd-table col.w-menu { width: var(--gutter); }
.bd-table col.w-qty { width: 64px; }
.bd-table col.w-unit { width: 64px; }
.bd-table col.w-price { width: 92px; }
.bd-table col.w-disc { width: 104px; }
.bd-table col.w-tax { width: 76px; }
.bd-table col.w-amt { width: 1%; }
.bd-table th { padding: 0 4px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
.bd-table th.num { text-align: right; padding-right: 10px; }
.bd-table th.c-amt { padding-right: 4px; }
.bd-table th.c-grip, .bd-table th.c-menu, .bd-table td.c-grip, .bd-table td.c-menu { border-bottom: 0; padding: 0; }
.bd-table td { padding: 5px 2px; border-bottom: 1px solid var(--border); vertical-align: top; }
.bd-table td.c-grip { text-align: right; padding-right: 2px; }
.bd-table td.c-menu { padding-left: 4px; }
.bd-table tr:last-child td:not(.c-grip):not(.c-menu) { border-bottom-color: var(--border); }
.bd-item-cell { display: flex; gap: 8px; align-items: flex-start; }
.bd-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bd-page .bd-cell { width: 100%; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; box-shadow: none; color: var(--text); font: inherit; font-size: 13.5px; }
.bd-page .bd-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.bd-page .bd-cell:hover:not(:disabled) { background: var(--surface-2); }
.bd-page .bd-cell:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-page .bd-cell:disabled { color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; }
.bd-page .bd-cell.invalid { border-color: var(--danger); background: var(--danger-soft); }
.bd-page .bd-cell::placeholder { color: var(--muted); opacity: .8; }
.bd-page .bd-name { font-weight: 500; }
.bd-page textarea.bd-desc { height: auto; min-height: 26px; padding: 3px 8px; color: var(--muted); font-size: 12.5px; line-height: 1.45; resize: none; overflow: hidden; }
.bd-page textarea.bd-desc:focus { color: var(--text-2); }
.bd-row .bd-desc:placeholder-shown:not(.open), .bd-row .bd-desc:disabled:placeholder-shown { display: none; }
.bd-amt { display: block; padding: 0 4px 0 10px; line-height: 32px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.bd-grip, .bd-rowmenu { opacity: 0; transition: opacity .12s; }
.bd-grip { display: inline-grid; place-items: center; width: 22px; height: 32px; margin-top: 0; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: grab; touch-action: none; }
.bd-grip:hover { background: var(--surface-2); color: var(--text); }
.bd-row:hover .bd-grip, .bd-row:focus-within .bd-grip, .bd-row:hover .bd-rowmenu, .bd-row:focus-within .bd-rowmenu, .bd-grip:focus-visible, .bd-rowmenu:focus-visible, .bd-rowmenu[aria-expanded="true"] { opacity: 1; }
.bd-grip:disabled { display: none; }
.bd-rowmenu { width: 28px; height: 32px; }
@media (hover: none) { .bd-grip, .bd-rowmenu { opacity: .7; } }
.bd-row.dragging td:not(.c-grip):not(.c-menu) { background: var(--surface); border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.bd-row.dragging { position: relative; z-index: 2; }
.bd-row.dragging .bd-grip { opacity: 1; cursor: grabbing; color: var(--accent-text); }
tbody.sorting .bd-row:not(.dragging) { transition: transform .15s ease; }
tbody.sorting { cursor: grabbing; user-select: none; }
.bd-taxbtn { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; width: 100%; min-height: 32px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; text-align: left; }
.bd-taxbtn:hover:not(:disabled) { background: var(--surface-2); }
.bd-taxbtn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-taxbtn:disabled { cursor: default; }
.bd-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bd-tax-none { color: var(--muted); font-size: 12.5px; opacity: .8; }
.bd-thumb { display: block; width: 32px; height: 32px; flex: none; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); overflow: hidden; cursor: pointer; }
.bd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bd-thumb.none { border-style: dashed; background: none; cursor: default; }
.bd-disc { display: flex; align-items: center; gap: 2px; }
.bd-unit-toggle { flex: none; height: 24px; min-width: 26px; padding: 0 5px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 600; cursor: pointer; }
.bd-dash { display: block; height: 32px; }
.bd-empty-row { padding: 20px 8px !important; color: var(--muted); text-align: center; font-size: 13px; }
.bd-add-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0 0 -8px; }

/* totals */
.bd-totals { display: flex; justify-content: flex-end; margin-top: 20px; }
.bd-totals-inner { width: min(340px, 100%); display: flex; flex-direction: column; }
.bd-trow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; color: var(--text-2); }
.bd-tlabel { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.bd-tval { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.bd-trow.add { min-height: 28px; }
.bd-trow.total { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text); font-weight: 600; }
.bd-trow.total .bd-tval { font-size: 22px; letter-spacing: -.02em; font-weight: 650; }
.bd-trow.paid { margin-top: 4px; }
.bd-trow.due { font-weight: 600; color: var(--text); }
.bd-trow.due .bd-tval { font-size: 15px; }
.bd-trow.bd-autotax-head { margin-top: 4px; color: var(--text); font-weight: 550; font-size: 13px; }
.bd-trow.bd-autotax-head .bd-tval { color: var(--muted); font-weight: 400; font-size: 12px; }
.bd-trow.bd-jur { min-height: 28px; padding-left: 20px; font-size: 13px; }
.bd-trow.bd-taxnotice { justify-content: flex-start; align-items: flex-start; gap: 8px; margin: 6px 0 2px; padding: 8px 10px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-size: 12.5px; line-height: 1.4; }
.bd-trow.bd-taxnotice .i { flex: none; margin-top: 2px; }
.bd-chip.bd-chip-auto { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.bd-taxcode-pop .bd-listbox { max-height: 280px; overflow: auto; }
.bd-taxcode-pop .bd-option { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.bd-taxcode-pop .bd-option:hover, .bd-taxcode-pop .bd-option:focus-visible { background: var(--surface-2); outline: none; }
.bd-taxcode-pop .bd-option-hint { margin-left: auto; color: var(--muted); font-size: 11px; }
.bd-page input.bd-mini { width: 72px; height: 28px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); box-shadow: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.bd-page input.bd-mini:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* phone rows */
.bd-mlist { border-top: 1px solid var(--border); }
.bd-mrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); text-align: left; cursor: pointer; }
.bd-mrow:active { background: var(--surface-2); }
.bd-mthumb { width: 36px; height: 36px; flex: none; border-radius: 6px; border: 1px solid var(--border); object-fit: cover; }
.bd-mrow-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.bd-mrow-name { font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.bd-mrow-name.muted { color: var(--muted); }
.bd-mrow-sub { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bd-mrow-amt { padding: 0; line-height: 1.4; font-size: 14.5px; }

/* notes, attachments, payments, options */
.bd-notes { display: grid; gap: 20px; }
.bd-default { font-size: 12.5px; }
.bd-attach { display: grid; gap: 12px; }
.bd-drop { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--text-2); transition: background .12s, border-color .12s; }
.bd-drop > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.bd-drop b { font-weight: 500; color: var(--text); }
.bd-drop span { color: var(--muted); }
.bd-drop .bd-link { font-size: inherit; }
.bd-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.bd-drop.off { opacity: .7; }
.bd-drop-ic { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.bd-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bd-file { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 4px 2px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.bd-pay-list { display: flex; flex-direction: column; }
.bd-pay-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.bd-pay-row:first-child { padding-top: 0; }
.bd-pay-logo { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 7px; overflow: hidden; background: var(--surface-2); color: var(--muted); }
.bd-pay-logo svg { width: 100%; height: 100%; display: block; }
.bd-pay-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bd-pay-text b { font-weight: 500; }
.bd-pay-text span { color: var(--muted); font-size: 12.5px; }
.bd-switches { display: flex; flex-direction: column; }
.bd-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.bd-switch-row:first-child { padding-top: 0; }
.bd-switch-row:last-child { border-bottom: 0; }
.bd-switch-row > div { display: flex; flex-direction: column; min-width: 0; }
.bd-switch-row b { font-weight: 500; }
.bd-switch-row span { color: var(--muted); font-size: 12.5px; }
.bd-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none; cursor: pointer; }
.bd-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.bd-switch-track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.bd-switch-thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.bd-switch input:checked + .bd-switch-track { background: var(--accent); }
.bd-switch input:checked + .bd-switch-track .bd-switch-thumb { transform: translateX(14px); }
.bd-switch input:focus-visible + .bd-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.bd-switch input:disabled { cursor: not-allowed; }
.bd-switch input:disabled + .bd-switch-track { opacity: .5; }
.bd-ledger .field { margin-bottom: 14px; }
.bd-ledger .field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.bd-design-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.bd-design-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.bd-design-thumb { width: 40px; height: 56px; flex: none; object-fit: cover; object-position: top; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.bd-design-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.bd-design-text b { font-weight: 500; }
.bd-design-text > span { color: var(--muted); font-size: 12.5px; }
.bd-design-text .bd-dot { margin-right: 6px; vertical-align: -1px; }
.bd-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--text) 15%, transparent); }

/* ---------------- floating layers ---------------- */
.bd-pop { position: fixed; z-index: 1000; min-width: 180px; max-width: calc(100vw - 16px); padding: 4px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06); color: var(--text); font-size: 13.5px; animation: bd-pop .12s ease; overscroll-behavior: contain; }
.bd-pop:focus { outline: none; }
@keyframes bd-pop { from { opacity: 0; transform: translateY(-4px); } }
.bd-menu, .bd-listbox { display: flex; flex-direction: column; }
.bd-menu-item, .bd-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 13.5px; text-align: left; cursor: pointer; }
.bd-menu-item:hover, .bd-menu-item:focus, .bd-option:hover, .bd-option.active { background: var(--surface-2); color: var(--text); outline: none; }
.bd-menu-item:disabled { opacity: .5; cursor: default; }
.bd-menu-item.danger { color: var(--danger); }
.bd-menu-item.danger:hover, .bd-menu-item.danger:focus { background: var(--danger-soft); }
.bd-menu-item .i { color: var(--muted); }
.bd-menu-item.danger .i { color: inherit; }
.bd-menu-label { flex: 1; white-space: nowrap; }
.bd-check { display: inline-grid; place-items: center; width: 16px; color: var(--accent-text); }
.bd-menu-sep { height: 1px; margin: 4px; background: var(--border); }
.bd-menu-head { padding: 8px 8px 4px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bd-option-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bd-option-hint { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bd-option[aria-selected="true"] > .i { color: var(--accent-text); }
.bd-option .i { flex: none; }
.bd-empty-opt { padding: 10px 8px; color: var(--muted); font-size: 13px; }
.bd-pop-search { margin-bottom: 4px; }
.bd-select-pop { display: flex; flex-direction: column; }
.bd-pop-select .bd-listbox { max-height: 320px; overflow: auto; }
.bd-tag { margin-left: 6px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 500; }
.bd-taxpop { display: flex; flex-direction: column; padding: 4px; }
.bd-check-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.bd-check-row:hover { background: var(--surface-2); }
.bd-check-row > span:first-of-type { flex: 1; }
.bd-check-row.small { font-size: 12.5px; color: var(--text-2); }
.bd-taxnew { display: grid; grid-template-columns: 1fr 80px; gap: 6px; padding: 0 4px 4px; }
.bd-taxpop > .bd-btn { margin: 6px 4px 2px; }
.bd-pop-note { margin: 4px 8px 8px; color: var(--muted); font-size: 12.5px; }
.bd-pop-link { margin: 4px 8px 4px; }
.bd-taxpop .bd-error-text { padding: 0 6px; }

/* calendar */
.bd-cal { padding: 8px; }
.bd-cal-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px; }
.bd-cal-title { font-weight: 600; font-size: 13.5px; }
.bd-cal-grid { display: flex; flex-direction: column; gap: 2px; }
.bd-cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.bd-cal-wd { display: grid; place-items: center; height: 26px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.bd-day { width: 100%; height: 34px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.bd-day:hover { background: var(--surface-2); }
.bd-day.out { color: var(--muted); opacity: .6; }
.bd-day.today { border-color: var(--border-strong); font-weight: 600; }
.bd-day.sel { background: var(--accent); color: var(--on-accent); font-weight: 600; border-color: var(--accent); }
.bd-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bd-cal-foot { display: flex; justify-content: flex-end; padding: 8px 4px 2px; }
.bd-cal-err { color: var(--danger); font-size: 12px; }

/* slide over panels and bottom sheets */
.bd-layer { position: fixed; inset: 0; z-index: 950; }
.bd-scrim { position: absolute; inset: 0; background: rgba(16, 24, 40, .32); animation: fade .15s; }
.bd-panel { position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: bd-slide .18s ease; }
.bd-layer.closing .bd-panel { animation: bd-slide-out .16s ease forwards; }
.bd-layer.closing .bd-scrim { opacity: 0; transition: opacity .15s; }
@keyframes bd-slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes bd-slide-out { to { transform: translateX(24px); opacity: 0; } }
.bd-layer.docked { inset: auto; }
.bd-layer.docked .bd-scrim { display: none; }
.bd-layer.docked .bd-panel { position: fixed; top: calc(var(--header-h) + var(--top-h)); bottom: 0; right: auto; border-left: 0; border-right: 1px solid var(--border); box-shadow: none; animation: bd-dock .16s ease; }
@keyframes bd-dock { from { opacity: 0; transform: translateX(-12px); } }
.bd-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 14px 24px; border-bottom: 1px solid var(--border); }
.bd-panel-head h2 { margin: 2px 0 0; font-size: 16px; font-weight: 600; }
.bd-panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.bd-panel-body { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px; overscroll-behavior: contain; }
.bd-panel-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); }
.bd-panel.sheet { top: auto; left: 0; right: 0; max-height: 90vh; border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; animation: bd-rise .2s ease; }
.bd-layer.closing .bd-panel.sheet { animation: bd-sink .16s ease forwards; }
@keyframes bd-rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes bd-sink { to { transform: translateY(40px); opacity: 0; } }
.bd-panel.sheet .bd-panel-head { padding: 6px 12px 10px 20px; }
.bd-panel.sheet .bd-panel-body { padding: 16px 20px; }
.bd-panel.sheet .bd-panel-foot { padding: 12px 20px calc(12px + var(--safe-b)); }
.bd-panel.sheet .bd-panel-foot .bd-btn { height: 40px; flex: 1; }
.bd-grabber { width: 36px; height: 4px; margin: 8px auto 2px; border-radius: 999px; background: var(--border-strong); }
.bd-form, .bd-sheet-form { display: flex; flex-direction: column; gap: 16px; }
.bd-form .bd-field, .bd-sheet-form .bd-field { margin: 0; }
.bd-moredetails { border-top: 1px solid var(--border); padding-top: 12px; }
.bd-moredetails > summary { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; list-style: none; }
.bd-moredetails > summary::-webkit-details-marker { display: none; }
.bd-moredetails > summary .i { transition: transform .15s; }
.bd-moredetails[open] > summary .i { transform: rotate(90deg); }
.bd-moredetails[open] > summary { margin-bottom: 14px; }
.bd-moredetails .bd-field { margin-bottom: 14px; }
.bd-chip-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.bd-chip-toggle { height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer; }
.bd-chip-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.bd-sheet-image { display: flex; align-items: center; gap: 12px; }
.bd-sheet-image img { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.bd-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

/* design panel */
.bd-design { display: flex; flex-direction: column; gap: 24px; }
.bd-dgroup h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.bd-dgroup > p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.bd-dgroup > h3 + .design-picks, .bd-dgroup > h3 + .bd-swatches, .bd-dgroup > h3 + .bd-seg { margin-top: 8px; }
.bd-design .design-picks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.bd-design .design-pick { gap: 6px; padding: 4px 4px 6px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.bd-design .design-pick:hover:not(:disabled) { border-color: var(--border-strong); }
.bd-design .design-pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); }
.bd-design .design-pick img { border-radius: 4px; }
.bd-design .design-pick span { padding: 0 2px; }
.bd-design .tpl-inv-pick { margin-top: 14px; }
.bd-design .tpl-inv-pick .lbl { font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.bd-design .design-picks.custom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bd-design .design-picks.custom .design-pick { flex-direction: row; align-items: center; padding: 8px; }
.bd-design .bd-dgroup > .bd-link { margin-top: 12px; }
.bd-swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bd-swatch { position: relative; width: 28px; height: 28px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.bd-swatch.on { box-shadow: 0 0 0 2px var(--text); }
.bd-swatch.custom { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); overflow: hidden; }
.bd-swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.bd-logo { display: flex; align-items: center; gap: 14px; }
.bd-logo img { max-width: 140px; max-height: 56px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.bd-logo-empty { display: grid; place-items: center; width: 56px; height: 56px; border: 1px dashed var(--border-strong); border-radius: 8px; color: var(--muted); }
.bd-logo-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* activity */
.bd-activity { display: flex; flex-direction: column; gap: 28px; }
.bd-activity .bd-label-row { margin-bottom: 10px; }
.bd-pays { margin: 0; padding: 0; list-style: none; }
.bd-pays li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.bd-pays li > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.bd-pays b { font-variant-numeric: tabular-nums; }
.bd-pays span { color: var(--muted); font-size: 12.5px; }
.bd-pay-acts { display: flex; gap: 4px; align-items: center; }
.bd-timeline { position: relative; margin: 8px 0 0; padding: 0; list-style: none; }
.bd-timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 18px; }
.bd-timeline li:not(:last-child)::before { content: ''; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--border); }
.bd-tl-dot { width: 9px; height: 9px; flex: none; margin-top: 6px; border-radius: 50%; background: var(--border-strong); }
.bd-tl-dot.t-payment, .bd-tl-dot.t-accepted, .bd-tl-dot.t-receipt { background: var(--success); }
.bd-tl-dot.t-sent, .bd-tl-dot.t-reminder, .bd-tl-dot.t-viewed { background: #3b82f6; }
.bd-tl-dot.t-overdue, .bd-tl-dot.t-declined, .bd-tl-dot.t-voided { background: var(--danger); }
.bd-timeline p { margin: 0; color: var(--text); }
.bd-timeline time { color: var(--muted); font-size: 12px; }

/* dialogs opened by the builder */
.bd-send-note { display: flex; align-items: center; gap: 6px; margin: 0; }
.bd-modal-form .field > span { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--text-2); }
.bd-modal-form .field { margin-bottom: 14px; }
.bd-modal-form .bd-select { height: 38px; }

/* ---------------- tablet: one column with Edit and Preview tabs ---------------- */
@media (max-width: 1280px) {
  .bd-body { grid-template-columns: minmax(540px, 600px) minmax(0, 1fr); }
  .bd-save-state span { display: none; }
  .bd-save-state.warn span, .bd-save-state.err span { display: inline; }
}
@media (max-width: 1100px) {
  .bd-hide-tablet, .bd-view { display: none !important; }
  .bd-save-state span { display: inline; }
  .bd-phone-tabs { display: block; padding: 12px 16px 0; }
  .bd-phone-tabs .bd-seg { display: flex; width: min(320px, 100%); margin: 0 auto; }
  .bd-phone-tabs .bd-seg button { flex: 1; height: 30px; font-size: 13px; }
  .bd .bd-body, .bd.view-edit .bd-body, .bd.view-preview .bd-body { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 24px; }
  .bd .bd-editor, .bd.view-preview .bd-editor { display: block; width: 100%; max-width: 760px; justify-self: center; min-height: 0; border: 1px solid var(--border); border-radius: 12px; }
  .bd .bd-preview, .bd.view-preview .bd-preview { display: none; position: static; height: auto; }
  .bd.tab-preview .bd-editor { display: none; }
  .bd.tab-preview .bd-preview { display: flex; }
  .bd-preview-head { height: 28px; padding: 0 4px; }
  .bd-preview-title { display: none; }
  .bd-preview-stage { padding: 0; overflow: visible; }
  .bd-paper, .bd-preview .bd-paper { width: 100%; max-width: 760px; cursor: default; }
  .bd-paper .preview-img { width: 100%; max-height: none; }
  .bd-paper-skel { width: 100%; }
  .bd-zoom { display: none; }
}
/* ---------------- phones ---------------- */
@media (max-width: 760px) {
  .bd { --gutter: 16px; font-size: 14px; }
  body.bd-page { padding-bottom: calc(72px + var(--safe-b)); }
  .bd-top { flex-wrap: nowrap; gap: 8px; padding: 8px 8px 8px 4px; }
  .bd-top-left { flex-wrap: wrap; row-gap: 0; column-gap: 4px; min-width: 0; flex: 1; }
  .bd-title { gap: 8px; flex-wrap: wrap; row-gap: 2px; }
  .bd-title h1 { font-size: 15px; }
  .bd-save-state { width: 100%; margin: 0 0 0 40px; font-size: 12px; }
  .bd-save-state:empty { display: none; }
  .bd-hide-phone { display: none !important; }
  .bd .bd-body, .bd.view-edit .bd-body, .bd.view-preview .bd-body { padding: 12px 0 16px; }
  .bd .bd-editor { border-radius: 0; border-left: 0; border-right: 0; }
  .bd-preview { padding: 0 12px; }
  .bd-sheet { padding: 0 16px 24px; }
  .bd-sec { padding: 22px 0; }
  .bd-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bd-details > .bd-field:first-child { grid-column: 1 / -1; }
  .bd-details > .bd-field:last-child { grid-column: 1 / -1; }
  .bd-details.two > .bd-field { grid-column: 1 / -1; }
  .bd-page .bd-input, .bd-page .bd-textarea, .bd-select, .bd-page .bd-panel input[type=text], .bd-page .bd-panel input[type=email], .bd-page .bd-panel input[type=tel], .bd-page .bd-panel textarea, .bd-page .bd-pop input[type=text], .bd-page .bd-combo input.bd-combo-input { font-size: 16px; }
  .bd-page .bd-input, .bd-select, .bd-page .bd-panel input[type=text], .bd-page .bd-panel input[type=email], .bd-page .bd-panel input[type=tel] { height: 40px; }
  .bd-chip-btn { height: 32px; padding: 0 12px; }
  .bd-cust-card { flex-wrap: wrap; }
  .bd-cust-actions { width: 100%; padding-left: 52px; margin-top: -2px; }
  .bd-totals-inner { width: 100%; }
  .bd-add-row { gap: 4px; margin-left: -8px; }
  .bd-drop { padding: 12px; }
  .bd-design .design-picks { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .bd-design .design-pick span { font-size: 11px; }
  .bd-bottom { position: fixed; z-index: 80; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px calc(10px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--border); }
  .bd-bottom-total { display: flex; flex-direction: column; min-width: 0; }
  .bd-bottom-total span { color: var(--muted); font-size: 12px; }
  .bd-bottom-total b { font-size: 19px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .bd-bottom .bd-btn { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
  .bd-panel { width: 100vw !important; }
  .toasts { bottom: calc(84px + var(--safe-b)) !important; }
}

/* loading skeleton (static markup in invoice.html until the builder renders) */
.bd-loading .bd-top { height: var(--top-h); }
.bd-loading .bd-sheet { display: flex; flex-direction: column; gap: 12px; padding-top: 28px; }
.bd-skel-line, .bd-skel-block { display: block; border-radius: 6px; background: var(--surface-2); animation: bd-pulse 1.4s ease-in-out infinite; }
.bd-skel-line { height: 12px; }
.bd-skel-line.w20 { width: 20%; margin-top: 16px; } .bd-skel-line.w30 { width: 220px; height: 16px; }
.bd-skel-block { height: 44px; }
.bd-skel-block.short { height: 96px; } .bd-skel-block.tall { height: 180px; }

/* accounting fields from the ledger module, matched to the builder */
.bd-ledger .dims { gap: 12px; }
.bd-page .bd-ledger select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6d66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
.bd-page .bd-ledger select:focus, .bd-page .bd-ledger input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.bd-page textarea.bd-name { height: auto; min-height: 32px; padding: 6px 8px 4px; line-height: 1.4; resize: none; overflow: hidden; }
.bd-page .bd-panel textarea.bd-sheet-name { min-height: 40px; padding: 8px 10px; }

/* custom fields (public/js/acct/custom-fields.js) inside the builder and the customer panel */
.bd-cf .cf-grid { gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.bd-cf label.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.bd-page .bd-cf input:not([type=checkbox]), .bd-page .bd-cf select { height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background-color: var(--surface); box-shadow: none; font-size: 13.5px; }
.bd-page .bd-cf input:not([type=checkbox]):focus, .bd-page .bd-cf select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
@media (min-width: 1400px) { .bd-body { grid-template-columns: minmax(560px, 680px) minmax(0, 1fr); } }
