/* DSSM additions on top of the designer's style.css (kept separate so the design file stays untouched). */

/* Invoice / monthly bill on a phone screen: fit the width instead of a fixed 794 px sheet (print layout is unchanged). */
@media screen and (max-width: 820px) {
  body.paperbody { padding: 0; }
  body.paperbody .noprint { padding: .75rem; flex-wrap: wrap; }
  .a4 { width: auto; max-width: 100%; min-height: 0; padding: 20px 16px; gap: 18px; box-shadow: none; }
  .a4 .hd { flex-wrap: wrap; gap: 12px; }
  .a4 .meta { grid-template-columns: 1fr; gap: 12px; }
  .a4 .totals { width: 100%; }
  .a4 > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .a4 .foot { flex-wrap: wrap; gap: 6px; }
}
@media print { .a4 { width: 794px; } }

/* direction-aware chevrons: .prev = back/previous (left in LTR, right in RTL); .flip (style.css) mirrors forward arrows in RTL */
.prev{transform:scaleX(-1)}
[dir=rtl] .prev{transform:none}

/* ---------- collapsible side menu (desktop) ---------- */
.navtoggle{flex:none}
html.nav-collapsed{--sidebar-w:76px}
html.nav-collapsed .sidebar{padding-inline:.75rem;align-items:stretch}
html.nav-collapsed .sidebar .brand{justify-content:center;padding-inline:0}
html.nav-collapsed .sidebar .brand .bn,
html.nav-collapsed .sidenav a span{display:none}
html.nav-collapsed .sidenav a{justify-content:center;padding-inline:0}
html.nav-collapsed .sidenav a[aria-current=page]::before{inset-inline-start:-.75rem}
html.nav-collapsed .sidenav .navlabel{height:1px;margin:.5rem .75rem;padding:0;font-size:0;background:var(--line);overflow:hidden}
html.nav-collapsed .sidebar .usercard{flex-direction:column;padding:.5rem;gap:.5rem}
html.nav-collapsed .sidebar .usercard>div{display:none}
@media (max-width:767.98px){.navtoggle{display:none!important}}

/* ---------- navigation progress bar + busy buttons ---------- */
html.is-loading::before{content:"";position:fixed;inset-inline:0;top:0;height:3px;z-index:200;background:linear-gradient(90deg,var(--brand-600),var(--brand-500),var(--brand-600));background-size:200% 100%;animation:dssm-bar 1s linear infinite,dssm-grow 8s cubic-bezier(.1,.7,.2,1) forwards;transform-origin:0 50%}
[dir=rtl] html.is-loading::before,html[dir=rtl].is-loading::before{transform-origin:100% 50%}
@keyframes dssm-bar{to{background-position:-200% 0}}
@keyframes dssm-grow{from{transform:scaleX(.05)}to{transform:scaleX(.95)}}
button.is-busy{position:relative;opacity:.8;cursor:progress}
button.is-busy::after{content:"";width:1em;height:1em;margin-inline-start:.5rem;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;display:inline-block;animation:dssm-spin .7s linear infinite}
@keyframes dssm-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){html.is-loading::before,button.is-busy::after{animation-duration:2.5s}}

/* ---------- 80 mm thermal slip: same layout and type as the old software (Courier, printer Black Copper BC95) ---------- */
body.paperbody .thermal{width:80mm;max-width:100%;margin:0 auto;background:#fff;color:#000;padding:15px 10px;border-radius:4px;box-shadow:0 0 10px rgba(0,0,0,.15);font-family:'Courier New',Courier,monospace;font-size:13px;line-height:1.4}
html[lang=ur] .thermal{font-family:"Noto Naskh Arabic",'Courier New',monospace;font-size:14px;line-height:1.7}
.thermal *{letter-spacing:0}
.thermal .t-head{text-align:center;margin-bottom:12px}
.thermal .t-shop{font-size:18px;font-weight:700;text-transform:uppercase}
.thermal .t-sub{font-size:11px;margin-bottom:5px;white-space:pre-line;unicode-bidi:plaintext}
.thermal .t-title{display:inline-block;font-weight:700;border:1px solid #000;padding:2px 8px;margin-top:5px;text-transform:uppercase}
.thermal .t-rule{border-top:1px dashed #000;margin:8px 0}
.thermal table{width:100%;border-collapse:collapse;font-size:12px}
.thermal th,.thermal td{padding:2px 0;vertical-align:top;text-align:start}
.thermal .t-info th{width:38%;font-weight:700}
.thermal .t-cust,.thermal .t-name{font-size:13px;font-weight:800}
.thermal .t-items th{border-bottom:1px dashed #000;padding:4px 2px;font-weight:700}
.thermal .t-items td{padding:4px 2px}
.thermal .t-items th:first-child{width:40%}
.thermal .t-items .r{text-align:right;white-space:nowrap}
.thermal .t-unit{display:block;font-size:10px}
.thermal .t-totals th,.thermal .t-totals td{text-align:right}
.thermal .t-totals th{font-weight:400;padding-inline-end:15px}
.thermal .t-totals td{width:35%;font-weight:700}
.thermal .t-totals .t-grand th,.thermal .t-totals .t-grand td{font-size:14px;font-weight:800;border-top:1px dashed #000;border-bottom:1px dashed #000;padding-top:4px;padding-bottom:4px}
.thermal .t-box{border:1px dashed #000;border-radius:3px;padding:6px;margin-top:8px;font-size:11px}
.thermal .t-boxhead{font-size:11px;font-weight:700;text-transform:uppercase;border-bottom:1px solid #000;padding-bottom:2px;margin-bottom:4px}
.thermal .t-boxhead.t-next{margin-top:8px;border-top:1px dashed #000;padding-top:6px}
.thermal .t-row{display:flex;justify-content:space-between;gap:8px;margin:2px 0;font-size:11px}
.thermal>.t-row{font-size:12px;padding:2px 0}
.thermal .t-row.t-strong{border-top:1px dotted #000;padding-top:4px;margin-top:4px;font-size:12px}
.thermal>.t-row.t-outstanding{font-size:14px;border-top:1px dashed #000;border-bottom:1px dashed #000;padding:6px 0;margin-top:6px}
.thermal .t-foot{text-align:center;margin-top:15px;font-size:11px}
.thermal .t-note{font-style:italic;margin-bottom:3px;white-space:pre-line}
.thermal .t-feed{display:none}
@media print{
  html,body,body.paperbody{background:#fff!important;margin:0!important;padding:0!important;height:auto!important;overflow:visible!important}
  body.paperbody .thermal{width:76mm;max-width:100%;margin:0;padding:5px 5px 0;box-shadow:none;border-radius:0;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .thermal,.thermal *{color:#000!important}
  .thermal strong,.thermal .t-name,.thermal .t-items th,.thermal .t-grand th,.thermal .t-grand td{font-weight:900!important}
  .thermal .t-feed{display:block;height:25mm}   /* push the last line past the cutter */
}

/* ---------- fixes found on the sale screen ---------- */
[hidden]{display:none!important}                                  /* design CSS gives .chip/.alert a display value that beat the hidden attribute */
.cl .row2{flex-wrap:wrap;row-gap:.5rem}
.cl .lt{margin-inline-start:auto}
input[type=date].input{font-size:.9375rem;min-width:0}
@media (max-width:480px){
  input[type=date].input::-webkit-calendar-picker-indicator{display:none}
  .cl .rate{flex:0 0 auto}
}

/* ---------- phone fixes found in the visual review ---------- */
@media (max-width:767.98px){
  .sale-grid .qchips{flex-wrap:wrap!important;overflow:visible!important}          /* all product chips visible, no hidden scroll strip */
  .toolbar .field.full{min-width:100%}                                                /* long selects (month names) get the full width */
}

/* ---------- compact phone cards (sales, customers, ledger list): about 3x shorter than the generic card ---------- */
@media (max-width:767.98px){
  .table.cards.dense tr{display:grid;column-gap:.75rem;row-gap:.125rem;padding:.5rem .875rem;margin-bottom:.5rem}
  .table.cards.dense td{display:block;width:auto;padding:0;margin:0;border:0}
  .table.cards.dense td .num,.table.cards.dense td .money{white-space:nowrap}
  .table.cards.dense td::before{display:none}
  .table.cards.dense td.primary{font-size:1rem;border:0;margin:0;padding:0;overflow-wrap:anywhere}
  .table.cards.dense td.num{text-align:end}
  .table.cards.dense td.actions{display:flex;justify-content:flex-end;padding:0}
  .table.cards.dense .muted-cell{color:var(--muted);font-size:.875rem}
  /* sales: who | total / invoice, date | type / actions */
  .dense-sales tr{grid-template-columns:auto auto 1fr auto;overflow:hidden}
  .dense-sales td:nth-child(1){grid-column:1/4;grid-row:1}
  .dense-sales td:nth-child(5){grid-column:4;grid-row:1;font-weight:750}
  .dense-sales td.inv .inv-pre{display:none}
  .table.cards.dense.dense-sales td.inv::before{display:inline;content:"#"}
  .dense-sales td:nth-child(2){grid-column:1;grid-row:2;color:var(--muted);font-size:.8125rem;white-space:nowrap}
  .dense-sales td:nth-child(3){grid-column:2;grid-row:2;color:var(--muted);font-size:.8125rem;white-space:nowrap}
  .dense-sales td:nth-child(4){grid-column:4;grid-row:2;text-align:end}
  .dense-sales td:nth-child(6){grid-column:1/-1;grid-row:3}
  /* customers: name | balance / shift, litres, phone / actions */
  .dense-customers tr{grid-template-columns:auto auto 1fr auto}
  .dense-customers td:nth-child(1){grid-column:1/4;grid-row:1}
  .dense-customers td:nth-child(5){grid-column:4;grid-row:1;font-weight:750}
  .dense-customers td:nth-child(3){grid-column:1;grid-row:2}
  .dense-customers td:nth-child(4){grid-column:2;grid-row:2;color:var(--muted);font-size:.875rem;align-self:center}
  .dense-customers td:nth-child(4)::after{content:" " attr(data-suffix)}
  .dense-customers td:nth-child(2){grid-column:3/5;grid-row:2;text-align:end;color:var(--muted);font-size:.875rem;align-self:center}
  .dense-customers td:nth-child(6){grid-column:1/-1;grid-row:3}
  /* ledger list: name | balance / phone | action */
  .dense-ledger tr{grid-template-columns:1fr auto}
  .dense-ledger td:nth-child(1){grid-column:1;grid-row:1}
  .dense-ledger td:nth-child(3){grid-column:2;grid-row:1;font-weight:750}
  .dense-ledger td:nth-child(2){grid-column:1;grid-row:2;color:var(--muted);font-size:.875rem;align-self:center}
  .dense-ledger td:nth-child(4){grid-column:2;grid-row:2}
}

/* ---------- quick date chips + collapsible filters + one summary card ---------- */
a.qchip[aria-current=true]{background:var(--brand-600);border-color:var(--brand-600);color:#fff}
details.filters>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:.5rem;min-height:44px;padding:.5rem 1rem;font-weight:650;color:var(--brand-700);border:1px solid var(--line-strong);border-radius:10px;background:#fff}
details.filters>summary::-webkit-details-marker{display:none}
details.filters[open]>summary{margin-bottom:.75rem}
@media (min-width:768px){details.filters>summary{display:none}}
.sumcard{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.25rem 1rem;padding:1rem 1.25rem}
.sumcard .k{color:var(--muted);font-size:.8125rem;font-weight:550}
.sumcard .v{font-weight:750;font-size:1.125rem;line-height:1.3;overflow-wrap:anywhere}
@media (max-width:767.98px){
  .sumcard{grid-template-columns:1fr 1fr;padding:.75rem 1rem}
  .sumcard .main{grid-column:1/-1;display:flex;justify-content:space-between;align-items:baseline;border-bottom:1px solid var(--line);padding-bottom:.5rem;margin-bottom:.25rem}
  .sumcard .main .v{font-size:1.375rem}
  .sumcard .v{font-size:1rem}
}
/* sale screen: the chosen sale type must be obvious at a glance */
#saleForm .seg input:checked+label{background:var(--brand-600);color:#fff;box-shadow:0 1px 3px rgba(22,32,46,.25)}
#saleForm .seg input:disabled+label{cursor:not-allowed}

/* ---------- find a customer fast ---------- */
.findbar{display:flex;gap:.75rem;flex-wrap:wrap;align-items:center;position:sticky;top:64px;z-index:5;background:var(--bg,#F4F6FA);padding:.5rem 0}
.findbar .findbox{flex:1 1 260px}
.findbar .findbox .input{min-height:52px;font-size:1.0625rem}
.qchip[aria-pressed=true]{background:var(--brand-600);color:#fff;border-color:var(--brand-600)}
.custlist{list-style:none;margin:0;padding:0;display:grid;gap:.5rem;grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr))}
.custlist li{display:flex;flex-direction:column;gap:.625rem;padding:.75rem .875rem;content-visibility:auto;contain-intrinsic-size:auto 140px}
.cl-main{display:flex;flex-direction:column;gap:2px;min-width:0}
.cl-name{font-size:1.125rem;overflow-wrap:anywhere}
.cl-sub{color:var(--muted);font-size:.875rem}
.cl-bal{font-size:.9375rem}
.cl-acts{display:flex;gap:.5rem;align-items:center;margin-top:auto}
.cl-acts .btn{flex:1;justify-content:center}
.cl-acts form{display:inline-flex}
.find-empty{padding:1.5rem;text-align:center}
.findbar{top:68px}
@media (max-width:767.98px){.findbar{top:60px}}


/* ---------- POS: compact, calm sale screen ---------- */
.pos{grid-template-columns:minmax(0,1fr) 300px;gap:1rem}
.pos-main{display:flex;flex-direction:column;gap:.75rem;min-width:0}
.pos-card{display:flex;flex-direction:column;gap:.625rem;padding:.875rem}
.pos .cpick{gap:.5rem}
.pos .cpick .input{min-height:48px;font-size:1.0625rem}
.pos .plist{max-height:300px;overflow:auto}
.pos-shift,.pos-products{gap:.375rem!important}
.pos .qchip{min-height:44px!important;padding:0 .75rem!important;font-size:.875rem!important;font-weight:600;border-color:var(--line)}
html[lang=ur] .pos .qchip{font-size:1rem!important}
.pos-shift .qchip[aria-selected=true]{border-color:var(--brand-600)}
.pos-products{flex-wrap:wrap!important;overflow:visible!important}
.pos-products .qchip{background:var(--surface-2)}
.pos .chip{align-self:flex-start;flex-wrap:wrap;margin:0}
.pos-last{display:flex;align-items:center;justify-content:space-between;gap:.5rem;font-size:.875rem;color:var(--muted)}
.pos-last .btn{flex:none;min-height:40px}
.pos-when{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:.625rem;align-items:center}
.pos-when .input{min-height:46px;height:46px}
.pos-when .seg{padding:3px}
.pos-when .seg label{min-height:40px}
.pos-rows{display:flex;flex-direction:column}
.pos-rows:empty::before{content:attr(data-empty);display:block;padding:.75rem;text-align:center;font-size:.875rem;color:var(--muted);border:1px dashed var(--line-strong);border-radius:10px}
.pos .cl{grid-template-columns:minmax(0,1fr) 40px;border:0;border-top:1px solid var(--line);border-radius:0;padding:.625rem 0 .25rem;gap:.375rem}
.pos .cl .field{min-width:0}
.pos .cl .select{min-height:40px;height:40px;font-weight:650;font-size:.9375rem}
.pos .cl .iconbtn.del{width:40px;height:40px}
.pos .cl .row2{gap:.5rem;justify-content:flex-start;flex-wrap:nowrap}
.pos .cl .stepper{width:138px;grid-template-columns:40px 1fr 40px}
.pos .cl .stepper .iconbtn{width:40px}
.pos .cl .stepper .iconbtn,.pos .cl .stepper .input{height:42px;min-height:42px}
.pos .cl .row2>.small{min-width:0}
.pos .cl .rate .input{width:72px!important;min-height:42px!important;height:42px;padding-inline:.375rem;text-align:center}
.pos .cl .rate{flex:0 0 auto}
.pos .cl .lt{margin-inline-start:auto;font-size:.9375rem}
@media (min-width:900px){
  .pos .cl{grid-template-columns:minmax(150px,1fr) auto 40px;align-items:center}
  .pos .cl .row2{grid-column:2;grid-row:1}
  .pos .cl .iconbtn.del{grid-column:3;grid-row:1}
  .pos .cl .lt{min-width:6.5rem;text-align:end}
}
.pos-sum{padding:.875rem;display:flex;flex-direction:column;gap:.5rem}
.pos-sum .sumrow{padding:0}
.pos-line{display:flex;align-items:center;justify-content:space-between;gap:.75rem;font-size:.9375rem}
.pos-line label{color:var(--muted)}
.pos-line .input,.pos-line .select{width:150px;min-height:42px;height:42px}
.pos-line .input{text-align:end}
.pos-total{margin:0!important;align-items:baseline}
.pos-total .money{font-size:1.75rem}
@media (max-width:1100px){.pos{grid-template-columns:minmax(0,1fr) 270px}}
@media (max-width:767.98px){
  .pos{grid-template-columns:minmax(0,1fr);gap:.625rem}
  .pos-main{gap:.625rem}
  .pos-card{padding:.625rem;gap:.5rem}
  .pos-sum{position:static;padding:.625rem}
  .pos-sum .pos-sub,.pos-sum .pos-total,.pos-sum .desk-sum-save{display:none}   /* the bottom bar already shows total + Save */
}
.pos .cpick:has(#cchip:not([hidden])) .pos-shift{display:none}     /* customer chosen: shift buttons are no longer needed */
@media (max-width:767.98px){
  .pos .cl .row2{gap:.3rem}
  .pos .cl .row2>.small:not(:first-of-type){display:none}          /* the "×" sign */
  .pos .cl .stepper{width:126px;grid-template-columns:40px 1fr 40px;gap:3px}
  .pos .cl .rate .input{width:60px!important}
  .pos .cl .lt{font-size:.875rem}
}
/* finger-size controls on phones (44px) */
.pos .qchip{min-width:48px;justify-content:center}
@media (max-width:767.98px){
  .pos .cl{grid-template-columns:minmax(0,1fr) 44px}
  .pos .cl .select{height:44px;min-height:44px}
  .pos .cl .iconbtn.del{width:44px;height:44px}
  .pos .cl .stepper{width:132px;grid-template-columns:44px 1fr 44px;gap:0}
  .pos .cl .stepper .iconbtn{width:44px}
  .pos .cl .stepper .iconbtn,.pos .cl .stepper .input,.pos .cl .rate .input{height:44px!important;min-height:44px!important}
  .pos-line .input,.pos-line .select{height:44px;min-height:44px}
}
