/* Extracted document/detail layout layer from styles-layout.css. Keep this file loaded after styles-layout.css. */

/* Document Database final contract.
   Keep document detail readable in both desktop and mobile preview, even when
   older generic card rules try to squeeze values into narrow columns. */
.cs-document-panel,
.cs-document-head,
.cs-doc-groups,
.cs-doc-group,
.cs-compact-row,
.cs-compact-main,
.cs-mini-details,
.cs-system-facts,
.cs-payment-row-list,
.cs-photo-strip {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.cs-document-summary {
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)) !important;
}

.cs-compact-row {
  grid-template-columns: minmax(174px, .26fr) minmax(0, 1fr) minmax(116px, .16fr) !important;
  overflow: hidden;
}

.cs-compact-main,
.cs-photo-strip {
  overflow: hidden;
}

.cs-mini-details,
.cs-system-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)) !important;
  gap: 7px;
}

.cs-mini-details span,
.cs-system-facts span,
.cs-document-summary span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.cs-mini-details em,
.cs-system-facts em,
.cs-document-summary em {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}

.cs-mini-details b,
.cs-system-facts b,
.cs-document-summary b {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.cs-payment-row-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
}

.cs-payment-row-list article,
.cs-photo-pill {
  min-width: 0;
  max-width: 100%;
}

body.mobile-preview-mode .cs-document-panel {
  padding: 8px;
  overflow: visible;
}

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

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

body.mobile-preview-mode .cs-mini-details,
body.mobile-preview-mode .cs-system-facts,
body.mobile-preview-mode .cs-payment-row-list {
  grid-template-columns: 1fr !important;
  gap: 6px;
}

body.mobile-preview-mode .cs-mini-details span,
body.mobile-preview-mode .cs-system-facts span {
  display: grid;
  grid-template-columns: minmax(82px, .34fr) minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  padding: 7px 8px;
}

body.mobile-preview-mode .cs-mini-details em,
body.mobile-preview-mode .cs-system-facts em {
  font-size: 9px;
  line-height: 1.15;
  white-space: normal;
}

body.mobile-preview-mode .cs-mini-details b,
body.mobile-preview-mode .cs-system-facts b {
  font-size: 12px;
  line-height: 1.2;
  white-space: normal;
}

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

@media (max-width: 340px) {
  body.mobile-preview-mode .cs-document-summary,
  body.mobile-preview-mode .cs-mini-details span,
  body.mobile-preview-mode .cs-system-facts span {
    grid-template-columns: 1fr !important;
  }
}

/* Optional money add-ons: desktop can sit inline, phone width must stack safely. */
@media (max-width: 760px) {
  .customer-payment-service-charge-row {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
  }

  .customer-payment-service-charge-row:not([open]) {
    width: min(280px, 100%) !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .customer-payment-service-charge-row > summary {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 42px !important;
    box-sizing: border-box;
  }

  .customer-payment-service-charge-field,
  .customer-payment-service-charge-field .amount-number-control,
  .customer-payment-service-charge-field .amount-digit-wrap,
  .customer-payment-service-charge-field .amount-digit-row {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .customer-payment-service-charge-field > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

body.mobile-preview-mode .customer-payment-service-charge-row {
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 8px !important;
}

body.mobile-preview-mode .customer-payment-service-charge-row:not([open]) {
  width: min(280px, 100%) !important;
  grid-template-columns: minmax(0, 1fr) !important;
}

body.mobile-preview-mode .customer-payment-service-charge-row > summary {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 42px !important;
  box-sizing: border-box;
}

body.mobile-preview-mode .customer-payment-service-charge-field,
body.mobile-preview-mode .customer-payment-service-charge-field .amount-number-control,
body.mobile-preview-mode .customer-payment-service-charge-field .amount-digit-wrap,
body.mobile-preview-mode .customer-payment-service-charge-field .amount-digit-row {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

body.mobile-preview-mode .customer-payment-service-charge-field > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* P1 policy guard: Document Database multi-select panels must only render while open. */
.cs-multi-filter:not([open]) > div,
.cs-multi-filter:not([open]) > div.cs-multi-panel,
body.mobile-preview-mode .cs-multi-filter:not([open]) > div,
body.mobile-preview-mode .cs-multi-filter:not([open]) > div.cs-multi-panel {
  display: none !important;
}

.cs-multi-filter[open] > div.cs-multi-panel,
body.mobile-preview-mode .cs-multi-filter[open] > div.cs-multi-panel {
  display: grid !important;
}

/* Final shared detail guards: expanded document/task content must wrap, not stretch. */
.btn.small,
.record-bulk-toolbar > summary,
.audit-bulk-select-inline,
.audit-bulk-row .record-bulk-toolbar > summary {
  min-height: 36px;
}

.cs-document-panel,
.cs-document-panel *,
.task-payment-row-detail,
.task-payment-row-detail *,
.existing-customer-payment-preview,
.existing-customer-payment-preview * {
  box-sizing: border-box;
}

.cs-document-panel,
.cs-doc-groups,
.cs-doc-group,
.cs-compact-row,
.cs-compact-main,
.cs-mini-details,
.cs-system-facts,
.cs-payment-row-list,
.cs-photo-strip,
.task-payment-rows,
.task-payment-row-detail {
  min-width: 0;
  max-width: 100%;
}

.cs-document-panel {
  overflow-x: hidden;
}

.cs-compact-main {
  display: grid;
  align-content: start;
  gap: 8px;
}

.cs-compact-main strong,
.cs-compact-main .doc-badge,
.cs-mini-details b,
.cs-system-facts b,
.cs-document-summary b,
.cs-payment-row-list span,
.task-payment-row-detail dd {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

.cs-system-facts,
.cs-mini-details {
  align-content: start;
}

.cs-system-facts span,
.cs-mini-details span,
.cs-document-summary span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.cs-photo-strip {
  overflow: hidden;
}

.cs-photo-strip .cs-photo-pill {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-payment-row-detail dl {
  min-width: 0;
}

@media (max-width: 760px) {
  .btn.small,
  .record-bulk-toolbar > summary,
  .audit-bulk-select-inline,
  .audit-bulk-row .record-bulk-toolbar > summary,
  body.mobile-preview-mode .btn.small,
  body.mobile-preview-mode .record-bulk-toolbar > summary,
  body.mobile-preview-mode .audit-bulk-select-inline,
  body.mobile-preview-mode .audit-bulk-row .record-bulk-toolbar > summary {
    min-height: 44px;
  }

  .audit-bulk-row,
  body.mobile-preview-mode .audit-bulk-row {
    grid-template-columns: minmax(84px, .34fr) minmax(0, 1fr) !important;
  }

  .audit-bulk-select-inline,
  body.mobile-preview-mode .audit-bulk-select-inline {
    justify-content: center;
    padding-inline: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 250, 248, .86);
  }

  .audit-bulk-select-inline span,
  body.mobile-preview-mode .audit-bulk-select-inline span {
    display: inline !important;
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 900;
    color: var(--muted);
  }

  .table-wrap table,
  .compact-table table,
  body.mobile-preview-mode .table-wrap table,
  body.mobile-preview-mode .compact-table table {
    min-width: 0 !important;
  }

  :is(.record-list-card, .deleted-records-card) :is(.table-wrap, .compact-table),
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) :is(.table-wrap, .compact-table) {
    overflow: visible !important;
  }

  :is(.record-list-card, .deleted-records-card) :is(table, thead, tbody, tr, td),
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) :is(table, thead, tbody, tr, td) {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box;
  }

  :is(.record-list-card, .deleted-records-card) thead,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) thead {
    display: none !important;
  }

  :is(.record-list-card, .deleted-records-card) tbody,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tbody {
    display: grid !important;
    gap: 10px;
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row {
    position: relative;
    display: grid !important;
    gap: 8px;
    padding: 12px 10px 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 250, 248, .92);
    box-shadow: 0 8px 20px rgba(78, 37, 48, .055);
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row td,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row td {
    display: grid !important;
    grid-template-columns: minmax(82px, .34fr) minmax(0, 1fr);
    gap: 7px;
    align-items: start;
    padding: 0 !important;
    border: 0 !important;
    line-height: 1.24;
    overflow-wrap: anywhere;
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row td::before,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row td::before {
    content: attr(data-cell);
    min-width: 0;
    color: var(--muted);
    font-size: 9px;
    font-weight: 950;
    line-height: 1.15;
    text-transform: none;
    overflow-wrap: normal;
    word-break: normal;
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex !important;
    justify-content: flex-end;
    width: auto !important;
    padding: 0 !important;
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col::before,
  :is(.record-list-card, .deleted-records-card) tr.summary-row td[data-cell=""]::before,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col::before,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row td[data-cell=""]::before {
    display: none !important;
    content: "";
  }

  :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col + td,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) tr.summary-row .select-col + td {
    padding-right: 38px !important;
  }

  :is(.record-list-card, .deleted-records-card) .details-row,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .details-row {
    display: block !important;
    padding: 0;
    border: 0;
    background: transparent;
  }

  :is(.record-list-card, .deleted-records-card) .details-row.hidden,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .details-row.hidden {
    display: none !important;
  }

  :is(.record-list-card, .deleted-records-card) .details-row td,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .details-row td {
    display: block !important;
    padding: 0 !important;
    border: 0 !important;
  }

  :is(.record-list-card, .deleted-records-card) .details-row td::before,
  body.mobile-preview-mode :is(.record-list-card, .deleted-records-card) .details-row td::before {
    display: none !important;
    content: "";
  }

  .cs-document-panel,
  body.mobile-preview-mode .cs-document-panel {
    padding: 8px;
  }

  .cs-compact-main,
  body.mobile-preview-mode .cs-compact-main {
    grid-template-columns: 1fr;
  }

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

  .cs-system-facts span,
  .cs-mini-details span,
  body.mobile-preview-mode .cs-system-facts span,
  body.mobile-preview-mode .cs-mini-details span {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
    min-height: 0;
    padding: 7px 8px;
  }

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

  .cs-payment-row-list,
  body.mobile-preview-mode .cs-payment-row-list {
    grid-template-columns: 1fr !important;
  }
}

/* Final mobile audit guard: long action/UUID strings must summarize, not explode cards. */
body.mobile-preview-mode .audit-log-meta {
  min-width: 0;
}

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,
body.mobile-preview-mode .audit-log-main > strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden !important;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

@media (max-width: 760px) {
  .audit-log-meta time,
  .audit-log-meta .audit-done-by,
  .audit-log-meta em,
  .audit-log-main > strong {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }
}

/* Final shared mobile contract for current modules and Store Database Phase 1. */
@media (max-width: 760px) {
  table,
  .table-wrap table,
  .compact-table table {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  th,
  td {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .btn.small,
  .record-draft-toast button {
    min-height: 44px;
    padding: 8px 14px;
  }
}

body.mobile-preview-mode table,
body.mobile-preview-mode .table-wrap table,
body.mobile-preview-mode .compact-table table {
  min-width: 0 !important;
  max-width: 100% !important;
}

body.mobile-preview-mode th,
body.mobile-preview-mode td {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

body.mobile-preview-mode .btn.small,
body.mobile-preview-mode .record-draft-toast button {
  min-height: 44px;
  padding: 8px 14px;
}

/* P0 shared mobile layout guard.
   Real phones and desktop mobile-preview both receive body.mobile-layout-mode from app.js.
   Keep mobile containment here so future modules inherit the same behavior. */
body.mobile-layout-mode.has-modal-open {
  position: fixed;
  inset: var(--modal-scroll-y, 0) 0 auto 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: contain;
}

body.mobile-layout-mode .main {
  padding-bottom: calc(126px + env(safe-area-inset-bottom)) !important;
}

body.mobile-layout-mode .main::after {
  content: "";
  display: block;
  height: calc(108px + env(safe-area-inset-bottom));
}

body.mobile-layout-mode .modal-backdrop {
  place-items: start center !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: max(12px, env(safe-area-inset-top)) 10px calc(18px + env(safe-area-inset-bottom)) !important;
}

body.mobile-layout-mode .modal-card {
  width: min(560px, calc(100vw - 20px)) !important;
  max-width: calc(100vw - 20px) !important;
  max-height: calc(100dvh - 24px) !important;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
  border-radius: 22px;
  padding: 14px;
}

@supports (height: 100svh) {
  body.mobile-layout-mode .modal-card {
    max-height: calc(100svh - 24px) !important;
  }
}

body.mobile-layout-mode .modal-actions {
  position: static !important;
  bottom: auto !important;
  z-index: auto !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  width: 100%;
  margin-top: 12px;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.mobile-layout-mode .modal-actions .btn {
  min-height: 50px;
}

body.mobile-layout-mode .task-board,
body.mobile-layout-mode .task-board.task-summary-grid,
body.mobile-layout-mode #taskResults .task-board,
body.mobile-layout-mode #taskResults .task-board.task-summary-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100% !important;
  max-width: 100% !important;
  gap: 12px !important;
  align-items: start;
}

body.mobile-layout-mode .task-board > .task-card,
body.mobile-layout-mode .task-board.task-summary-grid > .task-summary-card,
body.mobile-layout-mode #taskResults .task-card,
body.mobile-layout-mode #taskResults .task-summary-card {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

body.mobile-layout-mode .task-card {
  overflow: hidden;
  padding-bottom: 14px;
}

body.mobile-layout-mode .task-card > div,
body.mobile-layout-mode .task-card h3,
body.mobile-layout-mode .task-card .task-card-head,
body.mobile-layout-mode .task-card .task-summary-list,
body.mobile-layout-mode .task-card .task-view-details,
body.mobile-layout-mode .task-card .task-action-panel {
  min-width: 0;
  max-width: 100%;
}

body.mobile-layout-mode .task-card h3,
body.mobile-layout-mode .task-card .badge,
body.mobile-layout-mode .task-card .status,
body.mobile-layout-mode .task-card .task-summary-list dt,
body.mobile-layout-mode .task-card .task-summary-list dd {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

body.mobile-layout-mode .task-summary-list div {
  grid-template-columns: minmax(104px, .38fr) minmax(0, 1fr);
  align-items: start;
}

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

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

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

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

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

body.mobile-layout-mode .customer-payment-amount-field .amount-digit-row,
body.mobile-layout-mode #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, .92fr)) !important;
  gap: 2px !important;
  min-height: 40px;
  padding: 3px !important;
}

body.mobile-layout-mode .customer-payment-amount-field .amount-lock-window .amount-digit,
body.mobile-layout-mode .customer-payment-amount-field .amount-lock-window .amount-cent-digit,
body.mobile-layout-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-digit,
body.mobile-layout-mode #editRecordForm [data-edit-customer-payment-row] .customer-payment-amount-field .amount-lock-window .amount-cent-digit {
  height: 30px;
  min-height: 30px !important;
  font-size: clamp(13px, 4vw, 16px) !important;
  line-height: 30px;
}

body.mobile-layout-mode .audit-bulk-row {
  grid-template-columns: 58px minmax(0, 1fr) !important;
  gap: 8px !important;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

body.mobile-layout-mode .audit-bulk-select-inline {
  justify-content: center !important;
  width: 58px;
  min-width: 58px;
  min-height: 50px;
  padding: 0 !important;
}

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

body.mobile-layout-mode .audit-bulk-row .record-bulk-toolbar,
body.mobile-layout-mode .audit-bulk-row .record-bulk-toolbar > summary {
  width: 100%;
  min-width: 0;
}

body.mobile-layout-mode .audit-log-list,
body.mobile-layout-mode .record-list-card,
body.mobile-layout-mode .deleted-records-card,
body.mobile-layout-mode .cs-document-panel,
body.mobile-layout-mode .task-section {
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
}

body.mobile-layout-mode .cs-document-panel,
body.mobile-layout-mode .cs-doc-group,
body.mobile-layout-mode .cs-compact-row,
body.mobile-layout-mode .cs-compact-main,
body.mobile-layout-mode .cs-mini-details,
body.mobile-layout-mode .cs-system-facts,
body.mobile-layout-mode .cs-payment-row-list {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

body.mobile-layout-mode .cs-compact-row {
  grid-template-columns: minmax(0, 1fr) !important;
}

body.mobile-layout-mode .cs-mini-details,
body.mobile-layout-mode .cs-system-facts {
  grid-template-columns: minmax(0, 1fr) !important;
}

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

body.mobile-layout-mode .cs-document-summary span {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 9px 10px;
  overflow: hidden;
  line-height: 1.12;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

body.mobile-layout-mode .cs-document-summary b {
  display: block;
  flex: 0 0 auto;
  max-width: 55%;
  font-size: clamp(15px, 4.4vw, 19px);
  line-height: 1.12;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

body.mobile-layout-mode .cs-mini-details span,
body.mobile-layout-mode .cs-system-facts span {
  display: grid;
  grid-template-columns: minmax(84px, .42fr) minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

body.mobile-layout-mode .cs-compact-row .cs-mini-details span,
body.mobile-layout-mode .cs-system-facts span {
  min-height: auto;
}

body.mobile-layout-mode .cs-mini-details b,
body.mobile-layout-mode .cs-system-facts b,
body.mobile-layout-mode .cs-document-summary b,
body.mobile-layout-mode .cs-payment-row-list span {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

body.mobile-layout-mode .cs-document-summary b {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

body.mobile-layout-mode .cs-document-summary span,
body.mobile-layout-mode .cs-document-summary span * {
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
}

body.mobile-layout-mode .cs-compact-row h4,
body.mobile-layout-mode .cs-compact-row .badge,
body.mobile-layout-mode .cs-document-head h3,
body.mobile-layout-mode .audit-log-item,
body.mobile-layout-mode .audit-log-item * {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: normal;
}

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

body.mobile-layout-mode .audit-log-actions .btn {
  width: 100%;
  min-height: 44px;
}

body.mobile-layout-mode .audit-inline-details {
  max-height: 40vh;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

body.mobile-layout-mode .audit-log-item {
  grid-template-columns: minmax(0, 1fr) !important;
  padding: 12px !important;
  gap: 10px !important;
}

body.mobile-layout-mode .audit-log-meta {
  display: grid !important;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
}

body.mobile-layout-mode .audit-log-meta .audit-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-row: 1 / span 3;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  align-self: start;
}

body.mobile-layout-mode .audit-log-meta .audit-select span {
  display: none !important;
}

body.mobile-layout-mode .audit-log-meta time {
  grid-column: 2 / -1;
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-layout-mode .audit-log-meta .audit-done-by,
body.mobile-layout-mode .audit-log-meta em {
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-layout-mode .audit-log-main {
  min-width: 0;
}

body.mobile-layout-mode .audit-log-main strong,
body.mobile-layout-mode .audit-log-main p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.18;
}

body.mobile-layout-mode .audit-detail-summary,
body.mobile-layout-mode .audit-change-grid,
body.mobile-layout-mode .audit-raw-json pre {
  font-size: 13px;
  line-height: 1.25;
}

body.mobile-layout-mode .audit-detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px;
  margin-top: 8px;
}

body.mobile-layout-mode .audit-detail-summary > div {
  min-width: 0;
  padding: 8px 9px;
}

body.mobile-layout-mode .audit-detail-summary > div:nth-child(n + 3) {
  grid-column: 1 / -1;
}

body.mobile-layout-mode .audit-detail-summary span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

body.mobile-layout-mode .audit-change-grid > div {
  grid-template-columns: minmax(82px, .46fr) repeat(2, minmax(0, 1fr)) !important;
  gap: 6px;
}

body.mobile-layout-mode .calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 5px !important;
  width: 100%;
  max-width: 100%;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

body.mobile-layout-mode .calendar .day {
  min-width: 0;
  min-height: 86px;
  padding: 6px 4px;
  overflow: hidden;
}

body.mobile-layout-mode .calendar .day-number {
  font-size: clamp(15px, 4.3vw, 20px);
  line-height: 1.1;
}

body.mobile-layout-mode .calendar .event,
body.mobile-layout-mode .calendar .more-events {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
  font-size: clamp(9px, 2.7vw, 11px);
  padding: 3px 4px;
}

body.mobile-layout-mode .calendar-day-panel,
body.mobile-layout-mode .calendar-event-form {
  margin-inline: 0;
  max-width: 100%;
  overflow: hidden;
}

body.mobile-layout-mode .calendar-day-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

body.mobile-layout-mode .calendar-day-summary h3 {
  overflow-wrap: break-word;
  word-break: normal;
}

body.mobile-layout-mode .calendar-day-counts {
  justify-content: end;
  min-width: 58px;
}

body.mobile-layout-mode .calendar-day-item {
  grid-template-columns: minmax(0, 1fr);
}

body.mobile-layout-mode .calendar-day-item-actions {
  justify-content: stretch;
}

body.mobile-layout-mode .calendar-day-item-actions .btn {
  width: 100%;
}

body.mobile-layout-mode .calendar-head,
body.mobile-layout-mode .cs-document-head {
  min-width: 0;
}

body.mobile-layout-mode .cs-detail-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.mobile-layout-mode .cs-detail-filter .btn {
  width: 100%;
}

body.mobile-layout-mode .cs-document-panel,
body.mobile-layout-mode .calendar-day-panel,
body.mobile-layout-mode .task-section,
body.mobile-layout-mode .audit-log-list {
  scroll-margin-bottom: calc(116px + env(safe-area-inset-bottom));
}

@media (max-width: 430px) {
  body.mobile-layout-mode .modal-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.mobile-layout-mode .task-summary-list div,
  body.mobile-layout-mode .calendar-day-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  body.mobile-layout-mode .cs-detail-filter {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 340px) {
  body.mobile-layout-mode .cs-document-summary {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
