/* toolsfy — Business & Document Tools (shared styles). Scoped to #tool-container .bd */
#tool-container .bd { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#tool-container .bd [hidden] { display: none !important; }
#tool-container .bd .bd-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; }
#tool-container .bd-topbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
#tool-container .bd-lede { margin: 0; color: #475569; font-size: .92rem; flex: 1 1 280px; }
#tool-container .bd-topbtns { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#tool-container .bd button.bd-sm:not(#bd-n) { padding: 8px 14px; font-size: .86rem; }
#tool-container .bd-skip { font-size: .86rem; font-weight: 600; }
#tool-container .bd-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
#tool-container .bd-side { border-top: 1px dashed #cbd5e1; padding-top: 16px; }
#tool-container .bd-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; container-type: inline-size; container-name: bdform; }
#tool-container .bd-sec { border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px 14px; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
#tool-container .bd-sec > legend { font-weight: 700; color: #1e293b; padding: 0 6px; font-size: .98rem; }
#tool-container .bd-sec .bd-sec { border-style: dashed; }
#tool-container .bd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; min-width: 0; }
#tool-container .bd-grid > .bd-span2 { grid-column: 1 / -1; }
#tool-container .bd-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#tool-container .bd-f > label, #tool-container .bd-flabel { font-size: .86rem; font-weight: 600; color: #334155; margin: 0; }
#tool-container .bd-optl { font-weight: 400; color: #64748b; font-size: .8rem; }
#tool-container .bd-req { color: #b91c1c; }
#tool-container .bd input[type="text"], #tool-container .bd input[type="email"], #tool-container .bd input[type="tel"],
#tool-container .bd input[type="url"], #tool-container .bd input[type="date"], #tool-container .bd input[type="time"],
#tool-container .bd input[type="number"], #tool-container .bd select, #tool-container .bd textarea {
  padding: 8px 10px; font-size: .93rem; border-radius: 8px; min-width: 0; width: 100%; max-width: 100%;
}
#tool-container .bd input[type="time"] { border: 1px solid #d4d8e1; font-family: inherit; background: #fff; color: #0f172a; }
#tool-container .bd input[type="tel"] { border: 1px solid #d4d8e1; font-family: inherit; background: #fff; color: #0f172a; }
#tool-container .bd textarea { min-height: 0; resize: vertical; line-height: 1.45; }
#tool-container .bd [aria-invalid="true"] { border-color: #dc2626 !important; box-shadow: 0 0 0 2px rgba(220, 38, 38, .15); }
#tool-container .bd input:focus-visible, #tool-container .bd select:focus-visible, #tool-container .bd textarea:focus-visible,
#tool-container .bd button:focus-visible, #tool-container .bd a:focus-visible, #tool-container .bd .bd-filebtn:focus-within {
  outline: 3px solid #2563eb !important; outline-offset: 2px; box-shadow: none;
}
#tool-container .bd-hint { font-size: .8rem; color: #64748b; margin: 0; line-height: 1.4; }
#tool-container .bd-chk { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
#tool-container .bd-chk input { width: 18px; height: 18px; margin: 0; accent-color: #2563eb; }
#tool-container .bd-chk label { margin: 0; font-weight: 600; font-size: .9rem; color: #334155; }
#tool-container .bd-chk .bd-hint { flex-basis: 100%; padding-left: 26px; }
#tool-container .bd-radios { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
#tool-container .bd-radios legend { font-size: .86rem; font-weight: 600; color: #334155; padding: 0; margin-bottom: 4px; }
#tool-container .bd-radio { display: inline-flex; align-items: center; gap: 6px; }
#tool-container .bd-radio label { margin: 0; font-weight: 500; font-size: .9rem; }
#tool-container .bd-radio input { margin: 0; accent-color: #2563eb; }

/* repeatable lists */
#tool-container .bd button.bd-ib:not(#bd-n) { padding: 6px 9px; font-size: .82rem; line-height: 1; background: #fff; color: #334155; border: 1px solid #cbd5e1; border-radius: 7px; transform: none; }
#tool-container .bd button.bd-ib:not(#bd-n):hover:not(:disabled) { background: #eff6ff; border-color: #2563eb; color: #1d4ed8; transform: none; }
#tool-container .bd button.bd-ib-del:not(#bd-n):hover:not(:disabled) { background: #fef2f2; border-color: #dc2626; color: #b91c1c; }
#tool-container .bd button.bd-ib:not(#bd-n):disabled { background: #f8fafc !important; color: #cbd5e1; border-color: #e2e8f0; }
#tool-container .bd button.bd-ib-txt:not(#bd-n) { padding: 7px 12px; }
#tool-container .bd-itools { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
#tool-container .bd button.bd-add:not(#bd-n) { align-self: flex-start; background: #fff; color: #1d4ed8; border: 1px dashed #93c5fd; padding: 8px 14px; font-size: .88rem; }
#tool-container .bd button.bd-add:not(#bd-n):hover { background: #eff6ff; transform: none; }
#tool-container .bd-card { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; background: #f8fafc; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#tool-container .bd-card.is-hidden { opacity: .6; }
#tool-container .bd-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
#tool-container .bd-card-title { font-weight: 700; color: #1e293b; font-size: .92rem; overflow-wrap: anywhere; min-width: 0; flex: 1 1 140px; }
#tool-container .bd-card-title small { font-weight: 500; color: #64748b; }
#tool-container .bd-stack { display: flex; flex-direction: column; gap: 10px; }

/* line items */
#tool-container .bd-items { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#tool-container .bd-li, #tool-container .bd-li-head { display: grid; gap: 8px; align-items: start; min-width: 0; }
#tool-container .bd-li { border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; background: #f8fafc; }
#tool-container .bd-li-head { display: none; font-size: .78rem; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .03em; padding: 0 9px; }
#tool-container .bd-li-amt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#tool-container .bd-li-amt output { font-weight: 700; color: #0f172a; padding: 8px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; font-size: .92rem; }
#tool-container .bd-li-amtl { font-size: .86rem; font-weight: 600; color: #334155; }
#tool-container .bd-li { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#tool-container .bd-li > .bd-li-desc, #tool-container .bd-li > .bd-f:first-child { grid-column: 1 / -1; }
#tool-container .bd-li > .bd-itools { grid-column: 1 / -1; }
@container bdform (min-width: 620px) {
  #tool-container .bd-li-desc-qty-unit-rate { grid-template-columns: minmax(0, 3fr) minmax(0, .8fr) minmax(0, .9fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; }
  #tool-container .bd-li-sku-desc-qty-unit-rate { grid-template-columns: minmax(0, 1.1fr) minmax(0, 2.6fr) minmax(0, .8fr) minmax(0, .8fr) minmax(0, 1.1fr) minmax(0, 1.2fr) auto; }
  #tool-container .bd-li-desc-qty-rate { grid-template-columns: minmax(0, 3fr) minmax(0, .9fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; }
  #tool-container .bd-li-sku-desc-ord-ship-back { grid-template-columns: minmax(0, 1.1fr) minmax(0, 2.8fr) minmax(0, .9fr) minmax(0, .9fr) minmax(0, .9fr) auto; }
  #tool-container .bd-li-head { display: grid; }
  #tool-container .bd-li > .bd-li-desc, #tool-container .bd-li > .bd-f:first-child, #tool-container .bd-li > .bd-itools { grid-column: auto; }
  #tool-container .bd-li > .bd-f > label, #tool-container .bd-li .bd-li-amtl { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  #tool-container .bd-li .bd-itools { display: grid; grid-template-columns: repeat(2, auto); gap: 4px; padding-top: 2px; }
  #tool-container .bd-li .bd-itools button[data-act="rm"] { grid-column: 1 / -1; }
}
#tool-container .bd-taxes { display: flex; flex-direction: column; gap: 8px; }
#tool-container .bd-taxrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
#tool-container .bd-taxrow .bd-itools button[data-act="up"], #tool-container .bd-taxrow .bd-itools button[data-act="down"] { display: none; }
#tool-container .bd-basis { margin: 0; font-size: .84rem; color: #1e3a8a; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 9px 11px; line-height: 1.5; }
#tool-container .bd-basis i { color: #1d4ed8; margin-right: 2px; }
#tool-container .bd-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0; }
#tool-container .bd-totals > div { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px 10px; min-width: 0; }
#tool-container .bd-totals dt { font-size: .78rem; color: #64748b; }
#tool-container .bd-totals dd { margin: 2px 0 0; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#tool-container .bd-totals .is-key { border-color: #93c5fd; background: #eff6ff; }

/* image upload */
#tool-container .bd-imgrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#tool-container .bd-thumb { width: 72px; height: 48px; object-fit: contain; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; }
#tool-container .bd-thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 1.2rem; }
#tool-container .bd-imgbtns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: relative; }
#tool-container .bd-filebtn { display: inline-flex; gap: 6px; align-items: center; padding: 7px 12px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: #1e293b; font-size: .86rem; font-weight: 600; cursor: pointer; margin: 0; }
#tool-container .bd-filebtn:hover { border-color: #2563eb; color: #1d4ed8; }
#tool-container .bd-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; left: 0; top: 0; }

/* preview + actions */
#tool-container .bd-side { min-width: 0; }
#tool-container .bd-side-in { display: flex; flex-direction: column; gap: 10px; }
#tool-container .bd-prevhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#tool-container .bd-h { margin: 0; font-size: 1.05rem; color: #0f172a; }
#tool-container .bd-pagesz { font-size: .8rem; color: #64748b; }
#tool-container .bd-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#tool-container .bd-actions button { padding: 9px 14px; font-size: .9rem; }
#tool-container .bd-status { margin: 0; font-size: .88rem; color: #047857; min-height: 1.2em; }
#tool-container .bd-status.bd-bad { color: #b91c1c; }
#tool-container .bd-viewport { position: relative; overflow: hidden; background: #e2e8f0; border-radius: 10px; padding: 0; border: 1px solid #cbd5e1; max-width: 100%; }
#tool-container .bd-paper { box-sizing: border-box; background: #fff; color: #111827; box-shadow: 0 1px 3px rgba(15, 23, 42, .15); overflow-wrap: anywhere; word-break: break-word; }
#tool-container .bd-paper .bd-p { position: relative; white-space: pre-wrap; }
#tool-container .bd-paper .bd-bul { position: absolute; top: 0; }
#tool-container .bd-paper a { color: inherit; }
#tool-container .bd-paper .bd-t { border-collapse: collapse; table-layout: fixed; }
#tool-container .bd-paper .bd-t th, #tool-container .bd-paper .bd-t td { vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
#tool-container .bd-paper .bd-cols { display: flex; align-items: flex-start; }
#tool-container .bd-paper .bd-box { box-sizing: border-box; }
#tool-container .bd-prevnote { margin-top: 0; }
#tool-container .bd-msgs { display: flex; flex-direction: column; gap: 8px; }
#tool-container .bd-err, #tool-container .bd-warn { border-radius: 8px; padding: 9px 12px; font-size: .86rem; }
#tool-container .bd-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
#tool-container .bd-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
#tool-container .bd-err p, #tool-container .bd-warn p { margin: 0; }
#tool-container .bd-err ul, #tool-container .bd-warn ul { margin: 4px 0 0; padding-left: 20px; }
#tool-container .bd-err a, #tool-container .bd-warn a { color: inherit; text-decoration: underline; }
#tool-container .bd-confirm { border: 1px solid #fca5a5; background: #fff7ed; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
#tool-container .bd-confirm p { margin: 0; font-weight: 600; color: #7c2d12; }
#tool-container .bd-confirm-btns { display: flex; gap: 8px; flex-wrap: wrap; }
#tool-container .bd-bottom { margin-top: 0; }
#tool-container .bd-privacy { margin: 0; }
#tool-container .tfx-note { font-size: .88rem; color: #475569; background: #f8fafc; border: 1px solid #e2e8f0; border-left: 3px solid #2563eb; border-radius: 8px; padding: 10px 12px; }
#tool-container .tfx-note i { color: #2563eb; margin-right: 4px; }
#tool-container .bd-rulebox { font-size: .84rem; color: #334155; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 9px 11px; margin: 0; line-height: 1.5; }
#tool-container .bd-tablewrap { overflow-x: auto; max-width: 100%; }
#tool-container .bd-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
#tool-container .bd-table th, #tool-container .bd-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
#tool-container .bd-table td.num, #tool-container .bd-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* dark theme (form only — the document preview stays white like paper) */
:root[data-theme="dark"] #tool-container .bd-lede, :root[data-theme="dark"] #tool-container .bd-hint, :root[data-theme="dark"] #tool-container .bd-optl, :root[data-theme="dark"] #tool-container .bd-pagesz { color: var(--tf-text-soft); }
:root[data-theme="dark"] #tool-container .bd-sec { border-color: var(--tf-border); }
:root[data-theme="dark"] #tool-container .bd-sec > legend, :root[data-theme="dark"] #tool-container .bd-f > label, :root[data-theme="dark"] #tool-container .bd-flabel,
:root[data-theme="dark"] #tool-container .bd-chk label, :root[data-theme="dark"] #tool-container .bd-card-title, :root[data-theme="dark"] #tool-container .bd-h,
:root[data-theme="dark"] #tool-container .bd-li-amt output, :root[data-theme="dark"] #tool-container .bd-li-amtl, :root[data-theme="dark"] #tool-container .bd-radios legend { color: var(--tf-text); }
:root[data-theme="dark"] #tool-container .bd-li, :root[data-theme="dark"] #tool-container .bd-card, :root[data-theme="dark"] #tool-container .bd-totals > div { background: var(--tf-surface-2); border-color: var(--tf-border); }
:root[data-theme="dark"] #tool-container .bd-totals dd { color: var(--tf-text); }
:root[data-theme="dark"] #tool-container .bd-li-head { color: var(--tf-text-soft); }
:root[data-theme="dark"] #tool-container .bd input[type="time"], :root[data-theme="dark"] #tool-container .bd input[type="tel"] { background: var(--tf-surface); border-color: var(--tf-border); color: var(--tf-text); }
:root[data-theme="dark"] #tool-container .bd button.bd-ib:not(#bd-n), :root[data-theme="dark"] #tool-container .bd button.bd-add:not(#bd-n), :root[data-theme="dark"] #tool-container .bd-filebtn { background: var(--tf-surface); color: var(--tf-text); border-color: var(--tf-border-strong); }
:root[data-theme="dark"] #tool-container .bd-viewport { background: #0b1220; border-color: var(--tf-border); }
:root[data-theme="dark"] #tool-container .bd-basis { background: rgba(37, 99, 235, .14); color: #bfdbfe; border-color: rgba(96, 165, 250, .35); }
:root[data-theme="dark"] #tool-container .bd-err { background: rgba(127, 29, 29, .25); color: #fecaca; border-color: rgba(248, 113, 113, .4); }
:root[data-theme="dark"] #tool-container .bd-warn { background: rgba(120, 53, 15, .3); color: #fde68a; border-color: rgba(251, 191, 36, .35); }
:root[data-theme="dark"] #tool-container .bd-confirm { background: rgba(124, 45, 18, .3); border-color: rgba(251, 146, 60, .5); }
:root[data-theme="dark"] #tool-container .bd-confirm p { color: #fed7aa; }
:root[data-theme="dark"] #tool-container .bd-status { color: #34d399; }
:root[data-theme="dark"] #tool-container .bd-status.bd-bad { color: #f87171; }
:root[data-theme="dark"] #tool-container .tfx-note, :root[data-theme="dark"] #tool-container .bd-rulebox { background: var(--tf-surface-2); border-color: var(--tf-border); color: var(--tf-text-soft); }
:root[data-theme="dark"] #tool-container .bd-table th, :root[data-theme="dark"] #tool-container .bd-table td { border-bottom-color: var(--tf-border); }
:root[data-theme="dark"] #tool-container .bd-thumb { border-color: var(--tf-border); }

@media (max-width: 520px) {
  #tool-container .bd-sec { padding: 10px 10px 12px; }
  #tool-container .bd-actions button { flex: 1 1 140px; justify-content: center; }
  #tool-container .bd-taxrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #tool-container .bd-taxrow .bd-itools { grid-column: 1 / -1; }
}

/* printing: only the document is printed */
#bd-print-area { display: none; }
@media print {
  body > *:not(#bd-print-area) { display: none !important; }
  #bd-print-area { display: block !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #bd-print-area .bd-paper { transform: none !important; box-shadow: none !important; width: auto !important; min-height: 0 !important; padding: 0 !important; background: #fff !important; color: #111827; overflow-wrap: anywhere; }
  #bd-print-area .bd-p { position: relative; white-space: pre-wrap; }
  #bd-print-area .bd-bul { position: absolute; top: 0; }
  #bd-print-area .bd-t { border-collapse: collapse; table-layout: fixed; }
  #bd-print-area .bd-t th, #bd-print-area .bd-t td { vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
  #bd-print-area .bd-t thead { display: table-header-group; }
  #bd-print-area .bd-t tr { break-inside: avoid; }
  #bd-print-area .bd-cols { display: flex; align-items: flex-start; }
  #bd-print-area a { color: inherit; }
}
:root[data-theme="dark"] #tool-container .bd button.bd-ib:not(#bd-n):disabled { background: var(--tf-surface-2) !important; color: #475569; border-color: var(--tf-border); }
:root[data-theme="dark"] #tool-container .bd button.bd-ib:not(#bd-n):hover:not(:disabled), :root[data-theme="dark"] #tool-container .bd button.bd-add:not(#bd-n):hover { background: rgba(37, 99, 235, .2); color: #bfdbfe; }
