/* BUILD 148 — Adaptive Device UI + Turbo D1 visual polish */
:root{--tap-min:46px;--ui-gap:10px}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{min-width:0;overflow-x:hidden}
button,input,select,textarea{touch-action:manipulation}

/* POS adapts by available screen, not by shrinking text until unreadable. */
.posScreen{max-width:100%;overflow:hidden}
.posScreen .posGrid{min-width:0}
.posScreen .productPanel,.posScreen .cartPanel{min-width:0}
.posScreen .checkoutActions{align-items:stretch}
.posScreen .checkoutActions .posBtn{white-space:normal;overflow-wrap:anywhere}
.posScreen .barcodeDock,.posScreen .posToolbar,.posScreen .cartSummary{min-width:0}

/* Desktop / large POS: balanced workspace and readable checkout. */
@media (min-width:1201px){
  .posScreen .posGrid:not(.posCartOnly){grid-template-columns:minmax(420px,.92fr) minmax(620px,1.45fr)!important;gap:14px!important}
  .posScreen .checkoutActions{grid-template-columns:minmax(0,1fr)!important;gap:10px!important}
  .posScreen .priceGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .paymentGroup{grid-template-columns:repeat(5,minmax(0,1fr))!important}
  .posScreen .actionGroup,.posScreen .utilityGroup,.posScreen .shortcutGroup{grid-template-columns:repeat(6,minmax(0,1fr))!important}
  .posScreen .checkoutActions .posBtn{min-height:62px!important;font-size:14px!important}
}

/* Tablet landscape / small laptop */
@media (min-width:769px) and (max-width:1200px){
  .posScreen{padding:10px!important}
  .posScreen .posGrid:not(.posCartOnly){grid-template-columns:minmax(300px,.85fr) minmax(430px,1.25fr)!important;gap:10px!important}
  .posScreen .checkoutActions{grid-template-columns:1fr!important;gap:8px!important}
  .posScreen .priceGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .paymentGroup{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .posScreen .actionGroup,.posScreen .utilityGroup,.posScreen .shortcutGroup{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .posScreen .checkoutActions .posBtn{min-height:58px!important;font-size:13px!important;padding:9px 6px!important}
  .cartButtons button,.tableActions button{min-height:44px!important}
}

/* Tablet portrait and phones: stack panels, keep controls finger-sized. */
@media (max-width:768px){
  #app:has(> .posScreen){height:auto!important;min-height:100dvh!important;overflow:visible!important}
  #app>.posScreen{height:auto!important;min-height:calc(100dvh - 58px)!important;overflow:visible!important;padding:8px!important}
  .posScreen .posGrid,.posScreen .posGrid:not(.posCartOnly){display:grid!important;grid-template-columns:1fr!important;grid-template-rows:auto auto!important;gap:8px!important;overflow:visible!important}
  .posScreen .productPanel,.posScreen .cartPanel{height:auto!important;max-height:none!important;overflow:visible!important}
  .posScreen .products{max-height:38dvh!important;overflow:auto!important}
  .posScreen .cartPanel{order:-1!important}
  .posScreen .cartItems{max-height:38dvh!important;overflow:auto!important}
  .posScreen .posToolbar{position:sticky!important;top:0!important;z-index:12!important;background:#fff!important;border-radius:12px!important;box-shadow:0 4px 14px rgba(5,46,27,.09)!important}
  .posScreen .checkoutActions{position:static!important;grid-template-columns:1fr!important;gap:8px!important}
  .posScreen .checkoutGroup{padding:26px 7px 7px!important;gap:6px!important}
  .posScreen .priceGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .paymentGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .actionGroup,.posScreen .utilityGroup,.posScreen .shortcutGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .checkoutActions .posBtn{min-height:54px!important;font-size:12px!important;line-height:1.15!important;padding:8px 5px!important}
  .posScreen .checkoutActions .posBtn small{font-size:9px!important;margin-bottom:3px!important}
  .barcodeDock{position:sticky!important;bottom:0!important;z-index:11!important;background:#fff!important;box-shadow:0 -4px 14px rgba(5,46,27,.08)!important}
  .barcodeDock input{min-height:48px!important;font-size:16px!important}
  nav{overscroll-behavior:contain}
  table{font-size:12px!important}
  th{font-size:11px!important}
  td{font-size:12px!important}
}

/* Compact phones */
@media (max-width:480px){
  .posScreen{padding:6px!important}
  .posScreen .posToolbar{grid-template-columns:1fr 1fr!important;gap:5px!important;padding:6px!important}
  .posScreen .posSearchWrap{grid-column:1/-1!important}
  .posScreen .posToolbar button,.posScreen .posToolbar select,.posScreen .posToolbar input{min-height:46px!important;font-size:12px!important}
  .posScreen .paymentGroup,.posScreen .actionGroup,.posScreen .utilityGroup,.posScreen .shortcutGroup{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .posScreen .checkoutActions .posBtn{min-height:52px!important;font-size:11px!important}
  .cashPayment,.splitPayment{width:min(96vw,560px)!important;max-height:92dvh!important;overflow:auto!important}
  .splitPaymentRow{grid-template-columns:1fr!important}
  .cashKeypad button,.referenceKeypad button{min-height:58px!important}
  .cartButtons{flex-wrap:wrap!important}
}

/* Touch devices receive larger targets even on higher-resolution tablets. */
@media (pointer:coarse){
  button,.cartQtyBtn,.tableActions button{min-height:var(--tap-min)}
  input,select,textarea{min-height:46px;font-size:16px}
  .posScreen .checkoutActions .posBtn{min-height:58px!important}
}

/* Portrait tablet uses a one-column POS to avoid cramped cart/buttons. */
@media (orientation:portrait) and (min-width:600px) and (max-width:1024px){
  .posScreen .posGrid:not(.posCartOnly){grid-template-columns:1fr!important;grid-template-rows:auto auto!important}
  .posScreen .cartPanel{order:-1!important}
  .posScreen .products{max-height:36dvh!important}
  .posScreen .paymentGroup{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .posScreen .actionGroup,.posScreen .utilityGroup,.posScreen .shortcutGroup{grid-template-columns:repeat(3,minmax(0,1fr))!important}
}

/* Save badge stays visible but does not block cashier work. */
.networkBadge,#saveStatusBar{backdrop-filter:blur(8px)}
