/* Mobile-first tables, invoices, forms and action controls */
body.sam-material-theme .mt-table-container, body.sam-material-theme .mt-table-wrap, body.sam-material-theme .table-responsive { border:1px solid #dfe7ef; border-radius:12px; background:#fff; overflow-x:auto; -webkit-overflow-scrolling:touch; }
body.sam-material-theme .mt-table { min-width:680px; }
body.sam-material-theme .mt-table th { position:sticky; top:0; z-index:2; background:#f4f8fc; color:#455a64; font-size:11px; font-weight:900; }
body.sam-material-theme .mt-table th, body.sam-material-theme .mt-table td { min-height:42px; padding:10px 11px; border-bottom:1px solid #edf2f7; line-height:1.45; }
body.sam-material-theme .mt-table tbody tr:nth-child(even) { background:#fbfdff; }
body.sam-material-theme .mt-table tbody tr:hover { background:#eef6ff; }
body.sam-material-theme .mt-table td .mt-btn, body.sam-material-theme .mt-table td button { min-height:34px; padding:6px 9px; white-space:nowrap; }
body.sam-material-theme .mt-table .status-pill, body.sam-material-theme .mt-table .badge { white-space:nowrap; }
body.sam-material-theme .sam-print-preview-modal .mt-modal-body, body.sam-material-theme .sam-print-preview-body { background:#eef2f6; }
body.sam-material-theme .sam-a4-invoice, body.sam-material-theme .sam-purchase-invoice-doc, body.sam-material-theme .thermal-receipt { background:#fff; border-radius:8px; box-shadow:0 2px 12px rgba(38,50,56,.08); }
body.sam-material-theme .sam-print-actions-bar { display:flex; gap:8px; flex-wrap:wrap; }
body.sam-material-theme .sam-print-actions-bar button { min-height:42px; }
body.sam-material-theme input[type=checkbox], body.sam-material-theme input[type=radio] { width:18px; height:18px; accent-color:#1976d2; vertical-align:middle; }
body.sam-material-theme .mt-btn { padding:8px 12px; }
body.sam-material-theme .mt-toolbar-right .mt-btn { min-width:96px; }
body.sam-material-theme .mt-input::placeholder, body.sam-material-theme input::placeholder, body.sam-material-theme textarea::placeholder { color:#9aaab4; }
body.sam-material-theme .select2-container, body.sam-material-theme .choices { max-width:100%; }
@media (max-width:640px) {
  body.sam-material-theme .mt-table-container, body.sam-material-theme .mt-table-wrap { overflow:visible; border:0; background:transparent; }
  body.sam-material-theme .mt-table { min-width:0; width:100%; border-collapse:separate; border-spacing:0 10px; background:transparent; }
  body.sam-material-theme .mt-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
  body.sam-material-theme .mt-table tbody, body.sam-material-theme .mt-table tr, body.sam-material-theme .mt-table td { display:block; width:100%; }
  body.sam-material-theme .mt-table tbody tr { margin-bottom:12px; padding:10px 12px; border:1px solid #dfe7ef; border-radius:12px; background:#fff; box-shadow:0 3px 10px rgba(38,50,56,.06); }
  body.sam-material-theme .mt-table tbody tr:hover { background:#fff; }
  body.sam-material-theme .mt-table td { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; min-height:38px; padding:8px 0; border-bottom:1px solid #edf2f7; text-align:left; white-space:normal; overflow-wrap:anywhere; }
  body.sam-material-theme .mt-table td:last-child { border-bottom:0; }
  body.sam-material-theme .mt-table td::before { content:attr(data-label); flex:0 0 38%; color:#607d8b; font-size:11px; font-weight:900; text-align:right; }
  body.sam-material-theme .mt-table td > * { max-width:62%; }
  body.sam-material-theme .mt-table td:has(.mt-btn), body.sam-material-theme .mt-table td:has(button) { align-items:center; flex-wrap:wrap; }
  body.sam-material-theme .mt-table td:has(.mt-btn)::before, body.sam-material-theme .mt-table td:has(button)::before { width:100%; flex-basis:100%; }
  body.sam-material-theme .mt-table td:has(.mt-btn) > *, body.sam-material-theme .mt-table td:has(button) > * { max-width:100%; }
  body.sam-material-theme .mt-table td .mt-btn, body.sam-material-theme .mt-table td button { min-height:40px; flex:1 1 auto; }
  body.sam-material-theme .mt-table td input, body.sam-material-theme .mt-table td select { max-width:62%; min-height:40px; }
  body.sam-material-theme .mt-table-container + .pagination, body.sam-material-theme .mt-table-wrap + .pagination { margin-top:8px; }
  body.sam-material-theme .mt-toolbar-right { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
  body.sam-material-theme .mt-toolbar-right .mt-btn { width:100%; min-width:0; }
  body.sam-material-theme .form-group { margin-bottom:16px; }
  body.sam-material-theme .form-group label { display:block; margin-bottom:6px; font-size:13px; }
  body.sam-material-theme .mt-input, body.sam-material-theme input:not([type=checkbox]):not([type=radio]), body.sam-material-theme select, body.sam-material-theme textarea { min-height:46px; font-size:15px; }
  body.sam-material-theme .mt-modal-footer { display:grid; grid-template-columns:1fr; }
  body.sam-material-theme .mt-modal-footer .mt-btn, body.sam-material-theme .mt-modal-footer button { width:100%; min-height:44px; }
  body.sam-material-theme .sam-print-preview-modal .mt-modal-body { padding:8px !important; overflow:auto; }
  body.sam-material-theme .sam-a4-invoice, body.sam-material-theme .sam-purchase-invoice-doc { min-width:680px; transform-origin:top right; }
  body.sam-material-theme .thermal-receipt { width:100%; min-width:0; }
  body.sam-material-theme .sam-print-actions-bar { display:grid; grid-template-columns:1fr 1fr; }
  body.sam-material-theme .sam-print-actions-bar button { width:100%; }
}
@media print { body.sam-material-theme .mt-table-container, body.sam-material-theme .mt-table-wrap { overflow:visible; border:0; } body.sam-material-theme .mt-table { min-width:0; } }

/* Printed invoices and receipts keep their document layout, not mobile cards. */
@media (max-width:640px) {
  body.sam-material-theme .sam-a4-invoice .mt-table,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table,
  body.sam-material-theme .thermal-receipt .mt-table,
  body.sam-material-theme .sam-print-preview-modal .mt-table {
    display:table; min-width:680px; width:100%; border-collapse:collapse; border-spacing:0; background:#fff;
  }
  body.sam-material-theme .sam-a4-invoice .mt-table thead,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table thead,
  body.sam-material-theme .thermal-receipt .mt-table thead,
  body.sam-material-theme .sam-print-preview-modal .mt-table thead { position:static; width:auto; height:auto; overflow:visible; clip:auto; white-space:normal; }
  body.sam-material-theme .sam-a4-invoice .mt-table tbody,
  body.sam-material-theme .sam-a4-invoice .mt-table tr,
  body.sam-material-theme .sam-a4-invoice .mt-table td,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table tbody,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table tr,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table td,
  body.sam-material-theme .thermal-receipt .mt-table tbody,
  body.sam-material-theme .thermal-receipt .mt-table tr,
  body.sam-material-theme .thermal-receipt .mt-table td,
  body.sam-material-theme .sam-print-preview-modal .mt-table tbody,
  body.sam-material-theme .sam-print-preview-modal .mt-table tr,
  body.sam-material-theme .sam-print-preview-modal .mt-table td { display:table-row; width:auto; }
  body.sam-material-theme .sam-a4-invoice .mt-table td,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table td,
  body.sam-material-theme .thermal-receipt .mt-table td,
  body.sam-material-theme .sam-print-preview-modal .mt-table td { display:table-cell; min-height:0; padding:8px; border-bottom:1px solid #edf2f7; text-align:right; }
  body.sam-material-theme .sam-a4-invoice .mt-table td::before,
  body.sam-material-theme .sam-purchase-invoice-doc .mt-table td::before,
  body.sam-material-theme .thermal-receipt .mt-table td::before,
  body.sam-material-theme .sam-print-preview-modal .mt-table td::before { display:none; content:none; }
}

/* Mobile-friendly transaction modals: invoices, receipts, payments and forms. */
body.sam-material-theme .mt-modal-backdrop .mt-modal { display:flex; flex-direction:column; }
body.sam-material-theme .mt-modal-backdrop .mt-modal-header { flex:0 0 auto; display:flex; align-items:center; justify-content:space-between; gap:10px; }
body.sam-material-theme .mt-modal-backdrop .mt-modal-body { flex:1 1 auto; min-height:0; }
body.sam-material-theme .mt-modal-backdrop .mt-modal-footer { flex:0 0 auto; background:#f8fafc; border-top:1px solid #e3eaf2; }
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-grid,
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .invoice-form-grid,
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .voucher-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-grid > .full,
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .invoice-form-grid > .full,
body.sam-material-theme .mt-modal-backdrop .mt-modal-body .voucher-form-grid > .full { grid-column:1/-1; }
@media (max-width:640px) {
  body.sam-material-theme .mt-modal-backdrop .mt-modal { max-height:calc(100dvh - 16px) !important; height:auto; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-header { position:sticky; top:0; z-index:3; min-height:56px; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body { max-height:none; padding:14px !important; overflow-y:auto; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-footer { position:sticky; bottom:0; z-index:3; padding:10px !important; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-grid,
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .invoice-form-grid,
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .voucher-form-grid { grid-template-columns:1fr; gap:0; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-grid > .full,
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .invoice-form-grid > .full,
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .voucher-form-grid > .full { grid-column:auto; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-group { margin-bottom:15px; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .form-group > label { display:block; margin-bottom:6px; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .mt-table-container { margin-inline:0; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .mt-table { min-width:0; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-body .mt-table tbody tr { box-shadow:none; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-footer { display:flex; flex-direction:column-reverse; }
  body.sam-material-theme .mt-modal-backdrop .mt-modal-footer > *, body.sam-material-theme .mt-modal-backdrop .mt-modal-footer .mt-btn { width:100%; min-height:46px; }
}
