/* Extracted mobile module layer from styles.css. Keep this file loaded after styles-records.css and before styles-contracts.css. */

/* Final shared mobile module grid. New modules should reuse this pattern instead of one-off mobile grids. */
body.mobile-preview-mode .cs-filter-bar,
body.mobile-preview-mode .audit-filter-bar,
body.mobile-preview-mode .record-filter-bar,
body.mobile-preview-mode .task-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px;
  align-items: stretch;
}

body.mobile-preview-mode .cs-filter-bar > input,
body.mobile-preview-mode .audit-filter-bar .field:first-child,
body.mobile-preview-mode .record-filter-search,
body.mobile-preview-mode .task-filters > input,
body.mobile-preview-mode .cs-filter-bar .date-range-control,
body.mobile-preview-mode .record-filter-bar .date-range-control,
body.mobile-preview-mode .task-filters .date-range-control {
  grid-column: 1 / -1;
}

body.mobile-preview-mode .task-filter-branch {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.mobile-preview-mode .task-branch-staff-scope {
  width: auto;
  min-width: 68px;
  padding-inline: 8px;
}

body.mobile-preview-mode .record-filter-reset,
body.mobile-preview-mode .audit-clear-filter,
body.mobile-preview-mode #csResetWindow {
  width: 100%;
  min-width: 0;
}

@media (max-width: 760px) {
  .cs-filter-bar,
  .audit-filter-bar,
  .record-filter-bar,
  .task-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    align-items: stretch;
  }

  .cs-filter-bar > input,
  .audit-filter-bar .field:first-child,
  .record-filter-search,
  .task-filters > input,
  .cs-filter-bar .date-range-control,
  .record-filter-bar .date-range-control,
  .task-filters .date-range-control {
    grid-column: 1 / -1;
  }

  .task-filter-branch {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .task-branch-staff-scope {
    width: auto;
    min-width: 68px;
    padding-inline: 8px;
  }

  .record-filter-reset,
  .audit-clear-filter,
  #csResetWindow {
    width: 100%;
    min-width: 0;
  }

  .customer-payment-row-card,
  #editRecordForm [data-edit-customer-payment-row].customer-payment-row-card {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    padding-inline: 12px;
  }

  .customer-payment-row-card .customer-payment-row-title,
  .customer-payment-row-card .customer-payment-style-stack,
  .customer-payment-row-card .customer-payment-other-style-field,
  .customer-payment-row-card .customer-payment-type-field,
  .customer-payment-row-card .customer-payment-row-card-fields,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-title,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-style-stack,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-other-style-field,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-type-field,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-card-fields {
    grid-column: 1 / -1 !important;
  }

  .customer-payment-row-card .customer-payment-row-title,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-title {
    padding-inline: 2px;
    min-width: 0;
  }

  .customer-payment-row-card .customer-payment-deposit-field:not(.is-hidden),
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-deposit-field:not(.is-hidden) {
    grid-column: 1 !important;
  }

  .customer-payment-row-card .customer-payment-full-field,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-full-field {
    grid-column: 2 !important;
  }

  .customer-payment-row-card .customer-payment-deposit-field.is-hidden + .customer-payment-full-field,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-deposit-field.is-hidden + .customer-payment-full-field {
    grid-column: 1 / -1 !important;
  }

  .customer-payment-row-card .customer-payment-amount-field .amount-digit-row,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-digit-row {
    grid-template-columns: repeat(5, minmax(12px, 1fr)) 4px repeat(2, minmax(12px, 1fr)) !important;
    gap: 2px;
  }

  .customer-payment-row-card .customer-payment-amount-field .amount-lock-window .amount-digit,
  .customer-payment-row-card .customer-payment-amount-field .amount-lock-window .amount-cent-digit,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-digit,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-cent-digit {
    font-size: clamp(12px, 3.4vw, 15px) !important;
  }
}

@media (max-width: 360px) {
  .customer-payment-row-card,
  #editRecordForm [data-edit-customer-payment-row].customer-payment-row-card {
    grid-template-columns: 1fr !important;
  }

  .customer-payment-row-card .customer-payment-deposit-field:not(.is-hidden),
  .customer-payment-row-card .customer-payment-full-field,
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-deposit-field:not(.is-hidden),
  #editRecordForm [data-edit-customer-payment-row] .customer-payment-full-field {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 760px) {
  .audit-bulk-row {
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) !important;
    align-items: center;
    gap: 8px;
  }

  .audit-bulk-select-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding-inline: 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .audit-bulk-select-inline input {
    flex: 0 0 auto;
  }

  .audit-bulk-select-inline span {
    display: none;
  }

  .audit-bulk-row .record-bulk-toolbar {
    width: 100%;
    min-width: 0;
  }

  .audit-bulk-row .record-bulk-toolbar > summary {
    width: 100%;
    justify-content: space-between;
  }
}

body.mobile-preview-mode .audit-bulk-row {
  display: grid !important;
  grid-template-columns: 56px minmax(0, 1fr) !important;
  align-items: center;
  gap: 8px;
}

body.mobile-preview-mode .audit-bulk-select-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding-inline: 8px;
  font-size: 11px;
  white-space: nowrap;
}

body.mobile-preview-mode .audit-bulk-select-inline input {
  flex: 0 0 auto;
}

body.mobile-preview-mode .audit-bulk-select-inline span {
  display: none;
}

body.mobile-preview-mode .audit-bulk-row .record-bulk-toolbar {
  width: 100%;
  min-width: 0;
}

body.mobile-preview-mode .audit-bulk-row .record-bulk-toolbar > summary {
  width: 100%;
  justify-content: space-between;
}

@media (max-width: 360px) {
  .cs-filter-bar,
  .audit-filter-bar,
  .record-filter-bar,
  .task-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Final mobile layout contract: hubs/more/docs use compact 3-column grids, while expandable details stay readable. */
body.mobile-preview-mode .mobile-hub-grid,
body.mobile-preview-mode .mobile-more-module-grid,
body.mobile-preview-mode .cs-heatmap,
body.mobile-preview-mode .cs-document-summary,
body.mobile-preview-mode .cs-amount-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px;
}

body.mobile-preview-mode .mobile-hub-hero p,
body.mobile-preview-mode .mobile-more-head p {
  display: none;
}

body.mobile-preview-mode .mobile-hub-card.is-compact {
  min-height: 92px;
  grid-template-columns: 1fr !important;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 10px 6px;
  text-align: center;
  border-left-width: 0;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 17px;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-copy,
body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-count {
  min-width: 0;
  max-width: 100%;
  justify-self: center;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-copy b {
  display: -webkit-box;
  min-height: 2.35em;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  line-height: 1.15;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-copy small {
  display: none;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-count {
  min-width: 0;
  padding: 4px 6px;
  border-radius: 11px;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-count b {
  font-size: 11px;
}

body.mobile-preview-mode .mobile-hub-card.is-compact .mobile-hub-count small {
  font-size: 7.5px;
}

body.mobile-preview-mode .cs-heatmap-title {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.mobile-preview-mode .cs-heatmap-title p {
  display: none;
}

body.mobile-preview-mode .cs-date-lane {
  min-width: 0;
}

body.mobile-preview-mode .cs-date-lane.has-inline-detail {
  grid-column: 1 / -1;
}

body.mobile-preview-mode .cs-date-head {
  padding: 8px;
}

body.mobile-preview-mode .cs-date-head span,
body.mobile-preview-mode .cs-date-head em,
body.mobile-preview-mode .cs-heat-tile span,
body.mobile-preview-mode .cs-document-summary span,
body.mobile-preview-mode .cs-amount-stats span {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.mobile-preview-mode .cs-date-head span,
body.mobile-preview-mode .cs-date-head em {
  font-size: 10px;
  line-height: 1.15;
}

body.mobile-preview-mode .cs-date-head b,
body.mobile-preview-mode .cs-heat-tile b {
  font-size: 12px;
  line-height: 1.15;
}

body.mobile-preview-mode .cs-heat-cells {
  min-height: 72px;
  gap: 5px;
  padding: 6px;
}

body.mobile-preview-mode .cs-heat-tile {
  padding: 7px 6px;
  border-radius: 11px;
}

body.mobile-preview-mode .cs-heat-inline-detail,
body.mobile-preview-mode .cs-heatmap-detail-outside,
body.mobile-preview-mode .cs-mini-details,
body.mobile-preview-mode .cs-timeline,
body.mobile-preview-mode .cs-record-grid {
  min-width: 0;
  overflow-x: hidden;
}

body.mobile-preview-mode .function-role-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 6px;
}

body.mobile-preview-mode .function-role-pill {
  min-height: 74px;
  padding: 7px 5px;
  text-align: center;
}

body.mobile-preview-mode .function-role-pill b {
  font-size: 11px;
  line-height: 1.15;
}

body.mobile-preview-mode .function-role-pill small {
  font-size: 9px;
  line-height: 1.1;
}

body.mobile-preview-mode .function-role-pill em {
  display: -webkit-box;
  max-height: 2.5em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 8px;
  line-height: 1.2;
}

body.mobile-preview-mode .module-switch-row {
  grid-template-columns: 1fr !important;
}

body.mobile-preview-mode .module-switch-control {
  justify-items: start;
}

body.mobile-preview-mode details.permission-row.permission-card > summary {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 8px;
}

body.mobile-preview-mode details.permission-row.permission-card > summary .permission-module-note {
  grid-column: 1 / -1;
  display: -webkit-box;
  max-height: 2.6em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.mobile-preview-mode .permission-toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

body.mobile-preview-mode .confirm-box {
  max-height: none;
  overflow: visible;
  font-size: 12px;
  line-height: 1.35;
}

body.mobile-preview-mode .confirm-box .submission-photo-preview,
body.mobile-preview-mode .photo-grid,
body.mobile-preview-mode .photo-preview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.mobile-preview-mode .record-list-card .record-action-cell,
body.mobile-preview-mode .deleted-records-card .record-action-cell {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

body.mobile-preview-mode .record-list-card .details-row td,
body.mobile-preview-mode .deleted-records-card .details-row td,
body.mobile-preview-mode .task-card details,
body.mobile-preview-mode .task-payment-rows,
body.mobile-preview-mode .task-payment-row-detail,
body.mobile-preview-mode .task-view-details {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .mobile-hub-grid,
  .mobile-more-module-grid,
  .cs-heatmap,
  .cs-document-summary,
  .cs-amount-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .mobile-hub-hero p,
  .mobile-more-head p {
    display: none;
  }

  .mobile-hub-card.is-compact {
    min-height: 92px;
    grid-template-columns: 1fr !important;
    justify-items: center;
    align-content: start;
    gap: 6px;
    padding: 10px 6px;
    text-align: center;
    border-left-width: 0;
  }

  .mobile-hub-card.is-compact .mobile-hub-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 17px;
  }

  .mobile-hub-card.is-compact .mobile-hub-copy,
  .mobile-hub-card.is-compact .mobile-hub-count {
    min-width: 0;
    max-width: 100%;
    justify-self: center;
  }

  .mobile-hub-card.is-compact .mobile-hub-copy b {
    display: -webkit-box;
    min-height: 2.35em;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 12px;
    line-height: 1.15;
  }

  .mobile-hub-card.is-compact .mobile-hub-copy small {
    display: none;
  }

  .mobile-hub-card.is-compact .mobile-hub-count {
    min-width: 0;
    padding: 4px 6px;
    border-radius: 11px;
  }

  .mobile-hub-card.is-compact .mobile-hub-count b {
    font-size: 11px;
  }

  .mobile-hub-card.is-compact .mobile-hub-count small {
    font-size: 7.5px;
  }

  .cs-heatmap-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .cs-heatmap-title p {
    display: none;
  }

  .cs-date-lane {
    min-width: 0;
  }

  .cs-date-lane.has-inline-detail {
    grid-column: 1 / -1;
  }

  .cs-date-head {
    padding: 8px;
  }

  .cs-date-head span,
  .cs-date-head em,
  .cs-heat-tile span,
  .cs-document-summary span,
  .cs-amount-stats span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .cs-date-head span,
  .cs-date-head em {
    font-size: 10px;
    line-height: 1.15;
  }

  .cs-date-head b,
  .cs-heat-tile b {
    font-size: 12px;
    line-height: 1.15;
  }

  .cs-heat-cells {
    min-height: 72px;
    gap: 5px;
    padding: 6px;
  }

  .cs-heat-tile {
    padding: 7px 6px;
    border-radius: 11px;
  }

  .cs-heat-inline-detail,
  .cs-heatmap-detail-outside,
  .cs-mini-details,
  .cs-timeline,
  .cs-record-grid {
    min-width: 0;
    overflow-x: hidden;
  }

  .function-role-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px;
  }

  .function-role-pill {
    min-height: 74px;
    padding: 7px 5px;
    text-align: center;
  }

  .function-role-pill b {
    font-size: 11px;
    line-height: 1.15;
  }

  .function-role-pill small {
    font-size: 9px;
    line-height: 1.1;
  }

  .function-role-pill em {
    display: -webkit-box;
    max-height: 2.5em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 8px;
    line-height: 1.2;
  }

  .module-switch-row {
    grid-template-columns: 1fr !important;
  }

  .module-switch-control {
    justify-items: start;
  }

  details.permission-row.permission-card > summary {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px;
  }

  details.permission-row.permission-card > summary .permission-module-note {
    grid-column: 1 / -1;
    display: -webkit-box;
    max-height: 2.6em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .permission-toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .confirm-box {
    max-height: none;
    overflow: visible;
    font-size: 12px;
    line-height: 1.35;
  }

  .confirm-box .existing-customer-payment-preview {
    max-width: 100%;
    padding: 8px;
    gap: 7px;
    overflow: visible;
    box-sizing: border-box;
  }

  .confirm-box .existing-customer-payment-preview-head {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 6px;
  }

  .confirm-box .existing-customer-payment-preview-head b,
  .confirm-box .existing-customer-payment-preview-head .btn {
    grid-column: 1 / -1;
  }

  .confirm-box .existing-customer-payment-preview-head span {
    justify-content: center;
    min-width: 0;
    text-align: center;
    white-space: normal;
  }

  .confirm-box .existing-invoice-summary {
    grid-template-columns: 1fr !important;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .confirm-box .existing-invoice-summary div {
    min-width: 0;
    padding: 7px 8px;
  }

  .confirm-box .existing-invoice-summary dd {
    overflow-wrap: break-word;
    word-break: normal;
  }

  .confirm-box .submission-photo-preview,
  .photo-grid,
  .photo-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-list-card .record-action-cell,
  .deleted-records-card .record-action-cell {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .record-list-card .details-row td,
  .deleted-records-card .details-row td,
  .task-card details,
  .task-payment-rows,
  .task-payment-row-detail,
  .task-view-details {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .customer-payment-service-charge-row {
    width: 100%;
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .customer-payment-service-charge-row:not([open]) {
    width: max-content;
  }
}

@media (max-width: 340px) {
  .mobile-hub-grid,
  .mobile-more-module-grid,
  .cs-heatmap,
  .cs-document-summary,
  .cs-amount-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

body.mobile-preview-mode .permission-page-head {
  grid-template-columns: 1fr !important;
  gap: 8px;
}

body.mobile-preview-mode .permission-page-head > div,
body.mobile-preview-mode .permission-page-head p,
body.mobile-preview-mode .permission-head-actions,
body.mobile-preview-mode .permission-role-select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

body.mobile-preview-mode .permission-page-head p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
}

body.mobile-preview-mode .permission-head-actions {
  justify-content: stretch;
}

/* P1 final shared UI contract: compact mobile grids and safe clipped fields. */
body.mobile-preview-mode .function-status-row,
body.mobile-preview-mode .module-switch-row {
  grid-template-columns: 1fr !important;
}

body.mobile-preview-mode .function-role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 6px;
}

body.mobile-preview-mode .function-role-pill,
body.mobile-preview-mode .permission-toggle {
  min-width: 0;
  overflow: hidden;
}

body.mobile-preview-mode .function-role-pill b,
body.mobile-preview-mode .function-role-pill small,
body.mobile-preview-mode .function-role-pill em,
body.mobile-preview-mode .permission-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-preview-mode .permission-toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

body.mobile-preview-mode .customer-payment-row-card,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row].customer-payment-row-card {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  align-items: start;
  padding-inline: 12px;
}

body.mobile-preview-mode .customer-payment-row-card .customer-payment-row-title,
body.mobile-preview-mode .customer-payment-row-card .customer-payment-style-stack,
body.mobile-preview-mode .customer-payment-row-card .customer-payment-other-style-field,
body.mobile-preview-mode .customer-payment-row-card .customer-payment-type-field,
body.mobile-preview-mode .customer-payment-row-card .customer-payment-row-card-fields,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-title,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-style-stack,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-other-style-field,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-type-field,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-card-fields {
  grid-column: 1 / -1 !important;
}

body.mobile-preview-mode .customer-payment-row-card .customer-payment-row-title,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-row-title {
  padding-inline: 2px;
  min-width: 0;
}

body.mobile-preview-mode .customer-payment-row-card .customer-payment-deposit-field:not(.is-hidden),
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-deposit-field:not(.is-hidden) {
  grid-column: 1 !important;
}

body.mobile-preview-mode .customer-payment-row-card .customer-payment-full-field,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-full-field {
  grid-column: 2 !important;
}

body.mobile-preview-mode .customer-payment-row-card .customer-payment-deposit-field.is-hidden + .customer-payment-full-field,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-deposit-field.is-hidden + .customer-payment-full-field {
  grid-column: 1 / -1 !important;
}

body.mobile-preview-mode .customer-payment-amount-field,
body.mobile-preview-mode .customer-payment-amount-field .amount-number-control,
body.mobile-preview-mode .customer-payment-amount-field .amount-digit-wrap,
body.mobile-preview-mode .customer-payment-amount-field .amount-digit-row,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-number-control,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-digit-wrap,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-digit-row {
  min-width: 0;
  max-width: 100%;
}

body.mobile-preview-mode .customer-payment-amount-field .amount-digit-row,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-digit-row {
  grid-template-columns: repeat(5, minmax(9px, 1fr)) 4px repeat(2, minmax(9px, 1fr)) !important;
  gap: 2px;
  padding: 3px;
  overflow: hidden;
}

body.mobile-preview-mode .customer-payment-amount-field .amount-lock-window,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window {
  min-width: 0 !important;
  width: 100% !important;
}

body.mobile-preview-mode .customer-payment-amount-field .amount-lock-window .amount-digit,
body.mobile-preview-mode .customer-payment-amount-field .amount-lock-window .amount-cent-digit,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-digit,
body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-cent-digit {
  width: 100% !important;
  min-width: 0 !important;
  font-size: clamp(11px, 3.15vw, 15px) !important;
}

body.mobile-preview-mode .customer-payment-service-charge-row {
  width: 100%;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
}

body.mobile-preview-mode .customer-payment-service-charge-row:not([open]) {
  width: max-content;
  grid-template-columns: 40px;
}

body.mobile-preview-mode .customer-payment-service-charge-row > summary {
  width: 40px;
  height: 40px;
}

/* Mobile Document Database expanded detail: summaries stay compact, record facts stay readable. */
body.mobile-preview-mode .cs-document-panel {
  padding: 8px;
  border-radius: 16px;
  overflow: visible;
}

body.mobile-preview-mode .cs-document-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

body.mobile-preview-mode .cs-document-head h3 {
  min-width: 0;
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: normal;
  word-break: normal;
}

body.mobile-preview-mode .cs-document-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px;
}

body.mobile-preview-mode .cs-document-summary span,
body.mobile-preview-mode .cs-document-summary b {
  overflow-wrap: normal !important;
  word-break: normal !important;
}

body.mobile-preview-mode .cs-document-summary span {
  padding: 7px 8px;
  border-radius: 12px;
}

body.mobile-preview-mode .cs-doc-group-head {
  padding: 8px;
}

body.mobile-preview-mode .cs-compact-row {
  display: grid;
  grid-template-columns: 1fr !important;
  gap: 8px;
  padding: 8px;
  overflow: visible;
}

body.mobile-preview-mode .cs-compact-main,
body.mobile-preview-mode .cs-mini-details,
body.mobile-preview-mode .cs-photo-strip {
  width: 100%;
  min-width: 0;
}

body.mobile-preview-mode .cs-mini-details {
  grid-template-columns: 1fr !important;
  gap: 6px;
  overflow-x: visible;
}

body.mobile-preview-mode .cs-mini-details span {
  display: grid;
  grid-template-columns: minmax(72px, .38fr) minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  padding: 7px 8px;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

body.mobile-preview-mode .cs-mini-details em,
body.mobile-preview-mode .cs-mini-details b {
  min-width: 0;
  overflow-wrap: normal !important;
  word-break: normal !important;
  white-space: normal;
}

body.mobile-preview-mode .cs-mini-details em {
  font-size: 9px;
  line-height: 1.15;
}

body.mobile-preview-mode .cs-mini-details b {
  font-size: 12px;
  line-height: 1.2;
}

body.mobile-preview-mode .cs-photo-strip {
  justify-content: flex-start;
}

body.mobile-preview-mode .cs-photo-pill {
  max-width: 100%;
}

@media (max-width: 340px) {
  body.mobile-preview-mode .function-role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.mobile-preview-mode .customer-payment-row-card,
  body.mobile-preview-mode #editRecordForm [data-edit-customer-payment-row].customer-payment-row-card {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.mobile-preview-mode .cs-document-summary,
  body.mobile-preview-mode .cs-mini-details span {
    grid-template-columns: 1fr !important;
  }
}

/* P1 mobile module sweep: shared filters, Ordering, Audit, Home, and Confirm preview. */
body.mobile-preview-mode .record-filter-branch,
body.mobile-preview-mode .task-filter-branch {
  grid-template-columns: minmax(0, 1fr) minmax(62px, auto);
}

body.mobile-preview-mode .record-branch-staff-scope,
body.mobile-preview-mode .task-branch-staff-scope {
  min-width: 0;
  width: auto;
  padding-inline: 7px;
  font-size: 10px;
  white-space: normal;
  line-height: 1.1;
}

body.mobile-preview-mode .audit-filter-bar .audit-clear-filter,
body.mobile-preview-mode .record-filter-reset {
  min-width: 0;
  width: 100%;
}

body.mobile-preview-mode .workbench-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
}

body.mobile-preview-mode .workbench-hero h2 {
  font-size: clamp(22px, 7vw, 30px);
  line-height: 1.05;
}

body.mobile-preview-mode .workbench-hero p {
  display: -webkit-box;
  max-height: 3.8em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 13px;
  line-height: 1.28;
}

body.mobile-preview-mode .workbench-date {
  justify-items: start;
  padding: 9px 10px;
  border-radius: 14px;
}

body.mobile-preview-mode .today-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px;
}

body.mobile-preview-mode .today-summary-card {
  min-height: 96px;
  padding: 10px 8px;
  align-content: center;
  justify-items: center;
  text-align: center;
}

body.mobile-preview-mode .today-summary-card span {
  font-size: 18px;
  line-height: 1;
}

body.mobile-preview-mode .today-summary-card b {
  font-size: 24px;
  line-height: 1;
}

body.mobile-preview-mode .today-summary-card em {
  display: -webkit-box;
  max-width: 100%;
  min-height: 2.35em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 11px;
  line-height: 1.15;
  overflow-wrap: normal;
  word-break: normal;
}

body.mobile-preview-mode .dashboard-workspaces {
  grid-template-columns: 1fr !important;
  gap: 10px;
}

body.mobile-preview-mode .workspace-card {
  min-height: 0;
  padding: 13px;
  border-radius: 18px;
}

body.mobile-preview-mode .workspace-card p {
  display: -webkit-box;
  max-height: 3.7em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 13px;
  line-height: 1.25;
}

body.mobile-preview-mode .ordering-hero {
  display: none;
}

body.mobile-preview-mode .ordering-kcode-row,
body.mobile-preview-mode .ordering-detail-ticket {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px;
  padding: 9px;
}

body.mobile-preview-mode .ordering-kcode-field,
body.mobile-preview-mode .ordering-detail-ticket #salesOrderDetailNumberField {
  grid-column: 1 / -1;
}

body.mobile-preview-mode .ordering-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  grid-template-areas:
    "kcode kcode"
    "desc desc"
    "type size"
    "quantity doc" !important;
  gap: 8px;
}

body.mobile-preview-mode .ordering-detail-ticket input,
body.mobile-preview-mode .ordering-detail-ticket select,
body.mobile-preview-mode .ordering-date-box,
body.mobile-preview-mode .ordering-date-box input {
  min-height: 44px;
}

body.mobile-preview-mode .ordering-detail-ticket .invoice-number-control,
body.mobile-preview-mode .ordering-detail-ticket .invoice-digit-row {
  min-height: 46px;
}

body.mobile-preview-mode .ordering-detail-ticket .invoice-lock-window .invoice-digit {
  min-width: 0 !important;
  font-size: clamp(13px, 4.2vw, 18px) !important;
}

body.mobile-preview-mode .ordering-items-list,
body.mobile-preview-mode .ordering-records-list,
body.mobile-preview-mode .ordering-task-item-grid {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body.mobile-preview-mode .ordering-item-summary summary {
  grid-template-columns: 28px minmax(0, 1fr);
}

body.mobile-preview-mode .ordering-item-summary summary > .btn {
  grid-column: 1 / -1;
  width: 100%;
}

body.mobile-preview-mode .audit-log-card > p,
body.mobile-preview-mode .audit-section-helper {
  display: -webkit-box;
  max-height: 2.8em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  line-height: 1.35;
}

body.mobile-preview-mode .audit-log-item {
  grid-template-columns: 1fr !important;
  gap: 8px;
  padding: 10px;
  border-radius: 15px;
}

body.mobile-preview-mode .audit-log-meta {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

body.mobile-preview-mode .audit-log-meta .audit-select {
  grid-column: 2;
  grid-row: 1;
}

body.mobile-preview-mode .audit-log-meta time,
body.mobile-preview-mode .audit-log-meta .audit-done-by,
body.mobile-preview-mode .audit-log-meta em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-preview-mode .audit-log-meta em {
  grid-column: 1 / -1;
}

body.mobile-preview-mode .audit-log-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

body.mobile-preview-mode .audit-log-actions .btn {
  width: 100%;
}

body.mobile-preview-mode .audit-change-grid,
body.mobile-preview-mode .audit-detail-summary,
body.mobile-preview-mode .audit-raw-json pre {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

body.mobile-preview-mode .confirm-box {
  max-height: none;
  padding: 10px;
  border-radius: 15px;
  overflow: visible;
  overflow-wrap: break-word;
}

body.mobile-preview-mode .confirm-box .existing-customer-payment-preview {
  padding: 8px;
  gap: 7px;
  overflow: visible;
}

body.mobile-preview-mode .confirm-box .existing-customer-payment-preview-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

body.mobile-preview-mode .confirm-box .existing-customer-payment-preview-head b,
body.mobile-preview-mode .confirm-box .existing-customer-payment-preview-head .btn {
  grid-column: 1 / -1;
}

body.mobile-preview-mode .confirm-box .existing-customer-payment-preview-head span {
  justify-content: center;
  min-width: 0;
  text-align: center;
  white-space: normal;
}

body.mobile-preview-mode .confirm-box .existing-invoice-summary {
  grid-template-columns: 1fr !important;
  max-width: 100%;
  overflow: visible;
}

body.mobile-preview-mode .confirm-box .existing-invoice-summary div {
  min-width: 0;
  padding: 7px 8px;
}

body.mobile-preview-mode .confirm-box .existing-invoice-summary dd {
  overflow-wrap: break-word;
  word-break: normal;
}

body.mobile-preview-mode .confirm-box .submission-photo-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px;
  margin-top: 8px;
}

body.mobile-preview-mode .confirm-box .photo-preview-card,
body.mobile-preview-mode .confirm-box .photo-thumb {
  min-height: 90px;
}

@media (max-width: 760px) {
  .record-filter-branch,
  .task-filter-branch {
    grid-template-columns: minmax(0, 1fr) minmax(62px, auto);
  }

  .record-branch-staff-scope,
  .task-branch-staff-scope {
    min-width: 0;
    padding-inline: 7px;
    font-size: 10px;
    white-space: normal;
    line-height: 1.1;
  }

  .audit-filter-bar .audit-clear-filter,
  .record-filter-reset {
    width: 100%;
  }

  .workbench-hero {
    padding: 14px;
    border-radius: 20px;
  }

  .workbench-hero p {
    display: -webkit-box;
    max-height: 3.8em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    font-size: 13px;
    line-height: 1.28;
  }

  .today-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .today-summary-card {
    min-height: 96px;
    padding: 10px 8px;
    align-content: center;
    justify-items: center;
    text-align: center;
  }

  .today-summary-card span {
    font-size: 18px;
    line-height: 1;
  }

  .today-summary-card b {
    font-size: 24px;
    line-height: 1;
  }

  .today-summary-card em {
    display: -webkit-box;
    max-width: 100%;
    min-height: 2.35em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 11px;
    line-height: 1.15;
    overflow-wrap: normal;
    word-break: normal;
  }

  .dashboard-workspaces {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .workspace-card {
    min-height: 0;
    padding: 13px;
    border-radius: 18px;
  }

  .ordering-hero {
    display: none;
  }

  .ordering-kcode-row,
  .ordering-detail-ticket {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    padding: 9px;
  }

  .ordering-kcode-field,
  .ordering-detail-ticket #salesOrderDetailNumberField {
    grid-column: 1 / -1;
  }

  .ordering-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "kcode kcode"
      "desc desc"
      "type size"
      "quantity doc" !important;
  }

  .audit-log-item {
    grid-template-columns: 1fr !important;
    gap: 8px;
    padding: 10px;
  }

  .audit-log-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .confirm-box .submission-photo-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
