/* Layout repairs shared by the staff, settings and customer pages: overflow, small screens and print.
   Buttons, colours and corners are defined once in app.css; nothing here restyles them. */
.photos > .photo { min-width:0; }
.photo figcaption { min-width:0; overflow-wrap:anywhere; word-break:break-word; }
body .doc-pair { grid-template-columns:repeat(2,minmax(0,1fr)); }
body .doc-pair > figure, body .doc-media > figure { min-width:0; }
body .doc-pair figcaption, body .doc-media figcaption { overflow-wrap:anywhere; }
body.platform-body .pa-two, body.platform-body .pa-two > *, body.platform-body .platform-shell { min-width:0; }
body.platform-body .pa-card { min-width:0; max-width:100%; overflow-x:auto; }
body.platform-body .pa-note { overflow-wrap:anywhere; }
@media (max-width:900px) { body.platform-body .pa-two { grid-template-columns:minmax(0,1fr); } }
body.ui-body .pcover.empty { max-width:none; margin:0; padding:0; }
body.ui-body .pgrid, body.ui-body .home-grid, body.ui-body .form-cols,
body.ui-body .job-layout, body.ui-body .cust-grid { min-width:0; }
body.ui-body .pgrid > *, body.ui-body .home-grid > *, body.ui-body .form-cols > *,
body.ui-body .job-layout > *, body.ui-body .cust-grid > * { min-width:0; }
body.ui-body .sched-scroll { margin-left:0; margin-right:0; padding-left:2px; padding-right:2px; max-width:100%; overscroll-behavior-x:contain; scrollbar-width:thin; }
body.ui-body .sched-chip strong { overflow-wrap:anywhere; }
body.ui-body .bill-current-main { flex-wrap:wrap; gap:8px 12px; }
body.ui-body .bill-current-main > .hint { flex:1 1 auto; min-width:0; }
body.ui-body .bill-current-main > strong { flex:0 1 auto; overflow-wrap:anywhere; }
body.ui-body .bill-current-main > .pill-status { flex:none; }
body.ui-body .bill-term small { line-height:1.45; }
body.ui-body .set-top { min-height:64px; gap:12px; }
body.ui-body .set-top > strong { flex:none; }
body.ui-body .set-top-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
body.ui-body .polish-settings-toggle { display:none; }
body.ui-body .set-sec, body.ui-body .set-page-head { scroll-margin-top:88px; }
body.ui-body .set-save { gap:12px; }
body.ui-body .set-save .btn { flex:none; }
body.ui-body .set-save .hint { min-width:0; }
body.ui-body .ui-head, body.ui-body .docs-editor-head { gap:12px; }
body.ui-body .ui-head > div, body.ui-body .docs-editor-head > div { min-width:0; }
body.ui-body .ui-head h1, body.ui-body .job-title-row h1, body.ui-body .docs-editor h1 { overflow-wrap:anywhere; }
body.ui-body .docs-risk legend { max-width:100%; white-space:normal; }
body.ui-body .sl-line > *, body.ui-body .cb-field > *, body.ui-body .cf-main > * { min-width:0; }
body.ui-body .sl-line label { overflow-wrap:anywhere; }
body.ui-body .launch-dialog, body.ui-body .sl-dialog { max-height:calc(100dvh - 24px); overflow-y:auto; overscroll-behavior:contain; }
body.ui-body .launch-dialog::backdrop, body.ui-body .sl-dialog::backdrop { background:rgb(14 18 23 / .64); }
body.ui-body .launch-dialog .launch-photo-picker label { position:relative; }
body.ui-body .launch-dialog .launch-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
body.ui-body .launch-dialog .launch-form label, body.ui-body .launch-dialog .launch-grid > * { min-width:0; }
body.ui-body .launch-dialog .ui-pick { min-width:0; max-width:100%; width:100%; }
body.ui-body .launch-dialog :is(input,textarea,select), body.ui-body .sl-dialog :is(input,textarea,select) { scroll-margin-block:88px; }
@media (max-width:1199px) and (min-width:901px) {
  /* Use the editor's available width, allowing for the desktop sidebar. */
  body.ui-body .sl-line, body.ui-body .sl-line:not(:has(.sl-vat)) { grid-template-columns:repeat(4,minmax(0,1fr)); }
  body.ui-body .sl-line .sl-desc { grid-column:1 / -1; }
  body.ui-body .sl-line .sl-vat, body.ui-body .sl-line .sl-amount { grid-column:span 2; }
  body.ui-body .sl-line .sl-tools { grid-column:1 / -1; justify-content:flex-end; }
}
@media (max-width:899px) {
  body.ui-body .set-top { height:64px; padding:10px 14px; gap:8px; }
  body.ui-body .set-top > a.btn { width:36px; min-width:36px; min-height:40px; padding:0; font-size:0; }
  body.ui-body .set-top > a.btn::before { content:'←'; font-size:22px; line-height:1; }
  body.ui-body .set-top > strong { flex:1; min-width:0; font-size:14px; line-height:1.25; }
  body.ui-body .set-top-name { display:none; }
  body.ui-body .set-top .theme-pick { margin-left:0; flex:none; }
  body.ui-body .set-nav { position:fixed; top:64px; left:0; right:0; z-index:19; margin:0; padding:8px 14px; min-height:56px; align-items:center; border-bottom:1px solid var(--ui-line); background:var(--ui-surface); box-shadow:0 2px 4px rgb(0 0 0 / .03); scrollbar-width:thin; }
  body.ui-body .set-nav a { min-height:38px; display:inline-flex; align-items:center; padding:7px 12px; }
  body.ui-body .set-nav.polish-nav-ready { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; max-height:calc(100dvh - 140px); overflow-y:auto; overflow-x:hidden; }
  body.ui-body .polish-settings-toggle { grid-column:1 / -1; display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; padding:8px 12px; border:1px solid var(--ui-line); border-radius:8px; background:var(--ui-surface); color:var(--ui-ink); font:inherit; font-weight:600; min-height:40px; text-align:left; cursor:pointer; }
  body.ui-body .polish-settings-toggle > span:first-child { min-width:0; overflow-wrap:anywhere; }
  body.ui-body .set-nav.polish-nav-ready:not(.is-open) > a { display:none; }
  body.ui-body .set-nav.polish-nav-ready.is-open > a { white-space:normal; font-size:13px; }
  body.ui-body .set-wrap { display:block; padding-top:76px; }
  body.ui-body .set-main { margin-inline:auto; }
  body.ui-body .set-sec, body.ui-body .set-page-head, body.ui-body #payments { scroll-margin-top:148px; }
  body.ui-body .set-main > .set-notice.bad { top:130px; }
}
@media (max-width:600px) {
  body.ui-body .launch-dialog .launch-grid { grid-template-columns:minmax(0,1fr); }
  /* Avoid iOS zooming the whole page when a small form control receives focus. */
  body.ui-body input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=color]):not([type=file]),
  body.ui-body textarea, body.ui-body select { font-size:16px; }
  body.ui-body .ui-pick-btn { font-size:16px; min-height:44px; }
  body.ui-body .sl-line, body.ui-body .sl-line:not(:has(.sl-vat)) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.ui-body .sl-line .sl-desc, body.ui-body .sl-line .sl-tools { grid-column:1 / -1; }
  body.ui-body .sl-line .sl-vat, body.ui-body .sl-line .sl-amount { grid-column:span 1; }
  body.ui-body .job-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:2px; overflow:visible; }
  body.ui-body .job-tabs button { min-width:0; padding:10px 4px; min-height:44px; font-size:12px; justify-content:center; white-space:normal; line-height:1.35; }
  body.ui-body .job-tabs .n { font-size:11px; padding:1px 5px; }
  body.ui-body .jobs-status { flex-wrap:wrap; overflow:visible; gap:6px; }
  body.ui-body .jobs-status button { flex:1 0 auto; justify-content:center; min-height:38px; padding:7px 10px; }
  body.ui-body .bill-terms { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.ui-body .bill-term span { padding:10px; }
  body.ui-body .bill-current-main > strong { font-size:18px; }
  body.ui-body .bill-current-main > .hint { flex-basis:100%; }
  body.ui-body .bill-current-main > .pill-status { margin-left:auto; }
  body.ui-body .docs-filters > label { min-width:0; max-width:100%; }
  body.ui-body .docs-filters .searchbox { flex-basis:100%; }
  body.ui-body .docs-actions { gap:8px; }
  body.ui-body .set-save { padding:10px 14px calc(10px + var(--safe-b)); }
  body.ui-body .set-save .hint { font-size:12px; }
}
@media (max-width:380px) {
  body.ui-body .ui-top { padding-left:12px; padding-right:12px; gap:6px; }
  body.ui-body .ui-top .icon-btn { width:34px; min-width:34px; }
  body.ui-body .job-tabs button { font-size:11px; }
  body.ui-body .job-tabs .n { font-size:10px; padding-inline:4px; }
  body.ui-body .quick-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.ui-body .set-top .theme-pick button { width:30px; }
}
@media print {
  body.ui-body .set-nav, body.ui-body .set-top, body.ui-body .set-save, body.ui-body .ui-tabs { display:none!important; }
}

/* Keep financial documents legible on a phone; printed PDFs retain their table layout. */
@media screen and (max-width:650px) {
  body .sale-lines { display:block; width:100%; }
  body .sale-lines thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
  body .sale-lines tbody { display:block; width:100%; }
  body .sale-lines tbody tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 16px; padding:16px 0; border-bottom:1px solid #e1e6ec; width:100%; }
  body .sale-lines tbody td { display:block; min-width:0; border:0; padding:0; font-size:13px; white-space:normal; text-align:left; overflow-wrap:anywhere; }
  body .sale-lines tbody td:first-child { grid-column:1 / -1; font-size:14px; line-height:1.6; }
  body .sale-lines tbody td::before { content:attr(data-label); display:block; margin-bottom:3px; font-size:10px; letter-spacing:.04em; text-transform:uppercase; font-weight:700; color:#59677a; }
  body .sale-lines tbody td:first-child::before, body .sale-lines .sale-empty::before { display:none; }
  body .sale-lines tbody td:last-child:not(:first-child) { font-weight:700; }
}
