/* Keep the same reading order, content edges and controls across workspaces.
   Report editors retain their keyboard and fixed-footer height calculations. */
html:has(> body[data-system-ui="workbench"]) { scrollbar-gutter:stable; }
:root body[data-system-ui] :is(.patrol-main,.workforce-main,.monitoring-workspace,.worker-main) {
  max-width:none;
  margin-inline:0;
}
:root body[data-system-ui] :is(.patrol-main,.workforce-main,.monitoring-workspace,.worker-main):not(.is-report-view):not(.is-collection-view) {
  padding:var(--sys-page-top) var(--sys-page-gutter) 32px;
}
:root body[data-system-ui] .patrol-main:is(.is-report-view,.is-collection-view):not(.has-photo-library) {
  padding-inline:var(--sys-page-gutter);
}
:root body[data-system-ui] .patrol-main :is(#patrol-content,#patrol-message),
:root body[data-system-ui] .workforce-main > *,
:root body[data-system-ui] .monitoring-workspace > :not(dialog),
:root body[data-system-ui] .worker-main > :is(.worker-list-view,.worker-task-view,.upload-queue) {
  width:100%;
  max-width:var(--sys-page-content-max);
  margin-inline:auto;
}
:root body[data-system-ui] #main-content {
  max-width:calc(var(--sys-page-content-max) + 2 * var(--sys-page-gutter));
  padding:var(--sys-page-top) var(--sys-page-gutter) 32px;
}
:root body[data-system-ui] :is(.page-heading,.workforce-heading,.worker-page-heading,.patrol-heading:not(.report-heading)) {
  display:flex;
  align-items:flex-end;
  flex-direction:row;
  flex-wrap:wrap;
  gap:16px 24px;
  margin-block:0 var(--sys-page-gap);
}
:root body[data-system-ui] :is(.page-heading,.workforce-heading,.worker-page-heading,.patrol-heading:not(.report-heading)) > div:first-child {
  flex:1 1 320px;
  min-width:0;
}
:root body[data-system-ui] :is(.page-heading h1,.patrol-heading:not(.report-heading) h2,.workforce-heading h2,.worker-page-heading h2) {
  display:block;
  margin:0 0 8px;
  color:var(--sys-heading);
  font-size:30px;
  line-height:1.35;
  font-weight:650;
  letter-spacing:0;
}
:root body[data-system-ui] .page-heading .eyebrow { display:none; }
:root body[data-system-ui] :is(.page-heading,.patrol-heading:not(.report-heading),.workforce-heading,.worker-page-heading) p {
  margin:0;
  color:var(--sys-muted);
  font-size:14px;
  line-height:1.7;
}
:root body[data-system-ui] :is(.page-actions,.patrol-heading > .patrol-actions,.worker-list-tools) {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  margin:0;
  min-width:0;
}
:root body[data-system-ui] .patrol-heading > .patrol-actions:empty,
:root body[data-system-ui] .workforce-heading > .patrol-actions:not(:has(> .button:not([hidden]))) { display:none; }
:root body[data-system-ui] .workforce-heading > .button { align-self:flex-end; }
:root body[data-system-ui] :is(.operations-sections,.issue-status-filters) {
  display:flex;
  flex-wrap:nowrap;
  gap:8px;
  padding:6px 0 8px;
  margin-bottom:var(--sys-page-gap);
  border:0;
  border-bottom:1px solid var(--sys-border);
  border-radius:0;
  background:transparent;
  box-shadow:none;
  overflow-x:auto;
}
:root body[data-system-ui] :is(.operations-sections,.issue-status-filters) a {
  display:inline-flex; align-items:center; justify-content:center;
  flex:0 0 auto;
  min-height:44px;
  padding:10px 14px;
  border:1px solid transparent;
  border-radius:var(--sys-radius-control);
  background:transparent;
  box-shadow:none;
  color:var(--sys-muted);
  font-size:14px; font-weight:500; line-height:1.5;
  text-align:center; text-decoration:none;
  white-space:nowrap;
}
:root body[data-system-ui] :is(.operations-sections,.issue-status-filters) a:hover { color:var(--sys-primary); }
:root body[data-system-ui] :is(.operations-sections,.issue-status-filters) a[aria-current=page] { border-color:var(--sys-accent-border); color:var(--sys-primary); background:transparent; box-shadow:none; font-weight:600; }
:root body[data-system-ui] :is(.operations-sections,.issue-status-filters) a:focus-visible { outline:2px solid var(--sys-focus); outline-offset:-3px; }
/* Keep status and management destinations readable on small phones. */
@media(max-width:600px) {
  :root body[data-system-ui] .issue-status-filters { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  :root body[data-system-ui] .issue-status-filters a { min-width:0; padding-inline:10px; }
}
/* Feature sheets also target filter IDs; keep their device rules in this layer. */
:root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) {
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  gap:12px;
  padding:16px;
  margin-block:0 var(--sys-page-gap);
}
:root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) > .field {
  flex:1 1 180px;
  min-width:0;
  max-width:360px;
  margin:0;
}
:root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) .field :is(input,select) { min-width:0; width:100%; max-width:100%; }
:root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) > .button { min-height:44px; margin:0; }
:root body[data-system-ui] .patrol-stats:not(.business-monthly-stats) {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  margin-bottom:var(--sys-page-gap);
}
:root body[data-system-ui] .business-hub { max-width:none; }
:root body[data-system-ui] .business-worker-summary {
  grid-column:1/-1;
  align-self:start;
  margin:0;
  padding:16px 20px;
}
:root body[data-system-ui] .business-worker-summary h3 { font-size:16px; }
:root body[data-system-ui] .business-worker-summary > strong { font-size:32px; }
:root body[data-system-ui] .worker-task-list { align-items:start; }
:root body[data-system-ui] .worker-task-card__meta { grid-template-columns:repeat(2,minmax(0,1fr)); }
:root body[data-system-ui] .worker-task-card__meta > span { min-width:0; }
:root body[data-system-ui] .worker-task-card__meta > span:last-child:nth-child(odd) { grid-column:1/-1; }
@media(min-width:1100px) {
  :root body[data-system-ui] .worker-task-card__meta { grid-template-columns:repeat(3,minmax(0,1fr)); }
  :root body[data-system-ui] .worker-task-card__meta > span:last-child:nth-child(odd) { grid-column:auto; }
  :root body[data-system-ui] .report-form #report-fields > .report-submit-bar {
    max-width:calc(var(--sys-page-content-max) + 2 * var(--sys-page-gutter));
    padding-inline:var(--sys-page-gutter);
  }
}
@media(max-width:900px) {
  :root body[data-system-ui] :is(.page-heading,.workforce-heading,.worker-page-heading,.patrol-heading:not(.report-heading)) { flex-direction:column; align-items:stretch; gap:12px; }
  :root body[data-system-ui] :is(.page-heading,.workforce-heading,.worker-page-heading,.patrol-heading:not(.report-heading)) > div:first-child { flex:auto; }
  :root body[data-system-ui] :is(.page-heading h1,.patrol-heading:not(.report-heading) h2,.workforce-heading h2,.worker-page-heading h2) { font-size:26px; }
  :root body[data-system-ui] :is(.page-actions,.patrol-heading > .patrol-actions,.worker-list-tools) { width:100%; }
  :root body[data-system-ui] .workforce-heading > .button { align-self:flex-start; }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) > .field { grid-column:auto; width:100%; max-width:none; }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter) > .button { width:100%; }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter):has(> .field:only-of-type):has(> .button ~ .button) > .field { grid-column:1/-1; }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter):has(> .field:only-of-type):not(:has(> .button ~ .button)) { grid-template-columns:minmax(0,1fr) auto; }
  :root body[data-system-ui] .patrol-stats:not(.business-monthly-stats) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  :root body[data-system-ui] .business-record-table .business-table-heading { display:none; }
  :root body[data-system-ui] .business-record-table .business-record { grid-template-columns:minmax(0,1fr) auto; gap:12px; padding:16px; }
  :root body[data-system-ui] .business-record-table .business-record-primary { grid-column:1/-1; }
  :root body[data-system-ui] .business-record-table .business-record-person { grid-column:1; grid-row:2; }
  :root body[data-system-ui] .business-record-table .business-record-status { grid-column:1; grid-row:3; }
  :root body[data-system-ui] .business-record-table .business-record-actions { grid-column:2; grid-row:2/4; flex-direction:column; align-items:stretch; align-self:end; }
  :root body[data-system-ui] .business-record-table .business-issue .business-record-status { grid-row:2; }
  :root body[data-system-ui] .business-record-table .business-issue .business-record-time { grid-column:1; grid-row:3; }
  :root body[data-system-ui] .business-record-table .business-company > p { grid-column:1; grid-row:2; }
  :root body[data-system-ui] .business-record-table .business-company > code { grid-column:1; grid-row:3; overflow-wrap:anywhere; }
  :root body[data-system-ui] .list-columns { display:none; }
  :root body[data-system-ui] .task-list { padding-inline:16px; }
  /* Leave the inset overdue rail visible beside the parcel icon. */
  :root body[data-system-ui] .task-row { grid-template-columns:minmax(0,1fr) auto; gap:10px; padding:16px 12px; }
  :root body[data-system-ui] .parcel-cell { grid-column:1; grid-row:1; }
  :root body[data-system-ui] .parcel-cell strong { font-size:16px; }
  :root body[data-system-ui] .company-cell { grid-column:1/-1; grid-row:2; padding-left:47px; font-size:13px; }
  :root body[data-system-ui] .status-cell { grid-column:2; grid-row:1; }
  :root body[data-system-ui] .deadline-cell { grid-column:1/-1; grid-row:3; padding-left:47px; font-size:13px; }
  :root body[data-system-ui] .deadline-cell small { display:inline; margin-left:8px; }
  :root body[data-system-ui] .mobile-label { display:inline; font-size:12px; }
  :root body[data-system-ui] .row-arrow { display:none; }
  :root body[data-system-ui] .business-person-table .workforce-record { grid-template-columns:minmax(0,1fr) auto; gap:12px; padding:16px; }
  :root body[data-system-ui] .business-person-identity { grid-column:1; grid-row:1; }
  :root body[data-system-ui] .business-person-table .workforce-record > div:nth-child(3) { grid-column:2; grid-row:1; }
  :root body[data-system-ui] .business-person-role { grid-column:1/-1; grid-row:2; }
  :root body[data-system-ui] .business-person-table .person-actions { grid-column:1/-1; grid-row:3; justify-content:flex-start; }
  :root body[data-system-ui] .workforce-record.business-event { grid-template-columns:1fr; gap:10px; padding:18px 18px 18px 30px; }
  :root body[data-system-ui] .business-event::before { left:12px; top:24px; }
  :root body[data-system-ui] .business-event > div:first-child { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  :root body[data-system-ui] .business-event > div:first-child p { flex-basis:100%; }
  :root body[data-system-ui] .business-form-layout { grid-template-columns:minmax(0,1fr); }
  :root body[data-system-ui] .business-form-guide { grid-row:auto; }
}
@media(max-width:600px) {
  :root body[data-system-ui] .operations-sections { gap:8px; }
  :root body[data-system-ui] .operations-sections a { flex:1 1 0; min-width:0; padding-inline:2px; font-size:13px; }
  :root body[data-system-ui] :is(.page-actions,.patrol-heading > .patrol-actions) > :is(.button,button) { flex:1 1 130px; white-space:normal; }
  :root body[data-system-ui] .workforce-heading > .button { align-self:stretch; width:100%; }
  :root body[data-system-ui] :is(.patrol-form:not(.report-form):not(.attendance-simple),#monthly-submit-form) button[type=submit] { width:100%; }
  :root body[data-system-ui] .business-worker-summary { padding:14px 16px; }
  :root body[data-system-ui] .business-worker-summary p { display:none; }
  :root body[data-system-ui] .business-role-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
}
@media(max-width:360px) {
  :root body[data-system-ui] :is(.page-heading h1,.patrol-heading:not(.report-heading) h2,.workforce-heading h2,.worker-page-heading h2) { font-size:24px; }
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter),
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter):has(> .field:only-of-type):not(:has(> .button ~ .button)) { grid-template-columns:minmax(0,1fr); }
}
@media(max-width:1099px) {
  :root body[data-system-ui] :is(.business-record-actions .button,.business-person-table .button,.business-panel-heading .button,.business-role-tabs button) { min-height:44px; }
}
@media(min-width:361px) and (max-width:900px) {
  /* Workforce filters retain hidden date/export fields when showing people. */
  :root body[data-system-ui] :is(.patrol-filter,.workforce-filters,#month-filter,#attendance-filter,#record-filter,#month-detail-filter):has(> .field:not([hidden])):not(:has(> .field:not([hidden]) ~ .field:not([hidden]))):not(:has(> .button:not([hidden]) ~ .button:not([hidden]))) {
    grid-template-columns:minmax(0,1fr) auto;
  }
}
/* A tablet's attendance card should not expand to the full tall viewport. */
@media(min-width:601px) and (max-width:1099px) {
  :root body[data-system-ui] .patrol-main:has(.attendance-simple) #patrol-content { flex:none; }
  :root body[data-system-ui] .patrol-main .patrol-form.business-attendance { flex:none; max-width:680px!important; min-height:min(700px,calc(100dvh - 140px)); }
  :root body[data-system-ui] .business-attendance > .attendance-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:16px; }
}
