/* Byteobill desktop invoice entry. Existing billing controls are arranged into clear work areas. */
.bo-sale { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; align-items: stretch; }
.bo-sale > .card { margin: 0; min-width: 0; }
.bo-sale-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr); gap: .45rem 1rem; align-items: start; }
.bo-sale-top > .row:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--border); padding-bottom: .4rem; margin: 0; gap: .35rem; }
.bo-sale-top h2 { margin: 0; }
.bo-sale-top #holdBill, .bo-sale-top #recallBill { font-weight: 700; }
.bo-sale-top #cancelDraft { border-color: #e6c8c8; }
.sale-next { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .8rem; margin: .65rem 0; padding: .75rem .9rem; border: 1px solid #b6d6f4; border-radius: 9px; background: #eef6ff; color: #153b64; }
.sale-next > div:first-child { display: flex; flex: 1 1 260px; flex-direction: column; gap: .1rem; }
.sale-next > div:first-child span { font-size: .85rem; }
.sale-next-progress { flex: 1 1 100%; order: 5; height: 4px; overflow: hidden; border-radius: 4px; background: #d1e4f7; }
.sale-next-progress span { display: block; width: 0; height: 100%; background: #1470bb; transition: width .25s linear; }
.sale-next-stay { background: #f6f7f8; border-color: #d5d8dd; color: #333; }
.m-sale-switch { display: flex; gap: .35rem; padding: .55rem .65rem; background: #fff; border-bottom: 1px solid #dce5ee; }
.m-sale-switch button { flex: 1 1 0; min-width: 0; padding: .55rem .25rem; border: 1px solid #cbd9e6; border-radius: 7px; background: #f7fbff; color: #153b64; font: inherit; font-size: .76rem; font-weight: 700; }
.m-sale-switch button.danger-t { color: #a72828; background: #fff8f8; border-color: #ebcaca; }
.sale-price-level { display: inline-flex; gap: .35rem; padding: .2rem; border: 1px solid #b8cbe0; border-radius: 10px; background: #edf4fb; }
.sale-price-level label span { min-width: 94px; padding: .45rem .7rem !important; font-size: .9rem !important; font-weight: 800; border-radius: 7px; border-color: transparent; }
.sale-price-level input[value="retail"]:checked + span { background: #0d5b3b; color: #fff; border-color: #0d5b3b; }
.sale-price-level input[value="dealer"]:checked + span { background: #ad4900; color: #fff; border-color: #ad4900; }
.sale-price-level.is-wholesale { border-color: #d97706; background: #fff3df; }
.sale-price-level input:focus-visible + span { outline: 3px solid #1e70cb; outline-offset: 2px; }
.sale-price-level input:disabled + span { opacity: .45; cursor: not-allowed; }
.sale-price-notice { margin: .35rem 0 .2rem; padding: .4rem .65rem; border: 1px solid #e7a23b; border-radius: 7px; background: #fff4df; color: #793900; font-size: .83rem; font-weight: 700; }
.sale-price-notice[hidden] { display: none; }
.m-sale-price { display: flex; align-items: center; gap: .4rem; padding: .5rem .7rem; background: #eef5fb; border-bottom: 1px solid #cbd9e6; }
.m-sale-price > span { margin-right: auto; font-size: .8rem; font-weight: 800; color: #334d68; }
.m-sale-price button { min-height: 44px; min-width: 100px; padding: .4rem .65rem; border: 1px solid #a9bfd5; border-radius: 8px; background: #fff; color: #173b60; font: inherit; font-size: .85rem; font-weight: 800; }
.m-sale-price button[data-level="retail"][aria-pressed="true"] { border-color: #0d5b3b; background: #0d5b3b; color: #fff; }
.m-sale-price button[data-level="dealer"][aria-pressed="true"] { border-color: #ad4900; background: #ad4900; color: #fff; }
.m-sale-price.is-wholesale { background: #fff3df; border-bottom-color: #d97706; }
.m-sale-price button:focus-visible { outline: 3px solid #1e70cb; outline-offset: 2px; }
.m-sale-price button:disabled { opacity: .45; }
.bo-sale-customer { min-width: 0; }
.bo-sale-customer > .row:first-child { margin: 0 0 .25rem !important; gap: .35rem; flex-wrap: wrap; }
.bo-sale-customer > .row:first-child h3 { margin: 0 auto 0 0; }
.bo-sale-customer #custLinked { display: flex; align-items: center; gap: .2rem; min-width: 0; max-width: 55%; }
.bo-sale-customer #custLinked .badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bo-sale-customer > .search-wrap { width: 100%; }
.bo-sale-customer .results { z-index: 50; }
.bo-sale-customer #custNewBox { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(150px, .7fr); gap: .25rem .5rem; }
.bo-sale-customer #custNewHint { grid-column: 1 / -1; margin: 0; }
.bo-sale-customer #custNewBox label { font-size: .76rem; }
.bo-sale-customer #custNewBox input { width: 100%; }
.bo-sale-customer .cust-more { margin-top: .6rem; }
.bo-sale-options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, .82fr); grid-template-areas: 'flags total' 'level total'; gap: .25rem .55rem; align-self: start; border-left: 1px solid var(--border); padding-left: 1rem; }
.bo-sale-options > .row { grid-area: flags; display: flex; gap: .2rem .5rem; flex-wrap: wrap; margin: 0 !important; align-content: start; }
.bo-sale-options .level-row { grid-area: level !important; margin: 0 !important; align-items: center; }
.bo-sale-options .pay-modes { display: flex; }
.bo-sale-live-total { grid-area: total; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: .1rem; min-height: 92px; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg, #f7f9fc); text-align: right; }
.bo-sale-live-total span { color: var(--muted, #63728a); font-size: .85rem; font-weight: 600; }
.bo-sale-live-total strong { color: var(--text, #102a46); font-size: clamp(1.35rem, 1.9vw, 2.35rem); font-variant-numeric: tabular-nums; line-height: 1.15; }
.bo-sale-live-total small { color: var(--muted, #63728a); text-align: right; }
.bo-sale-live-total .bo-sale-adjust { color: #8a4b00; font-size: .75rem; font-weight: 700; max-width: 220px; line-height: 1.25; }
.bo-sale-live-total .bo-sale-adjust[hidden] { display: none; }
.bo-sale section.card:nth-child(2) { min-height: 290px; }
.bo-sale #posSearch { font-size: 1rem; }
/* Item search stays on screen while the bill grows. On a scrolling page it pins under the top bar.
   Inside the locked workspace the rule below puts it back in normal flow, above the scrolling rows. */
.bo-sale .sale-search {
  position: sticky;
  top: 54px;
  z-index: 24;
  flex: 0 0 auto;
  background: var(--card, #fff);
}
.bo-sale > section.card:nth-child(2) > #docWarnings,
.bo-sale > section.card:nth-child(2) > #salePriceNotice { flex: 0 0 auto; }
.bo-sale > section.card:nth-child(2) > .table-wrap {
  max-height: min(50vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
}
body.m-full .bo-sale .sale-search { top: 0; }
.bo-sale #docWarnings { margin-bottom: .5rem; padding: .55rem .75rem; font-size: .84rem; }
.bo-sale #docWarnings ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.bo-sale.empty-items .cart-table tbody tr { height: clamp(140px, 25vh, 250px); }
.bo-sale.empty-items .cart-table td.empty { text-align: center; vertical-align: middle; color: var(--muted); }
.bo-sale.many-items .table-wrap { max-height: min(58vh, 680px); overflow-y: auto; overscroll-behavior: contain; }
.bo-sale.many-items .cart-table thead th { position: sticky; top: 0; z-index: 2; background: var(--card, #fff); box-shadow: 0 1px 0 var(--border); }
.bo-sale .cart-table { width: 100%; min-width: 1040px; table-layout: fixed; }
.bo-sale .cart-table th, .bo-sale .cart-table td { padding: .55rem .45rem; vertical-align: top; }
.bo-sale .cart-table th:first-child, .bo-sale .cart-table td:first-child { width: 38px; }
.bo-sale .cart-table th:nth-child(2) { width: 31%; }
.bo-sale .cart-table th:nth-child(3) { width: 7%; }
.bo-sale .cart-table th:nth-child(4) { width: 16%; }
.bo-sale .cart-table th:nth-child(5) { width: 8%; }
.bo-sale .cart-table th:nth-child(6) { width: 6%; }
.bo-sale .cart-table th:nth-child(7) { width: 7%; }
.bo-sale .cart-table th:nth-child(8) { width: 5%; }
.bo-sale .cart-table th:nth-child(9) { width: 9%; }
.bo-sale .cart-table th:last-child, .bo-sale .cart-table td:last-child { width: 38px; }
.bo-sale .cart-table input[data-f] { max-width: 100%; box-sizing: border-box; }
.bo-sale .cart-table .cart-meta { margin-top: .35rem; }
.bo-sale .cart-table .sale-tracking { overflow-wrap: anywhere; }
.bo-sale .cart-table .sale-tracking .batch-sel { max-width: 100%; }
.bo-sale .cart-table .sale-tracking .sn-chosen { margin-top: .35rem; }
.bo-sale .amt-net { color: #8a4b00; font-size: .72rem; font-weight: 700; line-height: 1.2; white-space: normal; }
.bo-sale .cart-table .line-readout { white-space: normal; overflow-wrap: anywhere; }
.bo-sale-bottom { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 1.5rem; }
.bo-sale-payment { min-width: 0; }
.bo-sale-payment::before { content: 'Payment & bill details'; display: block; font-weight: 700; font-size: 1rem; margin-bottom: .65rem; }
.bo-sale-payment > label { display: block; margin-bottom: .3rem; }
.bo-sale-payment > .pay-modes { max-width: 620px; margin-bottom: .7rem; }
.bo-sale-payment > .grid, .bo-sale-payment > #splitBox { max-width: 720px; }
.cash-change { display: flex; flex-direction: column; justify-content: center; min-height: 63px; padding: .45rem .8rem; border: 1px solid #cfdae6; border-radius: 8px; background: #f5f8fc; font-variant-numeric: tabular-nums; }
.cash-change span { color: #42536b; font-size: .76rem; font-weight: 700; }
.cash-change strong { color: #233750; font-size: clamp(1.2rem, 1.5vw, 1.8rem); line-height: 1.12; }
.cash-change small { color: #52657b; font-size: .7rem; }
.cash-change[data-state='return'] { border-color: #8fcba9; background: #eaf8ef; }
.cash-change[data-state='return'] span, .cash-change[data-state='return'] strong { color: #146238; }
.cash-change[data-state='short'] { border-color: #ebc57b; background: #fff8e8; }
.cash-change[data-state='short'] span, .cash-change[data-state='short'] strong { color: #8a4b00; }
.cash-change[data-state='exact'] { border-color: #b6d6ec; background: #edf7ff; }
.cash-change[data-state='exact'] span, .cash-change[data-state='exact'] strong { color: #175783; }
.bo-sale-payment .sale-notes { margin-top: .5rem !important; max-width: 720px; }
.bo-sale-payment .sale-notes summary { cursor: pointer; color: var(--primary-2); font-size: .9rem; }
.bo-sale-payment .sale-notes textarea { min-height: 64px; margin-top: .35rem; }
.bo-sale-summary { border-left: 1px solid var(--border); padding-left: 1.5rem; min-width: 0; }
.bo-sale-summary::before { content: 'Bill summary'; display: block; font-weight: 700; font-size: 1rem; margin-bottom: .6rem; }
.bo-sale-summary .totals { width: 100%; margin: 0 0 .5rem; }
.bo-sale-summary .totals td { padding: .27rem 0; }
.bo-sale-summary .totals tr.grand td { padding-top: .75rem; font-size: 1.45rem; }
.bo-sale-summary .side-foot > .row { margin-top: .8rem !important; }
.bo-sale-summary .side-foot .btn.big { min-height: 44px; }
.bo-sale-brief { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; }
.bo-sale-brief > span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; color: var(--muted); font-size: .76rem; }
.bo-sale-brief b { color: var(--text); font-size: .94rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bo-brief-adjust { grid-column: 1 / -1; margin: .15rem 0 0; color: #8a4b00; font-size: .8rem; font-weight: 700; }
.bo-brief-adjust[hidden] { display: none; }
.bo-sale-breakdown { margin-top: .25rem; }
.bo-sale-breakdown summary { color: var(--primary-2); cursor: pointer; font-size: .8rem; }
.bo-sale-breakdown .totals { margin-top: .3rem; }
.bo-sale-quote .bo-sale-summary::before { content: 'Quotation summary'; }
.bo-sale-quote .bo-sale-customer .quote-customer-fields { gap: .4rem; margin-top: .35rem; }
.bo-sale-quote .bo-sale-payment .quote-extra { margin-top: .3rem; }
.bo-sale-quote .bo-quote-nav { margin: 0 !important; gap: .3rem; }
.bo-sale-quote .quote-extra summary { color: var(--primary-2); cursor: pointer; font-size: .85rem; }
.bo-sale-quote .cart-table { min-width: 800px; }
.bo-sale-quote .cart-table th:nth-child(2) { width: 44%; }
.bo-sale-quote .cart-table th:nth-child(3) { width: 12%; }
.bo-sale-quote .cart-table th:nth-child(4) { width: 8%; }
.bo-sale-quote .cart-table th:nth-child(5) { width: 8%; }
.bo-sale-quote .cart-table th:nth-child(6) { width: 7%; }
.bo-sale-quote .cart-table th:nth-child(7) { width: 12%; }
@media (min-width: 1001px) and (min-height: 560px) {
  html:has(body:is([data-route=billing], [data-route=bill-edit], [data-route=quote]) .bo-sale) { overflow: hidden; }
  body:is([data-route=billing], [data-route=bill-edit], [data-route=quote]):has(.bo-sale) { overflow: hidden; }
  body:is([data-route=billing], [data-route=bill-edit], [data-route=quote]):has(.bo-sale) main { overflow: hidden; }
  body:is([data-route=billing], [data-route=bill-edit], [data-route=quote]):has(.bo-sale) #boAppFoot { display: none; }
  .bo-sale { height: calc(100dvh - 76px); min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: .55rem; }
  .bo-sale > section.card:nth-child(2) { display: flex; flex-direction: column; min-height: 0; padding-bottom: .5rem; }
  .bo-sale > section.card:nth-child(2) > .hint { display: none; }
  .bo-sale .sale-search { position: relative; top: auto; }
  /* main is already below the top bar. A sticky header with top: 54px was shifted down over the item search. */
  .bo-sale.many-items .bo-sale-top { position: static; top: auto; z-index: auto; box-shadow: none; }
  .bo-sale > section.card:nth-child(2) > .table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; overscroll-behavior: contain; }
  .bo-sale .cart-table thead th { position: sticky; top: 0; z-index: 2; background: #f8fafc; box-shadow: 0 1px 0 var(--border); }
  .bo-sale.many-items .table-wrap { max-height: none; }
  .bo-sale-bottom { grid-template-columns: minmax(0, 1.55fr) minmax(340px, .9fr); gap: .9rem; padding-top: .55rem !important; padding-bottom: .5rem !important; }
  .bo-sale-payment { display: flex; flex-wrap: wrap; align-content: start; gap: .15rem .7rem; }
  .bo-sale-payment::before { display: none; }
  .bo-sale-payment > label { display: none; }
  .bo-sale-payment > .pay-modes { flex: 1 0 100%; max-width: none; margin: 0; }
  .bo-sale-quote .bo-sale-payment::before { content: 'Quotation details'; display: block; flex: 1 0 100%; margin: 0; font-size: .9rem; }
  .bo-sale-quote .bo-sale-payment > .grid { flex: 1 0 100%; max-width: none; }
  .bo-sale-quote .bo-sale-payment > .quote-extra { flex: 1 0 100%; margin: .1rem 0 0; }
  .bo-sale-quote .bo-sale-payment .quote-extra textarea { min-height: 55px; }
  .bo-sale-quote .bo-sale-customer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: .25rem .45rem; align-content: start; }
  .bo-sale-quote .bo-sale-customer > .row:first-child, .bo-sale-quote .bo-sale-customer > .cust-more { grid-column: 1 / -1; }
  .bo-sale-quote .bo-sale-customer .quote-customer-fields { grid-column: 2; margin: 0 !important; }
  .bo-sale-quote .bo-sale-customer .quote-customer-fields label { display: none; }
  .bo-sale-quote .bo-sale-customer .quote-customer-fields input { height: 40px; }
  .bo-sale-quote .bo-sale-customer > .search-wrap { grid-column: 1; }
  .bo-sale-payment > #cashBox { flex: 1 1 54%; min-width: 260px; margin-top: .15rem !important; }
  .bo-sale-payment > #billDiscBox { flex: 1 1 34%; min-width: 180px; margin-top: .15rem !important; }
  .bo-sale-payment > #creditBox, .bo-sale-payment > #splitBox { flex: 1 0 100%; margin-top: .15rem !important; }
  .bo-sale-payment #billDiscBox > .hint { display: none; }
  .bo-sale-payment .sale-notes { flex: 1 0 100%; max-width: none; margin: .1rem 0 0 !important; }
  .bo-sale-payment input, .bo-sale-payment select { padding-top: .35rem; padding-bottom: .35rem; }
  .bo-sale-summary { padding-left: .9rem; }
  .bo-sale-summary::before { margin-bottom: .25rem; }
  .bo-sale-summary .side-foot > .row { margin-top: .35rem !important; }
  .bo-sale:has(#cancelDraft) .bo-sale-summary .side-foot > .row:last-child { display: none; }
  .bo-sale-summary .side-foot .btn.big { min-height: 36px; padding: .4rem .7rem; font-size: .9rem; }
  .bo-sale-summary .gst-ready { font-size: .72rem; }
  .bo-sale .cart-table th, .bo-sale .cart-table td { padding-top: .4rem; padding-bottom: .4rem; }
  .bo-sale .cart-table .cart-meta { display: inline-block; max-width: 43%; margin-top: .15rem; white-space: nowrap; vertical-align: bottom; overflow: hidden; text-overflow: ellipsis; }
  .bo-sale .cart-table .line-readout { display: inline-block; max-width: 54%; margin: .15rem 0 0 .3rem; white-space: nowrap; vertical-align: bottom; overflow: hidden; text-overflow: ellipsis; contain: none; }
  .bo-sale-quote .cart-table .cart-meta { max-width: none; display: block; }
  .bo-sale-quote .cart-table .line-readout { max-width: none; display: block; }
}
@media (min-width: 1200px) {
  .bo-sale { min-height: 0; }
  .bo-sale > section.card:nth-child(2) { display: flex; flex-direction: column; }
  .bo-sale > section.card:nth-child(2) > .table-wrap { flex: 1 1 auto; }
}
.m-new-sale > .m-add-row {
  position: sticky;
  top: calc(56px + env(safe-area-inset-top));
  z-index: 22;
  background: #fff;
  margin: 0;
  padding: .15rem var(--m-pad, 14px) .65rem;
  border-bottom: 1px solid #e6eaf0;
}
@media (max-width: 1000px) {
  .bo-sale-top, .bo-sale-bottom { grid-template-columns: minmax(0, 1fr); }
  .bo-sale-customer #custNewBox { grid-template-columns: minmax(0, 1fr) minmax(140px, .7fr); }
  .bo-sale-options, .bo-sale-summary { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; padding-top: .5rem; }
  .bo-sale .cart-table { min-width: 1040px; }
}
@media (max-height: 850px) and (min-width: 1001px) {
  .bo-sale { min-height: 0; }
  .bo-sale-payment .sale-notes textarea { min-height: 48px; }
}
@media (max-width: 768px) {
  .bo-sale { gap: .6rem; }
  .bo-sale-top, .bo-sale-bottom { gap: .8rem; }
  .bo-sale-top > .row:first-child { flex-wrap: wrap; gap: .5rem; }
  .bo-sale .cart-table { min-width: 1040px; }
  .bo-sale-customer #custNewBox { grid-template-columns: minmax(0, 1fr); }
  .bo-sale-payment > .pay-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bo-sale-summary .side-foot > .row:has(#saveDocPrint) { flex-wrap: wrap; }
  .bo-sale-summary .side-foot #saveDocPrint { flex-basis: 100%; }
}
