/* Billing module. Loaded on every page by the core layout, so every selector here is billing-specific (b-*). */

.b-docform [hidden], .b-lines-card [hidden] { display: none !important; }
.b-tabs { margin-bottom: 1.25rem; }

/* banners */
.b-banner { padding: .8rem 1rem; border-radius: var(--radius); border-left: 4px solid; margin-bottom: 1rem; font-size: .9rem; }
.b-banner a { margin-left: .4rem; font-weight: 600; }
.b-banner-warn { background: var(--warn-bg); border-color: #F2A000; color: var(--ink); }
.b-banner-bad { background: var(--bad-bg); border-color: var(--bad); color: var(--ink); }
.b-banner .small { margin: .4rem 0; }
.b-unpriced summary { cursor: pointer; font-size: .85rem; color: var(--brand-strong); margin-top: .3rem; }
.b-inline { display: inline-block; margin-top: .3rem; }
.b-plain { margin: .3rem 0 .8rem; padding-left: 1.1rem; }
.b-plain li { margin: .15rem 0; }
.b-mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: .8rem; }
.b-copy { font-size: .8rem; }
.b-stat-small { font-size: 1.1rem !important; }
.b-check-pad { padding-top: 1.6rem; }
.head-actions form { margin: 0; }

/* product list quick price */
.b-quickprice { display: flex; gap: .3rem; align-items: center; }
.b-quickprice input { width: 5.6rem; padding: .3rem .45rem; text-align: right; font-size: .85rem; }
.b-quickprice .b-qp-margin { width: 3.8rem; }
.b-live-margin { margin: 0; flex-basis: 100%; }
.b-quickprice .btn { padding: .3rem .6rem; font-size: .8rem; }

/* line editor */
.b-lines-card .card-head, .b-docform .card-head { flex-wrap: wrap; gap: .3rem 1rem; }
.b-lines-edit td { padding: .45rem .4rem; vertical-align: top; }
.b-lines-edit th { padding: .5rem .4rem; }
.b-lines-edit input, .b-lines-edit select, .b-lines-edit textarea { padding: .4rem .5rem; font-size: .86rem; }
.b-lines-edit textarea { min-height: 2.3rem; }
.b-lines-edit:not(.b-al) td:nth-child(2) { min-width: 260px; }
.b-lines-edit .num input { text-align: right; }
.b-col-product { width: 22%; } .b-col-qty { width: 5.5rem; } .b-col-price { width: 7.5rem; } .b-col-small { width: 4.8rem; }
.b-col-type { width: 8rem; } .b-col-net { width: 7rem; } .b-col-x { width: 4.5rem; }
.b-line-net { white-space: nowrap; padding-top: .9rem !important; font-variant-numeric: tabular-nums; }
.b-remove { font-size: .82rem; padding-top: .6rem; }
.b-lines-foot { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: .75rem; }
.b-live-totals { margin: 0; font-size: .88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.b-al td:first-child { min-width: 260px; }
.b-al td:first-child select { margin-bottom: .35rem; }
.b-al-qty { min-width: 250px; }
.b-al-qty > select, .b-al-qty > span { display: block; margin-bottom: .35rem; }
/* product type-ahead (script.js productSearch); the list is position: fixed so the table's scroll box can't clip it */
.b-pp input { width: 100%; min-width: 10rem; }
.b-al .b-pp { margin-bottom: .35rem; }
.b-pp-list { position: fixed; z-index: 50; max-width: min(34rem, calc(100vw - 8px)); overflow-y: auto; margin: 0; padding: .25rem 0; list-style: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.18); font-size: .86rem; }
.b-pp-list[hidden] { display: none; }
.b-pp-list li { padding: .4rem .7rem; cursor: pointer; }
.b-pp-list li small { display: block; color: var(--muted); font-size: .74rem; }
.b-pp-list li[aria-selected="true"], .b-pp-list li[role=option]:hover { background: var(--paper); box-shadow: inset 3px 0 0 var(--brand); }
.b-pp-list .b-pp-none { color: var(--muted); cursor: default; }
.b-group input { margin-bottom: .3rem; }
.b-group select { margin-top: .3rem; }
.b-row-bad td { background: var(--bad-bg); }
.b-preview { border-top: 3px solid var(--brand); }
.b-linkform { margin: 1rem 0 0; }
.b-linkform select { max-width: 460px; }
.b-ticket-link { margin-top: .75rem; }

/* panels */
.b-panel h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: .6rem 0 .2rem; }
.b-panel-actions { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .88rem; font-weight: 600; margin-bottom: .2rem; }
.b-panel-grid { gap: 0 2rem; }

/* ---------- the document (quote / invoice / work order): looks like paper on screen, prints on A4 ---------- */
.b-doc {
  position: relative; overflow: hidden; background: #fff; color: #1B201F; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.6rem 2.8rem 2rem; margin-bottom: 1.25rem; font-size: .9rem; line-height: 1.5; box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border-top: 5px solid #FF4100;
}
.b-doc a { color: inherit; }
.b-watermark { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 7rem; font-weight: 700; letter-spacing: .2em;
  color: rgba(204, 52, 0, .07); transform: rotate(-18deg); pointer-events: none; user-select: none; }
.b-doc-head { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; margin-bottom: 2rem; }
.b-doc-from { display: flex; gap: 1rem; align-items: flex-start; }
.b-doc-logo { width: 64px; height: 64px; object-fit: contain; flex: none; }
.b-doc-company { display: block; font-size: 1.1rem; font-weight: 700; margin-bottom: .2rem; }
.b-doc-address, .b-doc-contact { font-size: .82rem; color: #55554F; }
.b-doc-titleblock { text-align: right; }
.b-doc-kind { font-size: 1.9rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .5rem; color: #CC3400; }
.b-doc-meta { display: grid; grid-template-columns: auto auto; gap: .15rem 1rem; margin: 0; font-size: .85rem; justify-content: end; }
.b-doc-kind { white-space: nowrap; }
.b-doc-meta dt { color: #66665F; white-space: nowrap; } .b-doc-meta dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.b-doc-parties { display: flex; gap: 3rem; margin-bottom: 1.4rem; padding: 1rem 0; border-top: 1px solid #E4E4DE; border-bottom: 1px solid #E4E4DE; }
.b-doc h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #66665F; margin: 0 0 .3rem; font-weight: 600; }
.b-doc-parties p { margin: 0; }
.b-doc-subject { font-size: 1.05rem !important; text-transform: none !important; letter-spacing: 0 !important; color: #1B201F !important; margin: 0 0 .5rem !important; }
.b-doc-intro { margin-bottom: 1.2rem; }
.b-doc-lines { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: .86rem; }
.b-doc-lines th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #66665F; font-weight: 600; padding: .5rem .5rem; border-bottom: 2px solid #1B201F; }
.b-doc-lines td { padding: .55rem .5rem; border-bottom: 1px solid #E4E4DE; vertical-align: top; }
.b-doc-lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.b-doc-lines td:first-child { width: 55%; }
.b-doc-group th { background: #F4F4F1; color: #1B201F; border-bottom: 1px solid #E4E4DE; padding: .4rem .5rem; font-size: .75rem; }
.b-unit { color: #77776F; font-size: .78rem; white-space: nowrap; }
.b-doc-totals { display: flex; justify-content: flex-end; margin-bottom: 1.2rem; }
.b-totals { border-collapse: collapse; min-width: 300px; font-size: .9rem; }
.b-totals th { text-align: left; font-weight: 500; color: #55554F; padding: .3rem .6rem .3rem 0; }
.b-totals td { padding: .3rem 0 .3rem 1.4rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.b-totals-head th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #66665F; text-align: right; font-weight: 600; }
.b-totals-head th:first-child { text-align: left; }
.b-totals .b-grand th, .b-totals .b-grand td { border-top: 2px solid #1B201F; font-weight: 700; font-size: 1.05rem; color: #1B201F; padding-top: .5rem; }
.b-per { display: block; font-size: .72rem; font-weight: 500; color: #66665F; }
.b-paid th { color: #2F7D3B !important; font-weight: 700 !important; padding-top: .5rem; }
.b-doc-accepted { padding: .6rem .9rem; background: #E5F2E6; color: #23702F; border-radius: 3px; font-weight: 600; }
.b-doc-notes { margin: 1rem 0; font-size: .84rem; }
.b-doc-foot { margin-top: 1.8rem; padding-top: 1rem; border-top: 1px solid #E4E4DE; font-size: .8rem; color: #55554F; }
.b-doc-pay { margin-bottom: .8rem; color: #1B201F; }
.b-doc-pay p { margin: 0; }
.b-doc-legal { margin: 0 0 .3rem; }
.b-doc-thanks { margin: 0; font-weight: 600; color: #CC3400; }

/* public quote page */
.b-public { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }
.b-public-actions { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.b-accept { margin: 0 auto 2rem; text-align: left; }

@media (max-width: 860px) {
  .b-doc { padding: 1.4rem 1.1rem; }
  .b-doc-head { flex-direction: column; }
  .b-doc-titleblock { text-align: left; }
  .b-doc-meta { justify-content: start; }
  .b-doc-parties { flex-direction: column; gap: 1rem; }
  .b-watermark { font-size: 4rem; }
}

/* ---------- print: only the document, on white A4 ---------- */
@page { size: A4; margin: 14mm 14mm 16mm; }
/* Scoped with body:has(.b-doc) so other modules' pages print as before. */
@media print {
  body:has(.b-doc) { background: #fff !important; font-size: 13px; color-scheme: light; }
  body:has(.b-doc) :is(.sidebar, .topbar, .flash, .head-actions, .skip, .b-tabs, .b-side, .b-noprint, .page-head, .b-banner, .b-public-actions, .b-accept, .crumbs) { display: none !important; }
  body.has-shell:has(.b-doc) { display: block !important; }
  body:has(.b-doc) :is(.shell, main) { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .b-docsplit { display: block !important; }
  .b-public { margin: 0; padding: 0; max-width: none; }
  .b-doc { border: 0 !important; border-top: 4px solid #FF4100 !important; box-shadow: none !important; padding: 6mm 0 0 !important; margin: 0 !important; border-radius: 0; font-size: 10.5pt; }
  .b-doc-lines tr, .b-totals tr, .b-doc-pay, .b-doc-notes { page-break-inside: avoid; break-inside: avoid; }
  .b-doc-lines thead { display: table-header-group; }
  .b-doc-group th, .b-doc-accepted { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .b-watermark { color: rgba(204, 52, 0, .09); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { text-decoration: none; }
}
