/* Keep the page's original cells and controls, laid out as records on a phone. */
@media screen and (max-width: 640px) {
  .prouz-mobile-table-wrap {
    box-sizing: border-box;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  html body table.prouz-mobile-table:not([hidden]) {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
    table-layout: auto;
    font-variant-numeric: tabular-nums;
  }
  html body table.prouz-mobile-table:not([hidden]) > colgroup,
  html body table.prouz-mobile-table:not([hidden]) > thead:not(.prouz-mobile-head-actions) {
    display: none !important;
  }
  html body table.prouz-mobile-table:not([hidden]) > :is(tbody, thead, tfoot):not([hidden]) {
    display: block;
    min-width: 0 !important;
    width: 100% !important;
  }
  html body table.prouz-mobile-table:not([hidden]) > :is(tbody, tfoot) > tr:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto !important;
    min-width: 0 !important;
    margin: 0 0 7px;
    border: 1px solid #dce7f1;
    border-radius: 10px;
    background: #fff;
  }
  html body table.prouz-mobile-table:not([hidden]) > :is(tbody, tfoot) > tr[hidden] { display: none !important; }
  html body table.prouz-mobile-table:not([hidden]) tr > :is(td, th) {
    box-sizing: border-box;
    position: static !important;
    display: block;
    height: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 6px 8px !important;
    text-align: start !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  html body table.prouz-mobile-table:not([hidden]) tr > :is(td, th)[hidden] { display: none !important; }
  html body table.prouz-mobile-table:not([hidden]) [data-prouz-mobile-wide] { grid-column: 1 / -1; }
  html body table.prouz-mobile-table:not([hidden]) [data-prouz-mobile-label]::before {
    display: block;
    margin-bottom: 3px;
    color: #546e86;
    content: attr(data-prouz-mobile-label);
    font: 600 .73rem/1.25 system-ui, sans-serif;
    white-space: normal;
  }
  html body table.prouz-mobile-table:not([hidden]) :is(td, th) > * {
    box-sizing: border-box;
    min-width: 0 !important;
    max-width: 100%;
  }
  html body table.prouz-mobile-table:not([hidden]) :is(td, th) :is(button, a) {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  html body table.prouz-mobile-table:not([hidden]) :is(td, th) :is(input, select, textarea) {
    box-sizing: border-box;
    min-width: 0 !important;
    max-width: 100%;
  }
  html body table.prouz-mobile-table:not([hidden]) > thead.prouz-mobile-head-actions > tr {
    display: flex !important;
    flex-wrap: wrap;
    height: auto !important;
    gap: 2px 5px;
    margin-bottom: 5px;
  }
  html body table.prouz-mobile-table:not([hidden]) > thead > tr > :is(th, td):not([data-prouz-header-action]) {
    display: none !important;
  }
  html body table.prouz-mobile-table:not([hidden]) > thead > tr > [data-prouz-header-action] {
    flex: 0 1 auto;
    padding: 5px 8px !important;
    border-radius: 6px;
  }

  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) > tbody > tr:not([hidden]) {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) > tbody > tr > td:nth-child(2) { grid-column: span 4; }
  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) > tbody > tr > td:nth-child(3) { grid-column: span 3; }
  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) > tbody > tr > td:nth-child(n+4) {
    padding: 3px 1px !important;
    text-align: center !important;
  }
  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) .employee-name-link { white-space: normal; }
  html body table.month-table.prouz-mobile-table:not([hidden]):not([hidden]) .month-shift-link { min-height: 29px; }

  html body #consumption-matrix.prouz-mobile-table > tbody > tr:not([hidden]) {
    height: auto !important;
    margin-bottom: 6px;
  }
  html body #consumption-matrix.prouz-mobile-table tbody tr[data-grid-row] > * {
    height: auto !important;
    padding-block: 6px !important;
  }
  html body #consumption-matrix.prouz-mobile-table tbody tr[data-grid-row] .grid-material strong {
    white-space: normal;
    overflow: visible;
    line-height: 1.35;
  }
  html body #consumption-matrix.prouz-mobile-table .grid-cell { min-height: 36px; touch-action: manipulation; }
  html body #consumption-matrix.prouz-mobile-table :is(.grid-material-resize, .grid-spacer) { display: none !important; }
  html body .grid-toolbar label:has(> #grid-column-count) { display: none !important; }

  .sheet-compact :is(.sheet-day-tools, .sheet-invoice-heading td > div, .sheet-group-date) {
    flex-wrap: wrap;
    max-width: 100%;
    white-space: normal;
  }
  .sheet-compact :is(.sheet-delivery-grid, .sheet-card-line) > * {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .activity-list { overflow-x: visible; }
  .activity-list .activity-columns { display: none; }
  .activity-list .activity-entry { min-width: 0; }
  .activity-list .activity-entry summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
    padding-block: 10px;
  }
  .activity-list .activity-entry summary > span { white-space: normal; overflow-wrap: anywhere; }

  #grid-workspace.grid-expanded .grid-workspace-bar { flex-wrap: wrap; }
  #grid-workspace.grid-expanded #grid-expanded-filters {
    flex: 1 1 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }
  #grid-workspace.grid-expanded :is(#grid-similar, #grid-fullscreen) {
    max-width: 100%;
    white-space: normal;
  }

  html body .shipping-sheet-content > .sheet-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }
  html body .shipping-sheet-content > .sheet-toolbar > label:first-child { grid-column: 1 / -1 !important; }
  html body .shipping-sheet-content > .sheet-toolbar > :is(label, button, a),
  html body .shipping-sheet-content > .sheet-toolbar input {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
  }

  #shipping-sheet-body.sheet-compact,
  #shipping-sheet-body.sheet-compact > tbody,
  #shipping-sheet-body.sheet-compact > tbody > tr,
  #shipping-sheet-body.sheet-compact > tbody > tr > :is(th, td) {
    display: block !important;
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    height: auto !important;
  }
  #shipping-sheet-body.sheet-compact .sheet-day-tools { position: static; width: auto; }
  #shipping-sheet-body.sheet-compact .sheet-card-title { flex-wrap: wrap; }
  #shipping-sheet-body.sheet-compact .sheet-card-line {
    grid-template-columns: 22px minmax(0, 1fr) 46px 64px;
  }
  #shipping-sheet-body.sheet-compact .sheet-line-actions { flex-wrap: wrap; }
  #shipping-sheet-body.sheet-compact :is(.sheet-card-product strong, .sheet-card-product small, .sheet-pack-info span) {
    white-space: normal !important;
    overflow-wrap: anywhere;
  }


  .production-order-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .production-order :is(.production-order-title h2, .production-order-title p, .production-order-number, .production-order-note, .production-order-metric strong) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .production-order .production-order-note {
    white-space: pre-line;
  }
  .production-order .production-order-actions {
    flex-wrap: wrap;
  }

  #item-card-dialog .production-drawer-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-inline: 10px;
  }
  #item-card-dialog .production-drawer-tabs button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 3px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #item-card-dialog .production-card-grid label,
  #item-card-dialog .production-material-search-wrap {
    min-width: 0;
  }
  #item-card-dialog :is(.production-card-grid, .production-material-search-wrap) :is(input, select, textarea) {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
  }
  #item-card-dialog .production-drawer-actions {
    flex-wrap: wrap;
  }
  #item-card-dialog .production-drawer-actions span:not(:empty) {
    flex-basis: 100%;
    overflow-wrap: anywhere;
  }
  #item-card-dialog .production-drawer-actions button {
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
  }
  #item-card-dialog .production-materials-panel .production-drawer-actions {
    margin-inline: -11px;
    padding-inline: 11px;
  }

  #crm-card .crm-tabs {
    flex-wrap: wrap;
    gap: 0 4px;
    overflow: visible;
  }
  #crm-card .crm-tabs button {
    flex: 0 1 auto;
    max-width: 100%;
    white-space: normal;
  }
  #crm-card #crm-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }

}
