/* Mobile content must size to text, not let long values escape neighbouring cells. */
@media screen and (max-width: 767px) {
  :where(.ui-page:not(.salary-page), .dash-page) { min-width: 0; max-width: 100%; }
  :where(.ui-page:not(.salary-page), .dash-page) :is(h1,h2,h3,p) { min-width: 0; overflow-wrap: anywhere; }

  /* All summary values remain complete, including non-breaking currency groups. */
  .stats-summary .stat-box, .stats-summary .stat-copy,
  .stats-secondary-grid .stats-metric, .dash-month-summary > *,
  .emp-mini-finance > *, #mySalaryPage .quick-total-item,
  #myPieceworkPage .piecework-summary-item { min-width: 0; }
  .stat-box .value, .stats-metric .value,
  .dash-month-amount > strong, .dash-month-team > strong,
  .emp-mini-finance .v, .emp-dash-summary .amount,
  #mySalaryPage :is(.quick-total-item .v,.kpi-value,.payroll-amount-details dd,.sum-line),
  #myPieceworkPage :is(.piecework-summary-item strong,.piecework-entry-total strong,.piecework-line-values b),
  .employee-workspace-drawer .emp-detail-item strong {
    max-width: 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere;
    line-height: 1.35;
  }
  .dash-check-heading h3 { min-width: 0; overflow-wrap: anywhere; }
  .timesheet-page .ts-mobile-summary-pills > div { min-width: 0; flex-wrap: wrap; }
  .timesheet-page .ts-mobile-summary-pills strong { min-width: 0; white-space: normal; overflow-wrap: anywhere; }

  /* Tabs and filters grow in height when Android uses larger text. */
  .settings-page .set-nav .nav-link { min-width: 0; height: auto; white-space: normal; flex-wrap: wrap; justify-content: center; line-height: 1.4; }
  .settings-page .set-nav .nav-link > span { min-width: 0; overflow-wrap: anywhere; }
  .registration-admin-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; max-width: 100%; }
  .registration-admin-summary button { min-width: 0; min-height: 44px; height: auto; flex-wrap: wrap; white-space: normal; line-height: 1.4; }
  .registration-admin-summary button span { min-width: 0; overflow-wrap: anywhere; }

  /* Native month inputs have an intrinsic width; allow the field to shrink, not the buttons. */
  .fu-head-actions, .fu-period { min-width: 0; max-width: 100%; }
  .fu-head-actions { flex-wrap: wrap; }
  .fu-period { flex: 1 1 100%; width: 100%; }
  .fu-period input { flex: 1 1 0; min-width: 0; width: 0; max-width: 100%; }
  .fu-period .fu-icon-btn { flex: 0 0 44px; min-width: 44px; min-height: 44px; }
  .fu-tile, .fu-tile > :is(span,strong,small) { min-width: 0; }
  .fu-tile > strong { white-space: normal; overflow-wrap: anywhere; }
  #smrPage .smr-hero-actions { min-width: 0; max-width: 100%; flex-wrap: wrap; }
  #smrPage .smr-hero-actions .btn { flex: 1 1 140px; min-width: 0; max-width: 100%; min-height: 44px !important; height: auto; white-space: normal; }

  .gate-card { min-width: 0; max-width: 100%; grid-template-columns: minmax(0,1fr); }
  .gate-step { min-width: 0; max-width: 100%; }
  .gate-step :is(input,.btn) { min-width: 0; max-width: 100%; }
  .gate-step .btn { white-space: normal; height: auto; }

  #myPieceworkPage { width: 100%; min-width: 0; max-width: 100%; }
  #myPieceworkPage .piecework-page-header { min-width: 0; flex-wrap: wrap; }
  #myPieceworkPage .piecework-page-header > div { min-width: 0; max-width: 100%; }
  #myPieceworkPage .piecework-page-header h1 { white-space: normal; overflow-wrap: anywhere; }
  #myPieceworkPage .piecework-line-main { flex-wrap: wrap; }
  #myPieceworkPage .piecework-status { max-width: 100%; white-space: normal; }
  #myPieceworkPage .piecework-entry-total { grid-template-columns: minmax(0,1fr); }
  #myPieceworkPage .piecework-entry-total :is(strong,span,small) { grid-column: 1; grid-row: auto; text-align: left; }
}
@media screen and (max-width: 575px) {
  /* One readable value per row is preferable to adjacent overflowing financial cards. */
  .dash-month-summary, .stats-primary-grid, .stats-secondary-grid,
  .emp-mini-finance, #mySalaryPage .quick-total-bar,
  .timesheet-page .ts-mobile-summary-pills { grid-template-columns: minmax(0,1fr); }
  .dash-month-progress { grid-column: auto; }
  .stats-summary .stat-box { grid-template-columns: 38px minmax(0,1fr); }
  .stats-card .st-grid-table tbody td, #statsMonthDetailFoot td { white-space: normal; overflow-wrap: anywhere; }
  #statsMonthDetailFoot tr { grid-template-columns: minmax(0,1fr); }
  #mySalaryPage .quick-total-item { grid-column: auto; grid-row: auto; border-left: 0; border-right: 0; border-bottom: 1px solid var(--modern-line); }
  #mySalaryPage .quick-total-item:last-child { border-bottom: 0; }
  #mySalaryPage .payroll-amount-details dd { text-align: left; }
  .employee-workspace-drawer .emp-detail-grid { grid-template-columns: minmax(0,1fr); }
  .employee-workspace-drawer .emp-detail-item { min-width: 0; grid-template-columns: 22px minmax(0,1fr); }
  .employee-workspace-drawer .emp-detail-item strong { grid-column: 2; }
}
@media screen and (max-width: 575px) {
  #mySalaryPage .payroll-amount-details dl > div { flex-direction: column; align-items: flex-start; gap: 6px; }
  #mySalaryPage .payroll-amount-details :is(dt,dd) { min-width: 0; max-width: 100%; }
  #myPieceworkPage .piecework-summary { grid-template-columns: minmax(0,1fr); }
  #myPieceworkPage .piecework-summary-item + .piecework-summary-item { border-left: 0; border-top: 1px solid var(--pw-line); }
  #myPieceworkPage .piecework-settlement-line > span { min-width: 0; width: 100%; overflow-wrap: anywhere; }
  #myPieceworkPage .piecework-settlement-line strong { display: block; min-width: 0; margin-left: 0; white-space: normal; overflow-wrap: anywhere; }
  #myPieceworkPage .piecework-monthly-total { display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; }
  #myPieceworkPage .piecework-monthly-total strong { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
}
@media screen and (max-width: 767px) {
  .fu-tile > strong { line-height: 1.45; }
  #smrPage .smr-hero-actions .btn { flex-wrap: wrap; line-height: 1.4; padding-inline: 10px; }
  #smrPage .smr-hero-actions .btn span { position: static; width: auto; height: auto; min-width: 0; max-width: 100%; margin: 0; overflow: visible; clip: auto; white-space: normal; }
  body .timesheet-page .ts-save-wrap { flex-wrap: wrap; }
  .timesheet-page .ts-save-state { flex: 1 0 100%; overflow-wrap: anywhere; }
  body .timesheet-page .ts-save-wrap .ts-save-btn { flex: 1 1 180px; height: auto; white-space: normal; line-height: 1.4; }
}
@media screen and (max-width: 575px) {
  .fu-summary { grid-template-columns: minmax(0,1fr); }
}
@media screen and (max-width: 767px) {
  /* The optional timesheet grid may scroll; enlarged status text must stay in its own day. */
  .timesheet-page #table :is(th.day-col,td.day-cell) { width: max(40px,3.8em); min-width: max(40px,3.8em); max-width: none; }
  .timesheet-page #table thead th { height: auto; padding-block: 6px; }
  .timesheet-page #table :is(.day-num,.day-dow) { line-height: 1.4; }
  .timesheet-page #table .day-cell-inner { grid-template-rows: auto auto; gap: 2px; padding-block: 4px; }
  .timesheet-page #table td.day-cell .day-cell-inner input { width: calc(100% - 4px); height: 2.2em; min-height: 2.2em; line-height: 1.4; }
  .timesheet-page #table :is(.cell-plus-btn,.cell-reason-btn) { width: 1.8em; min-width: 24px; height: 1.8em; min-height: 24px; line-height: 1.4; }
}
@media screen and (max-width: 767px) {
  body .timesheet-page { padding-bottom: max(130px,8em); }
}
@media screen and (max-width: 767px) {
  .fp-card-facts :is(span,strong,small) { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
  .owner-income-totals strong { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
}
@media screen and (max-width: 575px) {
  .fp-card-facts { grid-template-columns: minmax(0,1fr); }
  .owner-income-totals { grid-template-columns: minmax(0,1fr); }
  .owner-income-totals > div:last-child { display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; }
  .owner-income-filters { grid-template-columns: minmax(0,1fr); }
  .owner-income-filters > * { grid-column: 1 !important; grid-row: auto !important; min-width: 0; max-width: 100%; }
  .owner-income-filters .form-select { width: 100%; }
  #incomeReset { justify-self: end; width: 44px; min-height: 44px; }
  .owner-period-controls { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; flex: 1 1 100%; width: 100%; min-width: 0; max-width: 100%; }
  #incomePrev { grid-column: 1; grid-row: 1; }
  #incomeMonth { grid-column: 2; grid-row: 1; width: 100%; min-width: 0; }
  #incomeNext { grid-column: 3; grid-row: 1; }
  #incomeYear { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; }
}
@media screen and (max-width: 767px) {
  .timesheet-page #table :is(th,td).emp-cell { min-width: max(112px,7em); max-width: none; }
  .timesheet-page #table thead th.emp-cell { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
}
