html,body{max-width:100%;overflow-x:hidden}
button,a,input,select{touch-action:manipulation}
body.dialog-open{overflow:hidden;touch-action:none}

@media(max-width:750px){
  header{height:auto;min-height:58px;padding:10px 14px;gap:10px}
  .brand{font-size:16px;min-width:0}
  .brand b{width:34px;height:34px;flex:0 0 34px}
  main{width:100%;margin:14px auto;padding:0 10px 30px}
  .page-head{gap:10px;margin-bottom:14px}
  .page-head h1{font-size:21px;line-height:1.2}
  .page-head p{font-size:13px}
  .actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;gap:8px}
  .actions .btn{text-align:center;white-space:normal;min-height:42px;display:grid;place-items:center;padding:8px}
  .card{border-radius:10px;margin-bottom:12px}
  .card h2{padding:13px 14px}
  .body{padding:14px}
  input,select{min-height:44px;font-size:16px;padding:9px 10px}
  .btn,.delete{min-height:42px;padding:9px 12px}
  .add-grid .btn,.inline .btn,.filter-row .btn,.customer-report-filter .btn,.order-list-filter .btn{width:100%}
  .summary{justify-content:space-between;gap:12px;padding:12px 14px}
  .card-actions{display:grid;grid-template-columns:1fr;padding:12px 14px;position:relative;z-index:2}
  .card-actions .btn{width:100%;pointer-events:auto}
  .table-wrap,.order-lines{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .table-wrap table,.order-lines table{min-width:560px}
  .items-table,.preview-items-table{min-width:0!important;width:100%;table-layout:fixed}
  .items-table th,.items-table td,.preview-items-table th,.preview-items-table td{padding:8px 6px;white-space:normal;overflow-wrap:anywhere}
  .items-table th:nth-child(1),.items-table td:nth-child(1){width:48px;text-align:center}
  .items-table th:nth-child(3),.items-table td:nth-child(3){width:74px}
  .items-table th:nth-child(4),.items-table td:nth-child(4){width:52px;text-align:center}
  .items-table td:nth-child(2),.preview-items-table td:nth-child(2){font-size:12px;line-height:1.3}
  .items-table td input{width:100%;min-width:0;padding:7px 4px;text-align:center}
  .items-table .delete{width:100%;padding:6px 3px;font-size:11px}
  .preview-items-table th:nth-child(1),.preview-items-table td:nth-child(1){width:48px;text-align:center}
  .preview-items-table th:nth-child(3),.preview-items-table td:nth-child(3){width:66px;text-align:center}
  .shipment-totals-panel .filter-row{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .shipment-totals-panel .filter-row label{min-width:0}
  .shipment-totals-panel .filter-row .btn{width:100%}
  .shipment-totals-panel .table-wrap{overflow-x:hidden}
  .shipment-totals-table{min-width:0!important;width:100%;table-layout:fixed;font-size:10px}
  .shipment-totals-table th,.shipment-totals-table td{padding:7px 3px;white-space:normal;overflow-wrap:anywhere;line-height:1.25}
  .shipment-totals-table th:nth-child(1),.shipment-totals-table td:nth-child(1){width:34px;text-align:center}
  .shipment-totals-table th:nth-child(2),.shipment-totals-table td:nth-child(2){width:72px}
  .shipment-totals-table th:nth-child(4),.shipment-totals-table td:nth-child(4){width:48px;text-align:center}
  .shipment-totals-table th:nth-child(5),.shipment-totals-table td:nth-child(5){width:50px;text-align:center}
  th,td{padding:9px 10px;white-space:nowrap}
  td input{min-height:40px;width:90px}
  .admin-menu{display:flex;flex-direction:row;position:sticky;top:0;z-index:8;gap:7px;margin:0 0 12px;padding:8px;background:#fff;border:1px solid var(--line);border-radius:11px;box-shadow:0 6px 18px #15283e12;overflow-x:auto;overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity}
  .admin-menu::-webkit-scrollbar{display:none}
  .admin-menu button{flex:0 0 auto;scroll-snap-align:start;text-align:center;min-height:40px;padding:8px 13px;border:1px solid #e4eaf1;font-size:12px;line-height:1.25;white-space:nowrap}
  .admin-menu button.active{border-color:var(--blue);box-shadow:0 3px 9px #176de02b}
  .filter-row,.customer-report-filter,.order-list-filter,.order-grid,.edit-order-form{grid-template-columns:1fr!important;gap:10px}
  .filter-stat{min-height:58px}
  .orders-list{padding:0 10px 12px}
  .order-card-head{grid-template-columns:1fr!important;gap:9px;padding:12px}
  .order-card-head>div{min-width:0}
  .order-card-head b,.order-card-head small{overflow-wrap:anywhere}
  .order-toggle{text-align:left;min-height:38px;padding:6px 0}
  .order-manage{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:7px}
  .order-manage .btn,.order-manage .delete{width:100%}
  .user-create{grid-template-columns:1fr!important}
  .user-row{padding:10px}
  .user-title{align-items:flex-start;flex-wrap:wrap}
  .permission-grid{grid-template-columns:1fr!important;gap:10px}
  .permission-grid label{min-height:32px}
  .permission-grid input{min-height:auto}
  .user-actions{display:grid;grid-template-columns:1fr;margin-top:12px}
  .user-actions .btn{width:100%}
  .list-row{gap:8px;align-items:flex-start}
  .list-row span{min-width:0;overflow-wrap:anywhere;padding-top:8px}
  .list-row .btn{flex:0 0 auto}
  .preview-modal,.modal{align-items:flex-start;padding:8px;overflow-y:auto}
  .preview-box,.modal-box,.duplicate-box{width:100%;max-height:none;border-radius:10px;margin:auto 0}
  #previewModal{align-items:center;overflow:hidden;z-index:1000;isolation:isolate;pointer-events:none}
  #previewModal.open{pointer-events:auto}
  #previewModal .preview-box{display:flex;flex-direction:column;width:100%;height:calc(100vh - 16px);height:calc(100dvh - 16px);max-height:calc(100vh - 16px);max-height:calc(100dvh - 16px);margin:0;overflow:hidden;position:relative;z-index:1;pointer-events:auto}
  #previewModal .preview-head,#previewModal .preview-info,#previewModal .preview-total,#previewModal .preview-actions{flex:0 0 auto}
  #previewModal .table-wrap{flex:1 1 auto;min-height:80px;max-height:none;overflow:auto;-webkit-overflow-scrolling:touch;position:relative;z-index:1}
  .preview-head,.modal-head{padding:14px}
  #previewModal .preview-info{grid-template-columns:repeat(2,minmax(0,1fr))!important;padding:10px;gap:7px}
  #previewModal .preview-info div{min-width:0;padding:7px 8px}
  #previewModal .preview-info div:nth-child(2){grid-column:1/-1;grid-row:2}
  #previewModal .preview-info small{font-size:10px;margin-bottom:2px}
  #previewModal .preview-info b{font-size:12px;line-height:1.25;white-space:normal;overflow-wrap:anywhere}
  #previewModal .preview-actions{display:grid!important;grid-template-columns:1fr 1fr;padding:12px 12px calc(16px + env(safe-area-inset-bottom))!important;position:relative!important;z-index:3;background:#fff;border-top:1px solid var(--line);pointer-events:auto}
  #previewModal .preview-actions .btn{width:100%;min-height:48px;position:relative;z-index:4;pointer-events:auto;-webkit-user-select:none;user-select:none}
  .duplicate-box{padding:18px 14px}
  .login-wrap{width:100%!important;max-width:440px!important;margin:30px auto!important;padding:0 12px!important}
  .login-card{width:100%;margin:0}
  #toast{left:10px;right:10px;bottom:10px;text-align:center;z-index:1100;pointer-events:none}
}

@media(max-width:390px){
  .actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .order-manage,.preview-actions{grid-template-columns:1fr!important}
  .page-head h1{font-size:19px}
  .summary{flex-direction:column;gap:4px}
}
