@media screen and (max-width:760px) {
  body { font-family:Arial,sans-serif; }
  .page { padding:10px; }
  .card { padding:12px; margin-bottom:12px; }
  .tabs { padding:8px 8px 0; gap:4px; }
  .tabs button { padding:10px 12px; min-height:44px; }
  .tabs #refreshDataBtn { font-size:12px; padding:8px; }
  .filters { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
  .filters .field { min-width:0; }
  #quoteSearchPage .filters .field { grid-column:1/-1; }
  #pageStone .filters .field:has(#sKeyword) { grid-column:1/-1; }
  .field input,.field select,#qKeyword,#sKeyword,#sCategory,#sThick { width:100%!important; min-width:0!important; font-size:16px!important; min-height:44px; }
  .qgrid { grid-template-columns:1fr 1fr; gap:12px; }
  .qgrid .field:first-child { grid-column:1/-1; }
  .btn { min-height:44px; touch-action:manipulation; }
  input[type=checkbox] { width:22px!important; height:22px; min-height:22px!important; min-width:22px!important; vertical-align:middle; }
  .qty { width:100%; min-height:44px; font-size:16px!important; }
  .table-wrap { max-height:none; overflow:visible; border:0; }
  table.data,#tblStone { display:block; width:100%; min-width:0; }
  table.data thead,table.data colgroup { display:none; }
  table.data tbody { display:block; }
  table.data tbody tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 12px; margin-bottom:12px; border:1px solid #d8e0dc; border-radius:8px; padding:12px; background:white; }
  table.data tbody tr.cb-sub { border-left:3px solid #188038; }
  table.data tbody td { display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:4px; padding:0!important; border:0; text-align:left!important; min-width:0; overflow-wrap:anywhere; white-space:normal!important; }
  table.data td[data-mobile-label]::before { content:attr(data-mobile-label); font-size:11px; color:#5f6368; font-weight:normal; }
  table.data td[colspan] { grid-column:1/-1; }
  #tblProducts td:nth-child(3),#tblCart td:nth-child(2),#tblStone td:nth-child(2) { grid-column:1/-1; font-weight:bold; font-size:15px; }
  #tblProducts td:nth-child(2),#tblCart td:first-child { font-weight:bold; color:#146c2e; }
  #tblProducts td:nth-child(7) { align-self:end; }
  #tblProducts td:nth-child(7) .btn { width:100%; }
  #tblCart td:last-child { grid-column:1/-1; flex-direction:row; justify-content:flex-end; align-items:center; }
  #tblCart td:last-child .btn { min-width:48px; font-size:20px; }
  #tblCart tr.total-row { background:#e6f4ea; }
  #tblCart tr.total-row td { background:transparent; }
  #quoteSearchPage .card>div:has(>#addSelectedBtn) { flex-wrap:wrap; gap:8px!important; position:sticky; bottom:0; background:white; padding:10px 0 max(10px,env(safe-area-inset-bottom)); border-top:1px solid #dadce0; z-index:3; }
  #viewCartBtn { min-height:44px; }
  #selCount { flex-basis:100%; }
  #quotePreviewPage>.card { padding:10px; }
  #quotePreview { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  #quotePreview .qf { min-width:640px; padding:24px; }
  #quotePreview .qf input { min-height:28px; }
  .mobile-preview-hint { display:block; color:#5f6368; font-size:12px; margin:0 0 10px; }
  #exportNameHint,#status,#catStatus,#stoneStatus { overflow-wrap:anywhere; }
  .ac-list .ac-item { padding:12px 10px; }
}
@media screen and (min-width:761px),print { .mobile-preview-hint { display:none; } }

/* Compact stone cards on phones only. */
@media screen and (max-width:760px) {
  #tblStone tbody tr { grid-template-columns:minmax(0,1fr); gap:0; }
  #tblStone tbody td { grid-column:1; padding:7px 0!important; }
  #tblStone tbody td:nth-child(n+3) { flex-direction:row; align-items:center; justify-content:space-between; gap:16px; border-bottom:1px solid #f0f2f1; font-variant-numeric:tabular-nums; }
  #tblStone tbody td:nth-child(n+3)::before { flex:0 0 100px; font-size:13px; }
  #tblStone tbody td:nth-child(2) { padding-bottom:12px!important; }
  #tblStone tbody td:nth-child(3),
  #tblStone tbody td:nth-child(5),
  #tblStone tbody td:nth-child(11),
  #tblStone tbody td:nth-child(12),
  #tblStone tbody td:nth-child(13),
  #tblStone tbody td:nth-child(14),
  #tblStone tbody td:nth-child(15) { display:none; }
}

/* Combine the existing Size, L, W and Sqft values in the last mobile row. */
@media screen and (max-width:760px) {
  #tblStone tbody td:nth-child(5) {
    display:flex; order:100; border-bottom:0; border-top:1px solid #dadce0;
    margin-top:6px; padding-top:10px!important; gap:6px;
    justify-content:flex-start; font-size:0;
  }
  #tblStone tbody td:nth-child(5)::before {
    content:"Size:"; flex:0 0 auto; font-size:13px;
  }
  #tblStone tbody td:nth-child(5)::after {
    content:attr(data-mobile-size); font-size:13px; min-width:0;
  }
}

/* Photo link: only rendered when the photo index has a matching Item No. */
.stone-photo-link { color:#146c2e; font-weight:600; white-space:nowrap; text-decoration:underline; }
@media screen and (max-width:760px) {
 #tblStone tbody td.stone-photo-cell:empty {display:none;}
 #tblStone tbody td.stone-photo-cell {display:flex;order:101;border:0;justify-content:flex-end;padding-top:9px!important;}
 #tblStone tbody td.stone-photo-cell::before {content:none;}
}
