/* =====================================================================
   RestoPOS — all screens on every device
   (iPhone · Samsung · Honor · iPad · Galaxy Tab · desktop)
   Direction-neutral (logical properties) → the same file serves Arabic (RTL) and English (LTR).
   Loaded after app.css / pos.css on every screen.
   ===================================================================== */

/* never let a wide element widen the whole page (mobile browsers then zoom the page out) */
html,body{max-width:100%;overflow-x:clip}
img,svg,video,canvas,iframe{max-width:100%}
.main,.wrap,.card,.grid>*,.page-h,.page-h>*{min-width:0}
/* grid / flex children may shrink below their text width (long names wrap or get … instead of widening the page) */
[class*="grid"]>*,[class*="g2"]>*,[class*="g3"]>*,[class*="g4"]>*,form>*,.row-set>*{min-width:0}
.card{max-width:100%}
input,select,textarea{max-width:100%}

/* every data table scrolls sideways inside its own box (wrapped by shell.js) */
.tbl-wrap{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
.tbl-wrap>table{min-width:100%}
.tbl-auto{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}

/* ---------- title bar on phones ---------- */
@media (max-width:640px){
  .titlebar{gap:6px;padding-inline:8px;min-width:0}
  .titlebar>*{flex-shrink:0}
  .titlebar .tb-sp{flex:1 1 0;min-width:0}
  .tb-branch{flex:0 1 auto;min-width:0;padding:0 6px;gap:4px;overflow:hidden}
  .tb-branch select{max-width:84px;min-width:0;text-overflow:ellipsis}
  .tb-branch>span{max-width:84px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .tb-lang a{padding:4px 6px;min-width:24px}
  .winbtns{gap:2px}
  .winbtns button,.winbtns a{width:32px;height:32px}
  .tb-user .av{width:28px;height:28px}
  .page-h{flex-wrap:wrap;gap:8px}
  .page-h .acts{flex-wrap:wrap}
  .mh{gap:8px}.mh>span{min-width:0;overflow:hidden;text-overflow:ellipsis}
  .row-set{gap:10px}.row-set>span{min-width:0}
}
@media (max-width:400px){
  .winbtns button{display:none}             /* refresh / full-screen — the drawer & pull-to-refresh cover them */
  .tb-branch select{max-width:70px}
  .tb-branch svg{display:none}
  .tool{min-width:58px}
}

/* ---------- POS header: keep everything on one row on laptops / landscape tablets ---------- */
@media (min-width:1025px){
  .app>header{overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
  .app>header::-webkit-scrollbar{display:none}
  .app>header>*{flex-shrink:0}
}
@media (min-width:1025px) and (max-width:1500px){
  .app>header{gap:6px}
  .app>header .otype{min-width:0;padding:0 10px;gap:6px}
  .app>header .round{width:52px;height:52px;font-size:22px}
  .app>header .sq{width:56px;height:52px;font-size:26px}
  .app>header .brand{min-width:0;flex-shrink:1;overflow:hidden}
  .app>header .brand b{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}
  .app>header .brand small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
}

/* ---------- touch devices: bigger tap targets, no sticky hover ---------- */
@media (pointer:coarse){
  .btn.sm{min-height:36px}
  .chk{min-height:32px}
}

/* ---------- iPhone notch / home bar ---------- */
@supports (padding:max(0px)){
  .statusbar{padding-inline:max(0px,env(safe-area-inset-left)) max(0px,env(safe-area-inset-right))}
}

/* long button labels wrap on phones instead of widening the page */
@media (max-width:640px){
  .btn{max-width:100%;white-space:normal;height:auto;min-height:42px;line-height:1.35;padding-block:7px;text-align:center}
  .btn.sm{min-height:36px;padding-block:5px}
}
@media (max-width:640px){
  .card[style*="display:flex"],div[style*="display:flex"]:not(.kp-row):not(.tabs){flex-wrap:wrap}
  .card[style*="display:flex"]>*{min-width:0}
  [style*="min-width:220px"],[style*="min-width:200px"],[style*="min-width:180px"]{min-width:0!important}
}
