/* Phone layout in the style of the PEAK mobile app: card lists, 44px tap targets, actions pinned to the bottom edge */
@media (max-width:700px){
  html{-webkit-text-size-adjust:100%}
  input,select,textarea{font-size:16px}
  .btn{min-height:44px;padding:10px 16px}
  .btn.sm{min-height:36px;padding:6px 12px}
  .link{padding:6px 2px}

  .head{gap:8px}
  .head h1{width:100%}
  .head>.btn.pri{flex:1}
  .lhead input{max-width:none!important;width:100%}

  /* status tabs scroll sideways in one row instead of wrapping into three */
  .ptabs{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  .ptabs::-webkit-scrollbar{display:none}
  .ptabs .tab{flex:none;padding:12px 16px}
  .utabs{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}
  .utabs button{flex:none;padding:12px 16px}

  /* document lists become cards: number + amount, customer, date + status */
  table.doclist thead,table.doclist tfoot{display:none}
  table.doclist,table.doclist tbody{display:block}
  table.doclist tr{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:14px 16px;border-bottom:1px solid var(--line)}
  table.doclist td{padding:0!important;border:0!important;background:none!important}
  table.doclist td:nth-child(1),table.doclist td:nth-child(7){display:none}
  table.doclist td:nth-child(2){grid-row:1;grid-column:1;font-weight:600}
  table.doclist td:nth-child(5){grid-row:1;grid-column:2;font-weight:700;font-size:15px}
  table.doclist td:nth-child(3){grid-row:2;grid-column:1/3}
  table.doclist td:nth-child(4){grid-row:3;grid-column:1;color:var(--muted);font-size:12.5px}
  table.doclist td:nth-child(6){grid-row:3;grid-column:2;justify-self:end}
  table.doclist tr.click:active{background:var(--sunk)}
  table.doclist td[colspan]{grid-column:1/3}

  table.list td{padding-block:14px}

  /* line items: compact rows on the phone, numbers are edited in the full-screen item editor (✎ แก้ไข) */
  table.docitems{min-width:0!important;width:100%}
  table.docitems thead{display:none}
  table.docitems,table.docitems tbody{display:block}
  table.docitems tbody tr{display:grid;grid-template-columns:24px minmax(0,1fr) auto;align-items:start;gap:6px 10px;padding:12px 0;border-bottom:1px solid var(--line)}
  table.docitems tbody td{display:none;border:0!important;padding:0!important;background:none!important}
  table.docitems tbody td.rn:first-child{display:block;grid-row:1;grid-column:1;padding-top:10px!important;text-align:left}
  table.docitems tbody td:has(textarea){display:block;grid-row:1;grid-column:2}
  table.docitems tbody td.pv{display:block;grid-row:1;grid-column:3;padding-top:10px!important;font-weight:700}
  table.docitems tbody td.rn:last-child{display:block;grid-row:2;grid-column:2/4;text-align:left}
  table.docitems textarea{min-width:0!important;width:100%}

  /* create/approve bar pinned to the bottom edge like the app */
  .bar{position:fixed;left:0;right:0;bottom:0;z-index:30;border-radius:0;padding:10px 12px calc(10px + env(safe-area-inset-bottom,0px));gap:8px}
  .bar{flex-wrap:wrap}
  .bar>b,.bar>.sp{display:none}
  .bar>.bar-total{flex:1 1 100%;text-align:right;font-size:13px}
  .bar>.btn{flex:1 1 0;min-width:0;white-space:normal;line-height:1.2;padding-inline:8px}
  .page:has(>.bar){padding-bottom:130px}
  .chip{min-height:40px;padding:8px 14px}
  table.docitems .link{display:inline-block;padding:10px 14px;margin-right:6px;border:1px solid var(--line);border-radius:999px;text-decoration:none;white-space:nowrap}

  /* forms: one field per row, labels above */
  .grid>.f,.grid>label.f{grid-column:span 12!important}
  .modal>div{max-height:100%;border-radius:16px 16px 0 0}
  .modal{align-items:flex-end;padding:0}
}

/* งานขาย */
.flist{display:flex;flex-direction:column;gap:6px;font-size:13.5px;max-height:220px;overflow:auto}
.kpi small{display:block;margin-top:4px;font-size:12px}
@media (max-width:700px){
  table.sales-q td:nth-child(8),table.sales-b td:nth-child(8){display:block;grid-row:4;grid-column:1/3}
  table.sales-q td:nth-child(8) .btn,table.sales-b td:nth-child(8) .btn{width:100%;min-height:44px}
  table.sales-q td:nth-child(4),table.sales-b td:nth-child(4){grid-row:3;grid-column:1}
}
