/* Cashier workspace. All layout rules stay scoped to POS. */
#posMenuBtn,#posOrdersShortcut{display:none}
.app.pos-mode{height:100dvh;min-height:0;overflow:hidden;padding:0;background:#f7f5f0;color:#262b2b;display:flex;flex-direction:column}
.app.pos-mode .topbar{position:relative;inset:auto;flex:none;height:58px;min-height:58px;padding:6px clamp(12px,1.5vw,24px);background:#fff;border-bottom:1px solid #e5e1d8;box-shadow:none;gap:12px;z-index:25}
.app.pos-mode .brand{font-size:clamp(16px,1.45vw,20px);white-space:nowrap;color:#262b2b}
.app.pos-mode .tabs{display:none}
.app.pos-mode.pos-menu-open .tabs{display:flex;position:fixed;top:58px;right:0;bottom:0;left:auto;width:min(290px,85vw);height:auto;flex-direction:column;overflow:auto;padding:14px;background:#fff;border:1px solid #e5e1d8;box-shadow:-12px 12px 35px #28231b20;z-index:50}
.app.pos-mode .user-box{margin-inline-start:auto;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:nowrap;font-size:13px}
.app.pos-mode #userName{font-weight:800;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.app.pos-mode #shiftBtn,.app.pos-mode #posOrdersShortcut,.app.pos-mode #posMenuBtn,.app.pos-mode #logoutBtn{min-height:39px;padding:6px 10px;border:1px solid #ddd9cf;background:#fff;color:#414641;border-radius:10px;font-size:13px;white-space:nowrap;box-shadow:none}
.app.pos-mode #posMenuBtn,.app.pos-mode #posOrdersShortcut:not([hidden]){display:inline-flex;align-items:center}
.app.pos-mode #shiftBtn{background:#f2f5ed;border-color:#d5e1d0}
.app.pos-mode #posOrdersShortcut[hidden]{display:none}
.app.pos-mode #posOrdersShortcut.has-new{background:#fff6e2;border-color:#e7cd86;color:#654815;font-weight:800}
.app.pos-mode #posOrdersCount{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;margin-inline-start:4px;padding:0 4px;border-radius:7px;background:#ecdfc2}
.app.pos-mode #posOrdersShortcut.has-new #posOrdersCount{background:#ac7924;color:#fff}
.app.pos-mode .pos-connection{font-size:12px}
.app.pos-mode #posView{display:flex;flex:1;min-height:0;min-width:0;max-width:none!important;width:100%;margin:0;padding:12px clamp(12px,1.5vw,24px) 14px}
.app.pos-mode #posView.hidden{display:none}

/* ===== التخطيط =====
   الصف العلوي: لوحة الأرقام وتحتها أزرار الدفع (عمود جانبي عند زاوية الشاشة) + السلة تأخذ كل المساحة الباقية.
   الشريط السفلي بعرض الشاشة كله: ملخص الفاتورة (الباقي · الإجمالي · المستلم) ثم أزرار الوظائف. */
.app.pos-mode .pos-wrap{display:grid;grid-template-columns:clamp(264px,17.5vw,340px) minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;grid-template-areas:"side main" "bottom bottom";gap:10px 12px;width:100%;max-width:none;min-height:0;margin:0}
.app.pos-mode .pos-main{grid-area:main;display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto auto minmax(0,1fr);grid-template-areas:"scan count" "pickup pickup" "site site" "cart cart";column-gap:10px;row-gap:0;min-width:0;min-height:0;background:#fff;border:1px solid #e7e3db;border-radius:16px;padding:12px;box-shadow:0 3px 15px #37302509}
.app.pos-mode .pos-bottom{grid-area:bottom;display:flex;flex-direction:column;gap:8px;min-width:0}

/* البحث / الباركود + عدّاد الأصناف على نفس السطر (لا يأخذ العنوان سطرًا من ارتفاع السلة) */
.app.pos-mode .scan-area{grid-area:scan;position:relative;z-index:8;min-width:0}
.app.pos-mode .scan-area>label{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.app.pos-mode .scan-row{display:flex;gap:8px;margin:0}
.app.pos-mode #scanInput{flex:1;min-width:0;min-height:52px;padding:10px 17px;border:2px solid #d3c18e;border-radius:12px;background:#fffefa;font-size:18px;color:#252b27}
.app.pos-mode #scanInput:focus{border-color:#a57825;outline:3px solid #a578252e}
.app.pos-mode #scanBtn{min-width:92px;min-height:52px;border-radius:12px;background:#323c32;color:#fff;font-size:15px;font-weight:800}
.app.pos-mode #searchResults{position:absolute;top:100%;inset-inline:0;max-height:min(50vh,430px);overflow:auto;display:flex;gap:0;margin:5px 0 0;padding:3px;background:#fff;border:1px solid #e1ddd3;border-radius:12px;box-shadow:0 16px 38px #28231b24}
.app.pos-mode #searchResults:empty{display:none}
.app.pos-mode .search-results .result{min-height:64px;gap:16px;border:0;border-bottom:1px solid #edeae2;border-radius:0;padding:8px 14px;background:#fff;box-shadow:none}
.app.pos-mode .search-results .result:last-child{border-bottom:0}
.app.pos-mode .search-results .result:focus-visible,.app.pos-mode .search-results .result:hover{background:#f8f5eb}
.app.pos-mode .result-name{display:flex;flex-direction:column;align-items:flex-start;gap:3px;min-width:0;color:#292f29;font-size:15px;line-height:1.35}
.app.pos-mode .result-code,.app.pos-mode .r-price small{color:#717872;font-size:12px;font-weight:500}
/* الكاشير يرى حالة التوفر فقط (بلا رقم الرصيد)؛ «غير متوفر» بلون تنبيه */
.app.pos-mode .r-price small.out{color:#b0372b;font-weight:800}
.app.pos-mode .r-price{display:flex;flex-direction:column;align-items:flex-end;gap:3px;white-space:nowrap;color:#252c26}
.app.pos-mode .r-price b{font-size:17px}
.app.pos-mode .pos-cart-heading{grid-area:count;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:108px;min-height:52px;padding:3px 14px;border:1px solid #e6e0d2;border-radius:12px;background:#f7f3e9;text-align:center}
.app.pos-mode .pos-cart-heading strong{font-size:11.5px;font-weight:700;color:#7a7668;white-space:nowrap}
.app.pos-mode .pos-cart-heading span{color:#2d342e;font-size:16px;font-weight:850;white-space:nowrap;font-variant-numeric:tabular-nums}

/* السلة: صفوف نحيفة (52px) حتى يظهر أكثر من 10 أصناف بدون تمرير على شاشة الكاشير، مع بقاء أزرار اللمس 44px */
.app.pos-mode .pickup-context[hidden]{display:none}
.app.pos-mode #holdBtn[hidden],.app.pos-mode #heldListBtn[hidden],.app.pos-mode #clearCart[hidden],.app.pos-mode #debtBtn[hidden]{display:none!important}
.app.pos-mode .pickup-context{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:8px;padding:7px 11px;border:1px solid #d9dfc8;border-radius:9px;background:#f5f8ed;color:#344537;font-size:13px}
.app.pos-mode #pickupContext{grid-area:pickup}
.app.pos-mode #siteOrderContext{grid-area:site}
.app.pos-mode .pickup-context strong{font-size:14px}
.app.pos-mode .pickup-context a{color:inherit}
.app.pos-mode #posPickupBtn.has-new{border-color:#d8ba77;background:#fff5de;color:#75511b}
.app.pos-mode .site-order-context{background:#edf5ff;border-color:#a8c7e8;color:#173b64}
.site-order-row{border:1px solid #d9e3ed;border-radius:12px;padding:14px;margin:10px 0;background:#fff;cursor:pointer}
.site-order-row:focus-visible{outline:3px solid #3578bd;outline-offset:2px}
.site-order-row p{margin:7px 0;overflow-wrap:anywhere}
.site-order-row button{min-height:44px}
.app.pos-mode .pos-main>.table-scroll,.app.pos-mode .pos-main>.pos-cart-table{grid-area:cart}
.app.pos-mode .pos-main>.table-scroll{min-height:0;max-width:none;margin:8px 0 0;border:1px solid #ece8de;border-radius:12px;background:#fff;overflow:auto;overscroll-behavior:contain}
.app.pos-mode .pos-cart-table{width:100%;border:0;border-radius:0;box-shadow:none;background:transparent;border-spacing:0;border-collapse:separate;table-layout:fixed;counter-reset:cartline}
.app.pos-mode .pos-cart-table thead{display:none}
.app.pos-mode .pos-cart-table tbody tr{background:#fff;counter-increment:cartline}
.app.pos-mode .pos-cart-table tbody tr:nth-child(even){background:#fbfaf6}
.app.pos-mode .pos-cart-table tbody tr:hover{background:#f8f5eb}
.app.pos-mode .pos-cart-table tbody td{height:52px;padding:4px 10px;border:0;border-bottom:1px solid #f0ece3;vertical-align:middle;background:transparent;color:#353b35;font-size:15px}
.app.pos-mode .pos-cart-table tbody tr:last-child td{border-bottom:0}
.app.pos-mode .pos-cart-table td:first-child{width:auto;min-width:0}
.app.pos-mode .pos-cart-table td:nth-child(2){width:112px}
.app.pos-mode .pos-cart-table td:nth-child(3){width:168px}
.app.pos-mode .pos-cart-table td:nth-child(4){width:124px}
.app.pos-mode .pos-cart-table td:last-child{width:76px;text-align:center}
.app.pos-mode .pos-cart-table td.cart-product{position:relative;padding-inline-start:46px}
.app.pos-mode .cart-product::before{content:counter(cartline);position:absolute;inset-inline-start:11px;top:50%;display:grid;place-items:center;width:25px;height:25px;margin-top:-12.5px;border-radius:50%;background:#f1ede2;color:#6b6558;font-size:12px;font-weight:800;font-variant-numeric:tabular-nums}
.app.pos-mode .cart-product strong{font-size:15.5px;line-height:1.25;overflow-wrap:anywhere}
.app.pos-mode .cart-product>small:not(.alias-indicator){display:block;margin-top:1px;color:#8a8c84;font-size:11.5px;line-height:1.2;overflow-wrap:anywhere}
.app.pos-mode .cart-unit-price{font-variant-numeric:tabular-nums;white-space:nowrap;color:#69716c!important}
.app.pos-mode .cart-line-total{font-size:17px!important;font-weight:850;font-variant-numeric:tabular-nums;white-space:nowrap}
.app.pos-mode .qty{text-align:center;white-space:nowrap}
/* line-height:0 على الخليتين يمنع سطر النص من إضافة 3-4px فوق ارتفاع الأزرار (فيبقى الصف 52px بالضبط) */
.app.pos-mode .pos-cart-table td.qty,.app.pos-mode .pos-cart-table td:last-child{line-height:0}
.app.pos-mode .qty>*,.app.pos-mode .rm{vertical-align:middle}
.app.pos-mode .qty button{width:44px;min-width:44px;height:44px;min-height:44px;border:1px solid #e3dfd5;border-radius:10px;background:#f7f5ef;color:#242d25;font-size:23px;line-height:1}
.app.pos-mode .qty span{display:inline-flex;align-items:center;justify-content:center;min-width:42px;min-height:44px;padding:0 4px;font-size:18px;font-weight:850;line-height:1;font-variant-numeric:tabular-nums}
.app.pos-mode .rm{min-width:52px;min-height:44px;padding:6px;border:1px solid #efdbd6;border-radius:10px;background:#fff9f8;color:#a34439;font-size:13px;font-weight:800;line-height:1.2}
.app.pos-mode .promo-qty-locked{min-height:44px;line-height:1}
.app.pos-mode .pos-cart-table .empty td{height:auto;padding:46px 15px;border-bottom:0;text-align:center;color:#656c64;font-size:17px;font-weight:600;line-height:1.6}
.app.pos-mode .pos-cart-table tbody tr.empty,.app.pos-mode .pos-cart-table tbody tr.empty:hover{background:transparent}
/* نافذة بحث الفواتير: أعرض، المصدر ظاهر في الصف، وزر «عرض» ثابت لا يختفي مهما ضاق العرض */
#posInvModal .modal-card{width:min(1120px,96vw);max-width:none}
#posInvModal .products-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
#posInvModal .products-head input{flex:1 1 150px;min-height:46px}
#posInvModal .table-scroll{max-height:min(58vh,560px)}
#posInvModal table{min-width:760px}
#posInvModal th,#posInvModal td{padding:8px 10px;white-space:nowrap;vertical-align:middle}
#posInvModal td:nth-child(3){min-width:120px;white-space:normal}
#posInvModal .pi-total{font-weight:850;font-variant-numeric:tabular-nums}
#posInvModal th:last-child,#posInvModal .pi-act{position:sticky;inset-inline-end:0;width:98px;text-align:center;background:#fff}
#posInvModal th:last-child{z-index:3;background:#edf4f3}
#posInvModal .pi-act{z-index:2;box-shadow:8px 0 10px -10px #0005}
#posInvModal .pi-view{min-width:78px;min-height:44px;padding:6px 14px;border:0;border-radius:10px;background:#323c32;color:#fff;font-size:15px;font-weight:800}
#posInvModal tr.ret td{color:#8a4b3c}
/* نافذة الفاتورة: الإجراءات الثلاثة ظاهرة دائمًا؛ الزر المقفل = ينقصه صلاحية ويوضّح ذلك عند الضغط */
#invModal .modal-actions .locked{border:1px dashed #b9b9b0;background:#f3f2ee;color:#6a6f69}
#invModal .inv-return-preview{min-height:0;margin:8px 0 2px;font-size:16px;font-weight:700;color:#2f3630}
#invModal .inv-return-preview:empty{display:none}
#invModal .inv-return-preview b{font-size:20px;color:#1f6a3a}
/* ملخص البيع بعد إتمام أي عملية: يظهر مكان السلة الفارغة داخل نفس الشاشة (بلا نافذة ولا تبويب)، ويختفي تلقائيًا مع أول صنف جديد */
.app.pos-mode .sale-summary{grid-area:cart;z-index:6;display:grid;place-items:center;align-items:safe center;min-height:0;margin:8px 0 0;padding:14px;border:1px solid #dfe6d8;border-radius:12px;background:#f5f8f1;overflow:auto}
.app.pos-mode .sale-summary[hidden]{display:none}
/* البطاقة: شريط علوي أخضر (تم البيع + رقم الفاتورة)، ثم الإجمالي والباقي كبلاطتين بارزتين، ثم تفاصيل الدفع، ثم «طباعة / تم» */
.ss-card{width:min(100%,620px);overflow:hidden;border:1px solid #d5dfd0;border-radius:20px;background:#fff;box-shadow:0 20px 48px #1f3a281f,0 2px 6px #1f3a2812;animation:ssPop .2s ease-out}
@keyframes ssPop{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
.ss-head{display:flex;align-items:center;gap:14px;padding:15px 22px;background:linear-gradient(135deg,#1f4a31,#2b6a43);color:#fff}
.ss-ok{display:grid;place-items:center;flex:none;width:48px;height:48px;border-radius:50%;background:#f7e4ab;color:#1f4a31;font-size:25px;font-weight:900;box-shadow:0 0 0 5px #ffffff26}
.ss-title{min-width:0}
.ss-title strong{display:block;font-size:22px;font-weight:900;line-height:1.25}
.ss-title span{display:block;color:#d3e6d6;font-size:13.5px;font-weight:700}
.ss-inv{display:flex;flex-direction:column;align-items:flex-end;gap:4px;margin-inline-start:auto;white-space:nowrap}
.ss-inv strong{color:#f7e4ab;font-size:20px;font-weight:900;line-height:1.2;font-variant-numeric:tabular-nums}
.ss-inv span{padding:2px 11px;border-radius:999px;background:#ffffff24;color:#fff;font-size:12.5px;font-weight:800}
.ss-tiles{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:18px 22px 4px}
.ss-tiles.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.ss-tile{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;padding:13px 12px 15px;border-radius:16px;text-align:center}
.ss-tile>span{font-size:15px;font-weight:800}
.ss-tile b{display:flex;align-items:baseline;justify-content:center;gap:7px;font-size:clamp(38px,3vw,54px);font-weight:900;line-height:1.05;letter-spacing:-.02em;white-space:nowrap;font-variant-numeric:tabular-nums}
.ss-tile b small{font-size:.4em;font-weight:800;letter-spacing:0;opacity:1}
.ss-total{background:#29322b;box-shadow:inset 0 0 0 1px #3c463d}
.ss-total>span{color:#c9d0c6}
.ss-total b{color:#f7e4ab}
.ss-change{border:2px solid #a9d6ad;background:#edf8ec}
.ss-change>span{color:#2f6b3d}
.ss-change b{color:#1a6435}
.ss-rows{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:26px;margin:0;padding:8px 22px 2px}
.ss-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;min-height:46px;padding:6px 2px;border-bottom:1px dashed #e2e7de}
.ss-row:last-child:nth-child(odd){grid-column:1/-1}
.ss-row dt{flex:none;color:#5d665e;font-size:14.5px;font-weight:700}
.ss-row dd{min-width:0;margin:0;color:#262b2b;font-size:17px;font-weight:850;text-align:end;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
.ss-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 13px;border:1px solid #e0d6b8;border-radius:999px;background:#f8f3e3;color:#3a3520;font-size:16px;font-weight:850;white-space:nowrap}
.ss-card[data-method="cash"] .ss-chip{border-color:#bfe0c2;background:#eef8ee;color:#1f5a33}
.ss-card[data-method="card"] .ss-chip{border-color:#c2d6e6;background:#eef5fb;color:#274d6b}
.ss-card[data-method="cliq"] .ss-chip,.ss-card[data-method="qr"] .ss-chip{border-color:#d3c9e6;background:#f4f0fa;color:#4d3d6c}
.ss-card[data-method="debt"] .ss-chip{border-color:#e6d2a8;background:#fbf3e1;color:#7a5413}
.ss-actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);gap:12px;padding:16px 22px 8px}
.ss-actions button{display:flex;align-items:center;justify-content:center;gap:10px;min-width:0;min-height:58px;padding:6px 12px;border:1.5px solid #cfc8b6;border-radius:14px;background:#fff;color:#2f3630;font-size:18px;font-weight:850;box-shadow:0 2px 0 #e2dccd;touch-action:manipulation}
.ss-actions button:active{box-shadow:none;transform:translateY(2px)}
.ss-actions button small{display:inline-flex;align-items:center;justify-content:center;min-width:34px;height:22px;padding:0 8px;border:1px solid #cfc8b6;border-radius:6px;background:#f7f3e9;color:#5e594c;font-size:12px;font-weight:800;line-height:1}
.ss-actions .ss-done{border-color:#257344;background:#257344;color:#fff;box-shadow:0 2px 0 #1a5732}
.ss-actions .ss-done small{border-color:#ffffff66;background:#ffffff24;color:#fff}
.ss-hint{margin:0;padding:2px 22px 15px;color:#7a8279;font-size:13px;font-weight:700;text-align:center}
@media(prefers-reduced-motion:reduce){.ss-card{animation:none}}
/* شاشة منخفضة الارتفاع: البطاقة تصير أفقية (البلاطتان يمينًا والتفاصيل يسارًا) حتى تظهر كاملة مع زرّيها دون تمرير */
@media(max-height:820px) and (min-width:861px){
  .app.pos-mode .sale-summary{padding:8px}
  .ss-card{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);width:min(100%,900px);border-radius:16px}
  .ss-head{grid-column:1/-1;gap:11px;padding:8px 18px}
  .ss-ok{width:36px;height:36px;font-size:19px;box-shadow:0 0 0 4px #ffffff26}
  .ss-title strong{font-size:18px}
  .ss-title span{font-size:12.5px}
  .ss-inv strong{font-size:17px}
  .ss-tiles{align-content:center;gap:9px;padding:10px 16px 4px}
  .ss-tile{padding:8px 8px 10px;border-radius:13px}
  .ss-tile>span{font-size:13.5px}
  .ss-tile b{font-size:clamp(30px,2.8vw,40px)}
  .ss-rows{grid-template-columns:minmax(0,1fr);align-content:center;padding-block:6px 0;padding-inline:6px 16px}
  .ss-row{min-height:34px;padding:3px 2px}
  .ss-row dt{font-size:13.5px}
  .ss-row dd{font-size:15.5px}
  .ss-chip{padding:2px 11px;font-size:14.5px}
  .ss-actions{grid-column:1/-1;gap:10px;padding:9px 16px 11px}
  .ss-actions button{min-height:48px;font-size:17px}
  .ss-hint{display:none}
}
@media(max-width:520px){
  .ss-head{padding:12px 14px}
  .ss-tiles{padding:12px 14px 2px}
  .ss-tile b{font-size:32px}
  .ss-rows{grid-template-columns:minmax(0,1fr);padding:6px 14px 0}
  .ss-actions{padding:12px 14px 8px}
}
@keyframes posRowFlash{from{background:#ffeeb8}to{background:transparent}}
.app.pos-mode .pos-cart-table tbody tr.just-added td{animation:posRowFlash 1.2s ease-out}

/* ملخص الفاتورة: الباقي (يمين) · الإجمالي (الوسط، الأبرز) · المبلغ المستلم (يسار) */
.app.pos-mode .pos-summary{display:grid;flex:none;grid-template-columns:minmax(150px,1fr) minmax(0,1.5fr) minmax(150px,1fr);grid-template-areas:"change total received";align-items:stretch;gap:10px;min-width:0}
.app.pos-mode .pay-total{grid-area:total;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;column-gap:16px;row-gap:2px;min-height:86px;margin:0;padding:8px 18px;border-radius:14px;background:#29322b;color:#fff;text-align:center;box-shadow:inset 0 0 0 1px #3c463d,0 6px 18px #1d241f24}
.app.pos-mode .pay-total>span{color:#c9d0c6;font-size:16px;font-weight:700}
.app.pos-mode .pay-total>div:not(.discount-row){display:flex;align-items:baseline;gap:7px;justify-content:center}
.app.pos-mode .pay-total b{font-size:clamp(40px,3.5vw,60px);line-height:1;color:#f7e4ab;letter-spacing:-.02em;font-weight:900;font-variant-numeric:tabular-nums}
.app.pos-mode .pay-total small{font-size:19px;font-weight:800;color:#e3d6ad}
.app.pos-mode .discount-toggle{min-width:64px;min-height:44px;padding:6px 14px;border:1px solid #57625a;border-radius:10px;background:transparent;color:#d6ddd2;font-size:14px;font-weight:700;text-decoration:none}
.app.pos-mode .discount-row{display:flex;align-items:center;justify-content:center;gap:5px}
.app.pos-mode .discount-row.hidden{display:none}
.app.pos-mode .discount-row input{width:66px;min-width:0;min-height:44px;padding:4px 5px;border:1px solid #d9d3c6;border-radius:9px;background:#fff;color:#252b26;font-size:18px;font-weight:800;text-align:center}
.app.pos-mode .discount-row span{color:#c9d0c6;font-size:13px;font-weight:700}
.app.pos-mode .discount-row #discountAmount{color:#f7e4ab}
.app.pos-mode .pay-received{grid-area:received;display:flex;align-items:stretch;min-width:0}
.app.pos-mode .pay-received label{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:100%;margin:0;padding:6px 10px;border:1px solid #e3ddcf;border-radius:14px;background:#fbfaf6;text-align:center;font-size:13px;font-weight:700;color:#666d65}
.app.pos-mode .pay-received input{width:min(100%,340px);min-width:0;min-height:46px;padding:3px 8px;border:2px solid #d3c18e;border-radius:10px;background:#fff;direction:ltr;text-align:center;font-size:clamp(22px,2vw,30px);font-weight:850;font-variant-numeric:tabular-nums}
.app.pos-mode .pay-received input:focus{border-color:#a57825;outline:3px solid #a578252e}
.app.pos-mode .pay-change{grid-area:change;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px;min-width:0;margin:0;padding:6px 10px;border:1px solid #cfe1ce;border-radius:14px;background:#f2faf1;text-align:center;font-size:13px;font-weight:700;color:#55705a}
.app.pos-mode .pay-change b{font-size:clamp(26px,2.3vw,36px);line-height:1.1;color:#1f6a3a;white-space:nowrap;font-variant-numeric:tabular-nums}

/* أزرار الوظائف: كبيرة وواضحة بعرض الشاشة (بحث فاتورة / تعليق / المعلّقة / استلام / طباعة / الدرج / إلغاء) */
.app.pos-mode .pos-funcs{display:grid;flex:none;grid-template-columns:repeat(auto-fit,minmax(136px,1fr));gap:8px}
/* كل زر سطران مرتبان: الاسم فوق، وتحته الاختصار (F5…) و/أو العدّاد كشارة واضحة */
.app.pos-mode .pos-funcs button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-width:0;min-height:62px;padding:6px 10px;border:1px solid #d9d3c4;border-radius:12px;background:#fff;color:#2f3630;font-size:15.5px;font-weight:800;line-height:1.2;white-space:nowrap;box-shadow:0 2px 0 #e2dccd;touch-action:manipulation}
.app.pos-mode .pos-funcs button:active{background:#f3efe5;box-shadow:none;transform:translateY(2px)}
.app.pos-mode .pos-funcs .fn-clear{border-color:#e6bdb7;background:#fff5f3;color:#a34237;box-shadow:0 2px 0 #ecd2cd}
.app.pos-mode .pos-funcs .fn-meta{display:flex;align-items:center;justify-content:center;gap:6px}
.app.pos-mode .pos-funcs small{display:inline-flex;align-items:center;justify-content:center;min-width:34px;height:22px;margin:0;padding:0 8px;border:1px solid #cfc8b6;border-radius:6px;background:#f7f3e9;color:#5e594c;font-size:12px;font-weight:800;line-height:1;opacity:1}
.app.pos-mode .pos-funcs .fn-clear small{border-color:#e6bdb7;background:#fff;color:#a34237}
.app.pos-mode .pos-funcs .fn-count{display:inline-flex;align-items:center;justify-content:center;min-width:38px;height:22px;padding:0 10px;border:1px solid #bfb38d;border-radius:999px;background:#e6dcbd;color:#1f2620;font-size:14.5px;font-weight:900;line-height:1;font-variant-numeric:tabular-nums}
/* عدّاد الاستلام: يوجد طلب مفتوح = شارة ذهبية واضحة؛ طلب جديد لم يُطّلع عليه = شارة داكنة أقوى */
.app.pos-mode #posPickupBtn.has-open .fn-count{border-color:#b08a2e;background:#f3d98a;color:#3a2a05}
.app.pos-mode #posPickupBtn.has-new .fn-count{border-color:#ac7924;background:#ac7924;color:#fff}

/* العمود الجانبي: لوحة أرقام بترتيب الآلة الحاسبة (من اليسار لليمين) وتحتها مباشرة أزرار الدفع */
.app.pos-mode .pos-pay{grid-area:side;order:0;position:relative;top:auto;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1.7fr) minmax(0,1fr);gap:12px;min-width:0;min-height:0;width:100%;max-width:none;margin:0;padding:12px;border:1px solid #e0d9ca;border-radius:16px;background:#fff;box-shadow:0 4px 20px #37302512}
.app.pos-mode .pos-pay .keypad{direction:ltr;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(4,minmax(46px,1fr)) minmax(42px,.7fr);gap:8px;min-width:0;min-height:0;margin:0;padding:0}
.app.pos-mode .pos-pay .keypad button{min-width:0;padding:0;border:1px solid #e3ded3;border-radius:13px;background:#f8f6f1;color:#273029;font-size:clamp(21px,1.65vw,30px);font-weight:800;line-height:1;font-variant-numeric:tabular-nums;box-shadow:0 2px 0 #ddd7ca;touch-action:manipulation}
.app.pos-mode .pos-pay .keypad button:active{background:#ebe6d9;box-shadow:none;transform:translateY(2px)}
.app.pos-mode .pos-pay .keypad .kback{background:#f1eee6;color:#5d5546}
.app.pos-mode .pos-pay .keypad .kclear{grid-column:1/-1;border-color:#ecd2cd;background:#fff6f4;color:#a34237;font-size:16px;box-shadow:0 2px 0 #ecd2cd}
.app.pos-mode .pay-methods{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(52px,1.3fr) minmax(48px,1fr);grid-auto-rows:minmax(46px,.85fr);gap:8px;min-width:0;min-height:0}
.app.pos-mode .pay-methods .pay{min-width:0;min-height:46px;padding:6px 5px;border:1px solid transparent;border-radius:13px;box-shadow:none;color:#fff;font-size:clamp(16px,1.2vw,21px);font-weight:850;line-height:1.2;touch-action:manipulation}
.app.pos-mode .pay-methods .cash{grid-column:1/-1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;background:#257344;font-size:clamp(19px,1.5vw,26px)}
.app.pos-mode .pay-methods .card{background:#315d7e}
.app.pos-mode .pay-methods .qr{background:#61507f}
.app.pos-mode .pay-methods .debt{grid-column:1/-1;background:#9d712b}
.app.pos-mode .pay-methods .pay small{display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:19px;padding:0 7px;border-radius:6px;background:#ffffff2e;font-size:11.5px;font-weight:800;line-height:1;opacity:1}
.app.pos-mode .pay-methods .pay:active{filter:brightness(.93);transform:translateY(1px)}
.app.pos-mode .pay-methods .pay.selected{outline:3px solid #ad812b;outline-offset:2px;box-shadow:0 0 0 5px #f6ead1}
.app.pos-mode .pos-pay .today{display:none!important}
body:has(.app.pos-mode) .royal-order-alert{bottom:auto;top:70px}
@media(prefers-reduced-motion:reduce){.app.pos-mode .pos-cart-table tbody tr.just-added td{animation:none}}

/* شاشة منخفضة الارتفاع (مثل 1366×768 مع شريط المتصفح): نضغط الهوامش لنحافظ على أكبر عدد من صفوف السلة */
@media(max-height:760px){
  .app.pos-mode #posView{padding-top:8px;padding-bottom:8px}
  .app.pos-mode .pos-wrap{gap:8px 10px}
  .app.pos-mode .pos-main{padding:9px}
  .app.pos-mode .pos-bottom{gap:6px}
  .app.pos-mode .pay-total{min-height:68px;padding:5px 14px}
  .app.pos-mode .pay-total b{font-size:clamp(34px,3vw,46px)}
  .app.pos-mode .pay-received input{min-height:40px}
  .app.pos-mode .pos-funcs button{min-height:54px;gap:2px;padding:4px 8px}
  .app.pos-mode .pos-pay{padding:9px;gap:9px}
  .app.pos-mode .pos-pay .keypad,.app.pos-mode .pay-methods{gap:6px}
}
@media(max-width:1180px){
  .app.pos-mode .pos-wrap{grid-template-columns:clamp(236px,24vw,280px) minmax(0,1fr);gap:8px 9px}
  .app.pos-mode .pos-summary{grid-template-columns:minmax(104px,.9fr) minmax(0,1.5fr) minmax(104px,.9fr);gap:7px}
  .app.pos-mode .pos-cart-table td:nth-child(2){display:none}
  .app.pos-mode .pos-cart-table td:nth-child(3){width:152px}
  .app.pos-mode .pos-cart-table td:nth-child(4){width:100px}
  .app.pos-mode .pos-cart-table td:last-child{width:68px}
  .app.pos-mode .pos-cart-table tbody td{padding:4px 7px}
  .app.pos-mode .pos-funcs{grid-template-columns:repeat(auto-fit,minmax(112px,1fr));gap:6px}
  .app.pos-mode .pos-funcs button{padding:6px;font-size:13.5px}
}
/* عرض ضيق (تابلت بالطول / هاتف): عمود واحد — السلة، ثم الملخص والوظائف، ثم لوحة الأرقام وأزرار الدفع جنبًا إلى جنب */
@media(max-width:860px){
  .app.pos-mode .topbar{height:54px;min-height:54px;padding:5px 10px}
  .app.pos-mode .brand{font-size:15px}
  .app.pos-mode .user-box{gap:4px}
  .app.pos-mode #userName{display:none}
  .app.pos-mode .pos-connection{font-size:0;min-width:11px;width:11px;height:11px;overflow:hidden;border-radius:50%;background:#248251}
  .app.pos-mode .pos-connection[data-ready="0"]{background:#b44136}
  .app.pos-mode #shiftBtn,.app.pos-mode #posOrdersShortcut,.app.pos-mode #posMenuBtn{padding:5px 7px;font-size:11px;min-height:37px}
  .app.pos-mode #posView{padding:8px}
  .app.pos-mode .pos-wrap{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto auto;grid-template-areas:"main" "bottom" "side";gap:7px}
  .app.pos-mode .pos-main{padding:9px}
  .app.pos-mode .pos-cart-heading{min-width:84px;min-height:46px;padding:2px 9px}
  .app.pos-mode #scanInput,.app.pos-mode #scanBtn{min-height:46px}
  .app.pos-mode #scanBtn{min-width:66px}
  .app.pos-mode .pos-pay{grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);grid-template-rows:none;gap:8px;padding:8px}
  .app.pos-mode .pos-pay .keypad{grid-template-rows:repeat(4,44px) 40px;gap:5px}
  .app.pos-mode .pos-pay .keypad button{font-size:21px;border-radius:10px}
  .app.pos-mode .pos-pay .keypad .kclear{font-size:14px}
  .app.pos-mode .pay-methods{gap:6px}
  .app.pos-mode .pay-methods .pay{border-radius:10px;font-size:15px}
  .app.pos-mode .pay-methods .cash{font-size:18px}
  .app.pos-mode .pay-total{min-height:62px;padding:5px 9px;column-gap:9px}
  .app.pos-mode .pay-total b{font-size:32px}
  .app.pos-mode .pay-total>span{font-size:13px}
  .app.pos-mode .pay-received input{min-height:40px;font-size:20px}
  .app.pos-mode .pay-change b{font-size:22px}
  .app.pos-mode .pos-cart-table td.cart-product{padding-inline-start:38px}
  .app.pos-mode .cart-product::before{inset-inline-start:7px;width:23px;height:23px;margin-top:-11.5px}
  .app.pos-mode .cart-product strong{font-size:14px}
  .app.pos-mode .cart-line-total{font-size:15px!important}
  .app.pos-mode .pos-funcs{grid-template-columns:repeat(4,minmax(0,1fr))}
  .app.pos-mode .pos-funcs button{min-height:50px;gap:2px;padding:4px 6px;font-size:12.5px;white-space:normal}
  .app.pos-mode .pos-funcs small{display:none}
  .app.pos-mode .pos-funcs .fn-count{height:18px;font-size:12px}
}
@media(max-width:520px){
  .app.pos-mode{height:auto;min-height:100dvh;overflow:auto}
  .app.pos-mode #posView{overflow:visible}
  .app.pos-mode .pos-wrap{display:flex;flex-direction:column}
  .app.pos-mode .pos-main{min-height:48dvh}
  .app.pos-mode .pos-main>.table-scroll{max-height:46dvh}
  .app.pos-mode .pos-bottom{order:2}
  .app.pos-mode .pos-pay{order:3}
  .app.pos-mode .pos-summary{grid-template-columns:minmax(0,.85fr) minmax(0,1.3fr) minmax(0,.85fr);gap:5px}
  .app.pos-mode .pay-total b{font-size:27px}
  .app.pos-mode .pay-total small{font-size:14px}
  .app.pos-mode .pay-received label,.app.pos-mode .pay-change{padding:4px 5px;font-size:11px}
  .app.pos-mode .pay-received input{font-size:17px}
  .app.pos-mode .pay-change b{font-size:19px}
  .app.pos-mode .pos-pay{grid-template-columns:minmax(0,1fr)}
  .app.pos-mode .pos-pay .keypad{grid-template-rows:repeat(4,48px) 42px}
  .app.pos-mode .pay-methods{grid-auto-rows:52px;grid-template-rows:56px 52px}
  .app.pos-mode .pos-cart-table td:nth-child(3){width:104px}
  .app.pos-mode .pos-cart-table td:nth-child(4){width:66px}
  .app.pos-mode .pos-cart-table td:last-child{width:50px}
  .app.pos-mode .pos-cart-table tbody td{padding:4px 3px}
  .app.pos-mode .pos-cart-table td.cart-product{padding-inline-start:5px}
  .app.pos-mode .cart-product::before{display:none}
  .app.pos-mode .qty button{width:32px;min-width:32px}
  .app.pos-mode .qty span{min-width:24px;font-size:16px}
  .app.pos-mode .rm{min-width:44px;padding:2px;font-size:11px}
  .app.pos-mode .pos-funcs{grid-template-columns:repeat(3,minmax(0,1fr))}
}
/* ارتفاع قصير جدًا (هاتف بالعرض): نسمح بتمرير الصفحة بدل قصّ أزرار الدفع */
@media(max-height:470px){
  .app.pos-mode{height:auto;min-height:100dvh;overflow:auto}
  .app.pos-mode .pos-wrap{grid-template-rows:auto auto}
  .app.pos-mode .pos-main{grid-template-rows:auto auto auto auto}
  .app.pos-mode .pos-main>.table-scroll{min-height:170px;max-height:60dvh}
  .app.pos-mode .pos-pay{grid-template-rows:auto auto}
  .app.pos-mode .pos-pay .keypad{grid-template-rows:repeat(4,46px) 42px}
  .app.pos-mode .pay-methods{grid-template-rows:54px 50px;grid-auto-rows:48px}
}

/* Vertical completion summary at every screen height: invoice, total, paid, change. */
.app.pos-mode .ss-card{display:flex;flex-direction:column;width:min(100%,460px);flex-shrink:0;}
.app.pos-mode .ss-head{flex-direction:column;gap:5px;padding:12px;text-align:center;}
.app.pos-mode .ss-ok{display:none;}
.app.pos-mode .ss-inv{margin:0;text-align:center;}
.app.pos-mode .ss-inv strong{font-size:23px;}
.app.pos-mode .ss-title span{display:none;}
.app.pos-mode .ss-tiles,.app.pos-mode .ss-tiles.two{display:grid;grid-template-columns:1fr;gap:7px;padding:12px 16px 4px;}
.app.pos-mode .ss-tile{padding:8px;}
.app.pos-mode .ss-tile b{font-size:36px;}
.app.pos-mode .ss-change b{font-size:48px;}
.app.pos-mode .ss-paid{background:#f1f4f8;color:#25354a;}
.app.pos-mode .ss-rows{grid-template-columns:1fr;padding:0 16px;}
.app.pos-mode .ss-row{min-height:30px;}
.app.pos-mode .ss-actions{padding:10px 16px;}
.app.pos-mode .ss-actions button{min-height:48px;}

/* Keep completion actions in the outer frame, never inside the scrolling details. */
.app.pos-mode .sale-summary{overflow:hidden;align-items:stretch;padding:6px;}
.app.pos-mode .ss-card{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;align-self:stretch;justify-self:center;min-height:0;height:100%;max-height:100%;width:min(100%,430px);border-radius:14px;}
.app.pos-mode .ss-content{min-height:0;overflow:auto;overscroll-behavior:contain;}
.app.pos-mode .ss-head{padding:6px 12px;gap:2px;}
.app.pos-mode .ss-title strong{font-size:15px;}
.app.pos-mode .ss-inv strong{font-size:20px;}
.app.pos-mode .ss-inv>span{display:none;}
.app.pos-mode .ss-tiles,.app.pos-mode .ss-tiles.two{gap:4px;padding:6px 10px;}
.app.pos-mode .ss-tile{padding:4px;gap:1px;border-radius:9px;}
.app.pos-mode .ss-tile>span{font-size:12px;}
.app.pos-mode .ss-tile b{font-size:27px;}
.app.pos-mode .ss-change b{font-size:34px;}
.app.pos-mode .ss-details{margin:0 12px 5px;font-size:12px;}
.app.pos-mode .ss-details>summary{cursor:pointer;padding:3px;color:#4b5a4e;}
.app.pos-mode .ss-actions{grid-column:1;grid-row:2;background:#fff;border-top:1px solid #d5dfd0;padding:6px 10px;margin:0;gap:8px;}
.app.pos-mode .ss-actions button{min-height:46px;font-size:17px;}
.app.pos-mode .ss-hint{display:none;}

.app.pos-mode .ss-content .ss-title{display:none;}
.app.pos-mode .ss-content .ss-tile{flex-direction:row;justify-content:space-between;padding:5px 10px;}
.app.pos-mode .ss-content .ss-tile>span{font-size:14px;}

/* 0.4.41: four distinct methods, same fixed payment area. */
.app.pos-mode .pay-methods{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:52px 52px;grid-auto-rows:44px}
.app.pos-mode .pay-methods .cash{grid-column:auto;font-size:18px}
.app.pos-mode .pay-methods .bank-qr{background:#386a78}

/* 0.4.74 — نافذة الفاتورة / الإرجاع أرتب: سطر معلومات مضغوط، بطاقات أصغر، فاصل فوق الأزرار، ولا شيء تحت الأزرار */
#invModal .modal-card{max-height:calc(100dvh - 24px)}
#invModal #invTitle{margin:0 0 6px;font-size:22px}
#invoiceRelationship{display:flex;flex-wrap:wrap;gap:4px 18px;margin:0 0 4px}
#invoiceRelationship .invoice-source{margin:0;font-size:14px;line-height:1.7;color:#4b5a50}
#invModal .invoice-return-summary{margin:10px 0 14px;gap:10px}
#invModal .invoice-return-summary>div{padding:10px 14px}
#invModal .invoice-return-summary b{font-size:21px;margin-top:4px}
#invModal .prod-table td,#invModal .prod-table th{padding:8px 10px;vertical-align:middle}
#invModal .prod-table td:first-child{white-space:normal;line-height:1.5}
#invModal .prod-table .cell-inp{width:84px;min-height:42px;text-align:center}
#invoiceRelatedOperations{margin-bottom:6px}
#invoiceRelatedOperations h4{margin:14px 0 6px}
#invoiceRelatedOperations>p{margin:0;color:#5b6b60}
#invModal .invoice-related-row{padding:8px 12px;margin:6px 0}
#invModal .modal-card{padding-bottom:0}
#invModal .modal-card>.modal-actions{border-top:1px solid #e3e8e4;box-shadow:none;margin:12px -24px 0;padding:12px 24px 16px;background:#fff}
#invModalError:empty{display:none}
