      background: rgba(17,24,39,.75); backdrop-filter: blur(4px);
      display:flex; align-items:center; justify-content:center;
      animation: fadeIn .2s;
    }
    @keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }
    @keyframes scaleIn{ from{ opacity:0; transform:scale(.92); } to{ opacity:1; transform:scale(1); } }
    .modal-box{
      background:#fff; border-radius: 16px; box-shadow: 0 25px 50px rgba(0,0,0,.25);
      padding:20px; max-width: 480px; width:90%; max-height:85vh; overflow-y:auto; overflow-x:hidden;
      display:flex; flex-direction:column;
    }
    .modal-box:has(.modal-footer){ overflow:hidden; }
    .modal-box.modal-wide{ max-width:820px; padding:18px; }
    .modal-box.modal-full{ max-width:1100px; width:96vw; max-height:94vh; padding:0; overflow:hidden; display:flex; flex-direction:column; }
    .modal-box.modal-full .pf-head{ padding:16px 24px 12px; border-bottom:1px solid var(--border); flex-shrink:0; }
    .modal-box.modal-full .pf-body{ flex:1; overflow-y:auto; padding:16px 24px 24px; }
    .modal-box.modal-full .pf-foot{ padding:12px 24px; border-top:1px solid var(--border); flex-shrink:0; display:flex; gap:8px; flex-wrap:wrap; }
    @media(max-width:700px){
      .modal-box.modal-full{ width:100vw; max-width:100vw; max-height:100vh; border-radius:0; }
      .modal-box.modal-full .pf-body [style*="grid-template-columns"]{ grid-template-columns:1fr !important; }
    }
    .modal-box.modal-full table{ table-layout:auto !important; }
    .modal-box.modal-full .input{ padding:7px 10px; font-size:13px; }
    .modal-box.modal-wide .input{ padding:7px 10px; font-size:13px; }
    .modal-box.modal-wide .small{ font-size:12px; }
    .modal-box h3{ margin:0 0 16px; font-size:18px; }
    .modal-box .small{ font-size:13px; }
    .modal-box .input{ font-size:14px; }
    .modal-box .btn, .modal-box .btn2{ padding:10px 16px; font-size:14px; }
    .modal-scroll{flex:1 1 auto;overflow-y:auto;overflow-x:hidden;min-height:0;-webkit-overflow-scrolling:touch}
    .modal-box table{ width:100% !important; table-layout:fixed !important; min-width:0 !important; }
    .modal-box table td, .modal-box table th{ max-width:none !important; overflow:visible !important; text-overflow:clip !important; }
    .modal-footer{flex-shrink:0;padding-top:14px;border-top:1px solid var(--border);margin-top:14px}


    .print-area{
      display:none;
    }
    @media print{
      body > *:not(.print-area){ display:none !important; }
      .print-area{ display:block !important; }
      .no-print{ display:none !important; }
    }

    /* POS Styles */

    /* POS UX Enhancements */
    .pos-splitter{
      height: 6px;
      cursor: row-resize;
      user-select: none;
      background: transparent;
      position: relative;
      flex-shrink: 0;
    }
    .pos-splitter::before{
      content:"";
      position:absolute;
      left:50%;
      top:2px;
      transform:translateX(-50%);
      width:48px;
      height:2px;
      border-radius:99px;
      background: var(--border);
    }
    .pos-splitter:hover::before{
      background: rgba(16,185,129,.6);
    }
    .pos-compact .pos-product-item{ padding: 8px; border-radius: 10px; margin-bottom: 6px; }
    .pos-compact .pos-product-name{ font-size: 14px; margin-bottom: 2px; }
    .pos-compact .pos-product-price{ font-size: 16px; }
    .pos-compact .pos-product-meta{ gap: 8px; }
    .pos-compact .pos-search{ padding: 12px; }
    .pos-compact .pos-search input{ padding: 12px 14px; font-size: 15px; }
    .pos-compact .pos-cart-item{ padding: 6px 8px; margin-bottom: 4px; }
    .pos-compact .pos-cart-item-name{ font-size: 12px; }
    .pos-compact .pos-cart-item-price{ font-size: 10px; }

    .pos-container{
      display: grid;
      grid-template-columns: 1fr 380px;
      grid-template-rows: 1fr;
      gap: 12px;
      flex: 1;
      min-height: 0;
      height: 100%;
      overflow: hidden;
    }
    @media (max-width: 768px){
      .pos-container{ grid-template-columns: 1fr; overflow: visible !important; min-height: auto; height: auto !important; }
      .pos-products{ overflow: visible !important; max-height: none !important; height: auto !important; }
      .pos-cart{ overflow: visible !important; height: auto !important; }
    }

    /* When POS is active, lock the page — only product list scrolls */
    .main.pos-mode{ overflow:hidden; height:100vh; }
    .main.pos-mode .topbar{ flex-shrink:0; position:relative; }
    .main.pos-mode .content{ flex:1; overflow:hidden; display:flex; flex-direction:column; min-height:0; padding:10px 14px 0 14px; max-width:100%; margin:0; width:100%; }
    @media (max-width: 768px){
      .main.pos-mode{ overflow: auto !important; height: auto !important; }
      .main.pos-mode .content{ overflow: visible !important; display: block !important; }
    }

    .pos-products{
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-width: 0;
      min-height: 0;
      align-self: stretch;
    }
    .pos-products > .card{
      flex-shrink: 0;
    }

    .pos-search{
      padding: 16px;
      background: var(--card);
      border-radius: var(--r);
      box-shadow: var(--shadow);
      border: 1px solid rgba(17,24,39,.04);
      margin-bottom: 12px;
      flex-shrink: 0;
    }

    .pos-search input{
      width: 100%;
      padding: 14px 16px;
      border: 2px solid var(--border);
      border-radius: 12px;
      font-size: 16px;
      outline: none;
      background: #fff;
    }
    .pos-search input:focus{
      border-color: var(--success);
      box-shadow: 0 0 0 4px rgba(16,185,129,.12);
    }

    .pos-products-list{
      flex: 1;
      overflow-y: auto;
      background: var(--card);
      border-radius: var(--r);
      box-shadow: var(--shadow);
      border: 1px solid rgba(17,24,39,.04);
      padding: 12px;
    }

    .pos-product-item{
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px;
      border-radius: 12px;
      border: 1px solid var(--border);
      margin-bottom: 8px;
      cursor: pointer;
      transition: .15s;
      background: #fff;
    }
    .pos-product-item:hover{
      border-color: var(--success);
      background: rgba(16,185,129,.05);
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0,0,0,.08);
    }
    .pos-product-item:active{
      transform: scale(.98);
    }

    .pos-product-info{
      flex: 1;
      min-width: 0;
    }
    .pos-product-name{
      font-weight: 700;
      font-size: 15px;
      margin-bottom: 4px;
    }
    .pos-product-meta{
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
    }
    .pos-product-price{
      font-size: 18px;
      font-weight: 700;
      color: var(--success);
      white-space: nowrap;
    }
    .pos-product-stock{
      padding: 4px 8px;
      border-radius: 6px;
      font-size: 12px;
      font-weight: 700;
    }
    .pos-product-stock.low{
      background: #fef3c7;
      color: #d97706;
    }
    .pos-product-stock.ok{
      background: #d1fae5;
      color: #059669;
    }
    .pos-product-stock.out{
      background: #fee2e2;
      color: #dc2626;
    }

    .pos-cart{
      position: relative;
      display: flex;
      flex-direction: column;
      background: var(--card);
      border-radius: var(--r);
      box-shadow: var(--shadow);
      border: 1px solid rgba(17,24,39,.04);
      overflow: hidden;
      min-height: 0;
      height: 100%;
    }
    .main.pos-mode .pos-cart{
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;
      border-bottom: none;
    }
    .main.pos-mode .pos-products-list{
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;
      border-bottom: none;
    }

    .pos-cart-header{
      padding: 10px 14px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-shrink: 0;
    }

    .pos-cart-items{
      flex: 1;
      overflow-y: auto;
      padding: 8px;
      padding-bottom: 120px; /* Место под абсолютный footer */
      min-height: 0;
    }

    .pos-cart-item{
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 8px 10px;
      border-radius: 8px;
      background: var(--bg);
      margin-bottom: 6px;
    }

    .pos-cart-item-info{
      flex: 1;
      min-width: 0;
    }
    .pos-cart-item-name{
      font-weight: 700;
      font-size: 13px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .pos-cart-item-price{
      font-size: 11px;
      color: var(--muted);
    }

    .pos-cart-qty{
      display: flex;
      align-items: center;
      gap: 2px;
    }
    .pos-cart-qty button{
      width: 26px;
      height: 26px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: #fff;
      cursor: pointer;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: .15s;
    }
    .pos-cart-qty button:hover{
      background: var(--success);
      color: #fff;
      border-color: var(--success);
    }
    .pos-cart-qty span{
      min-width: 24px;
      text-align: center;
      font-weight: 700;
      font-size: 13px;
    }

    .pos-cart-remove{
      width: 26px;
      height: 26px;
      border-radius: 6px;
      border: 1px solid rgba(239,68,68,.3);
      background: #fff;
      color: var(--danger);
      cursor: pointer;
      transition: .15s;
      font-size: 12px;
      flex-shrink: 0;
    }
    .pos-cart-remove:hover{
      background: var(--danger);
      color: #fff;
    }

    .pos-cart-total{
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 5;
      padding: 10px 14px;
      border-top: 2px solid var(--border);
      background: linear-gradient(180deg, #fff, #fbfbff);
    }

    .pos-total-row{
      display: flex;
      justify-content: space-between;
      margin-bottom: 6px;
      font-size: 14px;
    }
    .pos-total-row.main{
      font-size: 20px;
      font-weight: 700;
      color: var(--success);
      margin-bottom: 10px;
    }

    .pos-checkout-btn{
      width: 100%;
      padding: 12px;
      border-radius: 10px;
      border: 0;
      background: var(--success);
      color: #fff;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      transition: .15s;
    }
    .pos-checkout-btn:hover{
      background: #059669;
      transform: translateY(-2px);
      box-shadow: 0 8px 20px rgba(16,185,129,.3);
    }
    .pos-checkout-btn:active{
      transform: scale(.98);
    }
    .pos-checkout-btn:disabled{
      background: var(--muted);
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }

    .pos-empty{
      text-align: center;
      padding: 60px 20px;
      color: var(--muted);
    }
    .pos-empty-icon{
      font-size: 64px;
      margin-bottom: 16px;
      opacity: .5;
    }
  
    /* POS Drawer (Sales History) — Slide-in Panel */
    .pos-drawer-backdrop{
      position: fixed; inset:0; z-index:120;
      background: rgba(17,24,39,.18);
      display:flex; justify-content:flex-end;
      animation: fadeInBackdrop .2s;
    }
    @keyframes fadeInBackdrop{ from{ opacity:0; } to{ opacity:1; } }
    .pos-drawer{
      width: 420px; max-width: 96vw; height: 100%;
      background: #fff;
      box-shadow: -8px 0 32px rgba(0,0,0,.12);
      display:flex; flex-direction:column;
      animation: slideInDrawer .25s cubic-bezier(.16,1,.3,1);
    }
    @keyframes slideInDrawer{ from{ transform: translateX(100%); } to{ transform: translateX(0); } }
    .pos-drawer-header{
      display:flex; align-items:center; justify-content:space-between; gap:10px;
      padding: 14px 16px; border-bottom:1px solid var(--border);
      background: #fafbfc;
    }
    .pos-drawer-header h3{ margin:0; font-size:15px; font-weight:700; }
    .pos-drawer-search{
      padding: 10px 16px; border-bottom:1px solid var(--border); background:#fff;
    }
    .pos-drawer-search input{
      width:100%; padding:8px 12px; border:1px solid var(--border); border-radius:8px;
      font-size:13px; outline:none; background:#fafbfc;
    }
    .pos-drawer-search input:focus{ border-color: var(--success); background:#fff; box-shadow: 0 0 0 3px rgba(16,185,129,.1); }
    .pos-drawer-body{ flex:1; overflow-y:auto; padding:0 8px 8px; }
    .pos-drawer-stats{
      padding:10px 16px; border-bottom:1px solid var(--border); background:#fafbfc;
      display:flex; gap:16px; font-size:12px; color:var(--muted);
    }
    .pos-drawer-stats b{ color:var(--text); font-size:13px; }
    .pos-sale-row{
      border:1px solid transparent;
      border-bottom:1px solid var(--border);
      border-radius: 0;
      padding: 8px 10px;
      margin-bottom: 0;
      cursor:pointer;
      background:#fff;
      transition:.12s;
      display:flex;
      align-items:center;
      gap:10px;
    }
    .pos-sale-row:first-child{ border-radius: 8px 8px 0 0; }
    .pos-sale-row:last-child{ border-radius: 0 0 8px 8px; border-bottom:1px solid var(--border); }
    .pos-sale-row:only-child{ border-radius: 8px; }
    .pos-sale-row:hover{ background: rgba(16,185,129,.04); }
    .pos-sale-row:active{ background: rgba(16,185,129,.08); }
    .pos-sale-row .sr-left{ flex:1; min-width:0; }
    .pos-sale-row .sr-top{ display:flex; align-items:baseline; gap:6px; }
    .pos-sale-row .sr-no{ font-size:11px; color:var(--muted); font-weight:600; }
    .pos-sale-row .sr-items{ font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .pos-sale-row .sr-meta{ font-size:11px; color:var(--muted); margin-top:2px; display:flex; gap:6px; align-items:center; }
    .pos-sale-row .sr-right{ text-align:right; flex:0 0 auto; }
    .pos-sale-row .sr-total{ font-weight:700; font-size:14px; }
    .pos-sale-row .sr-count{ font-size:11px; color:var(--muted); }
    .pos-sale-row .pay-badge{
      font-size:10px;
      padding:1px 6px;
      border-radius:999px;
      border:1px solid var(--border);
      background:#f8fafc;
      white-space:nowrap;
    }
    .pos-sale-row .pay-cash{ border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.06); color:#059669; }
    .pos-sale-row .pay-card{ border-color: rgba(59,130,246,.4); background: rgba(59,130,246,.06); color:#1d4ed8; }
    .pos-sale-row .pay-mixed{ border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.08); color:#d97706; }
    .pos-sale-row .pay-debt{ border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.06); color:#dc2626; }
  
    
    /* Orders Drawer (New Order / Quick Edit) — Slide-in Panel */
    .order-drawer-backdrop{
      position: fixed; inset:0; z-index:130;
      background: rgba(17,24,39,.22);
      display:flex; justify-content:flex-end;
      animation: fadeInBackdrop .2s;
    }
    .order-drawer{
      width: 560px; max-width: 96vw; height: 100%;
      background:#fff;
      box-shadow: -10px 0 36px rgba(0,0,0,.14);
      display:flex; flex-direction:column;
      animation: slideInDrawer .25s cubic-bezier(.16,1,.3,1);
    }
    .order-drawer-header{
      display:flex; align-items:center; justify-content:space-between; gap:10px;
