/* UI-106 — SEMANTIC TABLE COLUMNS — 2026-10-08
   Column meaning, not incidental label length, determines alignment.
   No data/price/quantity transformations or backend calls.
   Shared geometry: header and every item row use ONE five-column ruler.

   INDEX       : compact, centered, tabular digits.
   DESCRIPTION : product/customer/source name, left, flexible, min-width:0.
   MONEY       : price/amount/profit, right, tabular digits, last total rightmost.
   QUANTITY    : within 5-column cart/order, centered numeric axis.
   STEPPER     : centered as one complete - [number] + control.
   FINAL COUNT : when quantity is the last column in source-group tables,
                 right align to the table edge.
*/
#cartBottomSheet .cart-compact-grid {
  display:grid !important;
  grid-template-columns:
    var(--cart-stt-track,24px)
    minmax(0,1fr)
    var(--cart-qty-track,96px)
    var(--cart-unit-track,54px)
    var(--cart-total-track,69px) !important;
  grid-template-areas:none !important;
  width:100% !important;
  min-width:0 !important;
  column-gap:6px !important;
  justify-content:stretch !important;
}
#cartBottomSheet[data-cart-mode="preview"] .cart-compact-grid {
  column-gap:7px !important;
}
/* Crucial: do NOT move captions independently of their values. */
#cartBottomSheet .cart-column-header .cart-qty,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-qty-control,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-qty-readonly {
  transform:none !important;
}
#cartBottomSheet .cart-column-header .cart-stt,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-stt {
  text-align:center !important;
  font-variant-numeric:tabular-nums;
}
#cartBottomSheet .cart-column-header .cart-name,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-name {
  text-align:left !important;
  min-width:0 !important;
}
#cartBottomSheet .cart-column-header .cart-price,
#cartBottomSheet .cart-column-header .cart-total,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-price,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-total,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-money-value {
  text-align:right !important;
  font-variant-numeric:tabular-nums;
}
#cartBottomSheet #cartItemList .cart-compact-grid .cart-price,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-total {
  justify-content:flex-end !important;
}
#cartBottomSheet .cart-column-header .cart-qty,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-qty,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-qty-readonly {
  text-align:center !important;
  justify-content:center !important;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control {
  justify-self:center !important;
  justify-content:center !important;
  align-self:center !important;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control > input {
  text-align:center !important;
  font-variant-numeric:tabular-nums;
}
/* Non-editable order detail — use the shared measured C/D/E widths. */
#orderDetailContentToShare .order-detail-compact-grid {
  display:grid !important;
  grid-template-columns:
    var(--order-stt-track,24px)
    minmax(0,1fr)
    var(--order-qty-track,29px)
    var(--order-price-track,60px)
    var(--order-total-track,76px) !important;
  column-gap:7px !important;
  width:100% !important;
  min-width:0 !important;
}
#orderDetailContentToShare .order-detail-compact-grid .order-stt {
  text-align:center !important;
  font-variant-numeric:tabular-nums;
}
#orderDetailContentToShare .order-detail-compact-grid .order-name,
#orderDetailContentToShare .order-detail-compact-grid > .min-w-0 {
  text-align:left !important;
  min-width:0 !important;
}
#orderDetailContentToShare .order-detail-compact-grid .order-price,
#orderDetailContentToShare .order-detail-compact-grid .order-total {
  text-align:right !important;
  font-variant-numeric:tabular-nums;
}
#orderDetailContentToShare .order-detail-compact-grid .order-qty {
  text-align:center !important;
  font-variant-numeric:tabular-nums;
}
/* Summary: source description left; quantities and money are numeric.
   Preserve each true table structure and its number of columns. */
.order-summary-panel .summary-compact-table :is(th,td):first-child {
  text-align:left !important;
}
.order-summary-panel .summary-compact-table :is(th,td):not(:first-child) {
  text-align:right !important;
  font-variant-numeric:tabular-nums;
}
/* Source-detail / grouped: two text columns may occur, SL is FINAL numeric
   column so it belongs at the right edge (not center as in a five-col cart). */
.source-detail-capture .source-detail-grid .source-detail-stt {
  text-align:center !important;
  font-variant-numeric:tabular-nums;
}
.source-detail-capture .source-detail-grid :is(.source-detail-name,.source-detail-product-cell,.source-detail-buyer-cell,.source-detail-buyer) {
  text-align:left !important;
  min-width:0 !important;
}
.source-detail-capture .source-detail-grid :is(.source-detail-qty,.source-detail-total-qty) {
  justify-self:end !important;
  justify-content:flex-end !important;
  text-align:right !important;
  font-variant-numeric:tabular-nums;
}
/* Cards: customer name is a description, monetary value remains rightmost. */
.order-card-title-row > :first-child,
.order-card-meta-row > :first-child {
  min-width:0;
  text-align:left;
}
.order-card-total,
.order-card-meta-row .profit-only {
  text-align:right !important;
  font-variant-numeric:tabular-nums;
}
@media(max-width:620px) {
  #orderDetailContentToShare .order-detail-compact-grid {column-gap:6px !important;}
}
@media(max-width:350px) {
  #cartBottomSheet .cart-compact-grid {column-gap:4px !important;}
  #orderDetailContentToShare .order-detail-compact-grid {column-gap:4px !important;}
}

/* UI-107: semantic two-line fallback, ONLY when runtime measures <68px
   left for product name with a full - number + stepper. The same five
   numeric tracks remain locked; both caption and data reorganize together.
   Never apply it merely because the browser viewport is narrow: split
   desktop panes are also measured on their actual inner width. */
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid {
  grid-template-rows:minmax(20px,auto) minmax(34px,auto) !important;
  row-gap:3px !important;
  align-items:center !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header{
  padding-top:5px !important;
  padding-bottom:5px !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-stt,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-stt{
  grid-column:1 !important;
  grid-row:1 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-name,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-left > .min-w-0{
  grid-column:2 / -1 !important;
  grid-row:1 !important;
  min-width:0 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-price,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-price{
  grid-column:4 !important;
  grid-row:2 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-qty,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-qty{
  grid-column:3 !important;
  grid-row:2 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-total,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-total{
  grid-column:5 !important;
  grid-row:2 !important;
}

/* UI-111/112: accounting order. One coherent five-track ruler at every width.
   A STT | B Description | C Quantity | D Unit Price | E Amount.
   Captions are adaptive to the displayed NUMERIC widths; never move values. */
#cartBottomSheet .cart-compact-grid,
#cartBottomSheet[data-cart-mode="edit"] .cart-compact-grid,
#cartBottomSheet[data-cart-mode="preview"] .cart-compact-grid{
  grid-template-columns:
    var(--cart-stt-track,24px) minmax(0,1fr)
    var(--cart-qty-track,96px)
    var(--cart-unit-track,54px)
    var(--cart-total-track,69px) !important;
}
#cartBottomSheet .cart-compact-grid .cart-qty{
  grid-area:auto !important;
  grid-column:3 !important;
  grid-row:1 !important;
}
#cartBottomSheet .cart-compact-grid .cart-price{
  grid-area:auto !important;
  grid-column:4 !important;
  grid-row:1 !important;
}
#cartBottomSheet .cart-compact-grid .cart-total{
  grid-area:auto !important;
  grid-column:5 !important;
  grid-row:1 !important;
}
#orderDetailContentToShare .order-detail-compact-grid{
  grid-template-columns:
    var(--order-stt-track,24px) minmax(0,1fr)
    var(--order-qty-track,29px)
    var(--order-price-track,60px)
    var(--order-total-track,76px) !important;
}
#orderDetailContentToShare .order-detail-compact-grid .order-qty{
  grid-area:auto !important;
  grid-column:3 !important;
  grid-row:1 !important;
}
#orderDetailContentToShare .order-detail-compact-grid .order-price{
  grid-area:auto !important;
  grid-column:4 !important;
  grid-row:1 !important;
}
#orderDetailContentToShare .order-detail-compact-grid .order-total{
  grid-area:auto !important;
  grid-column:5 !important;
  grid-row:1 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-qty,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-qty{
  grid-column:3 !important;
  grid-row:2 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-price,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-price{
  grid-column:4 !important;
  grid-row:2 !important;
}
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] .cart-column-header .cart-total,
#cartBottomSheet[data-cart-mode="edit"][data-compact-two-line="1"] #cartItemList .cart-compact-grid .cart-total{
  grid-column:5 !important;
  grid-row:2 !important;
}

/* UI-114 — SHARED AXES, ADAPTIVE SPACING, QUIETER QUANTITY STEPPER.
   No per-row translations. Cart runtime calculates 6–11px based on
   available product-name width. Saved order computes 6–10px.
   Preserve the actual 30x34px button hit areas; shrink only the
   PAINTED circle, not the clickable element. */
#cartBottomSheet .cart-column-header,
#cartBottomSheet[data-cart-mode="edit"] .cart-column-header,
#cartBottomSheet[data-cart-mode="preview"] .cart-column-header,
#cartBottomSheet #cartItemList .cart-compact-grid,
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid,
#cartBottomSheet[data-cart-mode="preview"] #cartItemList .cart-compact-grid {
  column-gap:var(--cart-finance-gap,6px) !important;
}
#orderDetailContentToShare .order-column-header,
#orderDetailContentToShare #detailModalItems .order-detail-compact-grid,
#orderDetailContentToShare.order-readable-compact #detailModalItems .order-detail-compact-grid {
  column-gap:var(--order-finance-gap,6px) !important;
}
/* Same left-edge ruler for header TÊN and body product text. */
#cartBottomSheet .cart-column-header .cart-stt,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-stt,
#orderDetailContentToShare .order-column-header .order-stt,
#orderDetailContentToShare #detailModalItems .order-detail-compact-grid .order-stt{
  text-align:center !important;
  justify-self:stretch !important;
  padding-left:0 !important;
  padding-right:0 !important;
}
#cartBottomSheet .cart-column-header .cart-name,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-left > .min-w-0,
#cartBottomSheet #cartItemList .cart-compact-grid .cart-name-note-trigger,
#orderDetailContentToShare .order-column-header .order-name,
#orderDetailContentToShare #detailModalItems .order-detail-compact-grid > .min-w-0 {
  text-align:left !important;
  justify-self:stretch !important;
  margin-left:0 !important;
  padding-left:0 !important;
  min-width:0 !important;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control{
  height:36px !important;
  min-height:36px !important;
  padding:1px 2px !important;
  border-color:#e5e7eb !important;
  box-shadow:0 1px 2px rgba(15,23,42,.045) !important;
}
/* Keep hit areas while rendering 26px soft circles. */
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control > button{
  box-sizing:border-box;
  height:34px !important;
  min-height:34px !important;
  width:30px !important;
  min-width:30px !important;
  background-color:transparent !important;
  border-radius:999px !important;
  touch-action:manipulation;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control > button:first-child {
  background-image:radial-gradient(circle 13px at center,#f1f5f9 98%,transparent 100%) !important;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control > button:last-child {
  background-image:radial-gradient(circle 13px at center,#16a34a 98%,transparent 100%) !important;
}
#cartBottomSheet[data-cart-mode="edit"] #cartItemList .cart-compact-grid .cart-qty-control > input{
  height:34px !important;
  min-height:34px !important;
  font-size:12px !important;
  font-weight:700 !important;
}
#cartBottomSheet #cartItemList .cart-compact-grid .cart-price .cart-money-value,
#orderDetailContentToShare #detailModalItems .order-price{
  font-weight:650 !important;
}
#cartBottomSheet #cartItemList .cart-compact-grid .cart-total .cart-money-value,
#orderDetailContentToShare #detailModalItems .order-total{
  font-weight:800 !important;
}
/* Keep the narrow two-line fallback instead of squeezing touch controls. */

/* UI-117 — SCROLL OWNER DETERMINES THE HEADER RULER
   #cartItemList and #detailModalItems scroll; their headers do NOT.
   Classic desktop scrollbars consume horizontal pixels, whereas
   macOS/iOS overlay scrollbars usually do not. Read the actual
   scrollbar width in JS, never hardcode 12/15/17px, and reserve it
   ONLY on the header's far-right padding. Left padding stays 16px.
   A--E values and header use exactly the same available content width.
   Grouping is semantic, not five equally-sized columns:
   STT compact / Name flexible / SL centred / Price & Total right. */
#cartBottomSheet > .cart-column-header {
  box-sizing:border-box !important;
  padding-right:calc(1rem + var(--cart-scrollbar-inset,0px)) !important;
}
#orderDetailContentToShare > .order-column-header {
  box-sizing:border-box !important;
  padding-right:calc(1rem + var(--order-scrollbar-inset,0px)) !important;
}

/* UI-118 / UI-119 — Debt cards: preserve the natural card rhythm.
   Avatar | (customer name, last transaction) | monetary amount. Money
   is centered VERTICALLY against both lines of customer information, not
   forced up to the name's baseline. Only the name/detail may truncate.
   Sorting remains compact without changing monetary semantics. */
#tab-cong-no .debt-sort-row{
  min-height:36px;
  min-width:0;
}
#tab-cong-no .debt-sort-control{
  display:inline-flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  flex:0 0 auto;
  min-width:0;
}
#tab-cong-no .debt-sort-control > i{
  font-size:13px;
  color:#64748b;
  flex:none;
}
#tab-cong-no #debtSortSelect{
  height:36px;
  min-height:36px;
  max-width:152px;
  font-size:12px;
  line-height:1.25;
  font-weight:650;
  white-space:nowrap;
  background-color:#f8fafc;
  touch-action:manipulation;
}
#tab-cong-no .debt-customer-card{
  display:grid;
  grid-template-columns:40px minmax(0,1fr) max-content;
  align-items:center;
  column-gap:10px;
  min-width:0;
}
#tab-cong-no .debt-customer-avatar{
  width:40px;
  min-width:40px;
  min-height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
}
#tab-cong-no .debt-customer-body{
  min-width:0;
}
#tab-cong-no .debt-customer-name{
  flex:1 1 auto;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  line-height:1.35;
}
#tab-cong-no .debt-customer-money{
  grid-column:3;
  align-self:center;
  justify-self:end;
  min-width:max-content;
  margin:0;
  text-align:right;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
  line-height:1.25;
}
#tab-cong-no .debt-customer-detail{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  line-height:1.5;
}
@media(max-width:350px){
  #tab-cong-no .debt-customer-card{
    grid-template-columns:36px minmax(0,1fr) max-content;
    column-gap:8px;
  }
  #tab-cong-no .debt-customer-avatar{
    width:36px;
    min-width:36px;
  }
  #tab-cong-no .debt-customer-money{font-size:14px}
  #tab-cong-no #debtSortSelect{max-width:137px}
}
