/* Field work controls shared by desktop dialogs and mobile workflows. */
.quick-choices,
.upload-pickers,
.contact-actions,
.mobile-more-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 13px 0;
}
.quick-choices .btn {
  min-height: 44px;
  font-size: 13px;
  white-space: normal;
  text-align: left;
}
.previous-note {
  padding: 14px 16px;
  margin-bottom: 17px;
  background: #f1f4f1;
  border-radius: 14px;
}
.previous-note p {
  margin: 7px 0;
  white-space: pre-wrap;
}
.previous-note small,
.upload-context {
  color: var(--muted);
}
.upload-pickers label.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 54px;
  margin: 0;
  cursor: pointer;
  font-size: 15px;
  background: #f7f9f7;
  border-style: dashed;
}
.upload-pickers label.btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
}
.upload-pickers label.btn.primary:hover:not(:has(input:disabled)) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.upload-pickers label.btn:focus-within {
  outline: 3px solid #8aac9b;
  outline-offset: 3px;
}
.upload-pickers label.btn:has(input:disabled) {
  color: #78827c;
  background: #eef1ef;
  border-color: #dde3df;
  box-shadow: none;
  cursor: default;
}
.upload-pickers input:disabled {
  cursor: default;
}
.upload-pickers input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.upload-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.upload-item img {
  width: 66px;
  height: 66px;
  object-fit: cover;
  border-radius: 11px;
}
.upload-item > div {
  min-width: 0;
  flex: 1;
}
.upload-item b {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.upload-item small {
  display: block;
  color: var(--muted);
  margin: 5px 0;
}
.upload-item progress {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
}
.upload-ok {
  color: var(--accent);
}
.upload-feedback {
  font-size: 14px;
  margin: 16px 0;
}
.confirm-check {
  display: flex !important;
  align-items: center;
  gap: 11px;
  padding: 14px;
  background: var(--accent-light);
  border-radius: 12px;
  line-height: 1.7;
}
.confirm-check input {
  width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  margin: 0 !important;
  flex-shrink: 0;
}
.modal .form-error {
  flex-shrink: 0;
  margin: 0;
  padding: 0 26px;
  max-height: 116px;
  overflow: auto;
}
.modal .form-error:not(:empty) {
  padding: 13px 26px;
  background: var(--danger-light);
}
.modal [aria-busy="true"] .modal-body {
  pointer-events: none;
  opacity: 0.65;
}
#networkStatus {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: #863f2e;
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  font-size: 13px;
  text-align: center;
}
#networkStatus[hidden] {
  display: none;
}
.mobile-actionbar {
  display: none;
}
.project-status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.project-status-line > .btn {
  min-height: 44px;
  padding: 8px 13px;
  font-size: 13px;
}
.quote-lines summary {
  min-height: 48px;
  padding: 16px 0;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}
.mobile-contact-compact > summary {
  min-height: 44px;
  padding: 13px 0;
  color: #5f7466;
  font-size: 14px;
  cursor: pointer;
}
.mobile-contact-compact {
  margin-bottom: 8px;
}

@media (max-width: 800px) {
  button {
    min-height: 44px;
  }
  .mobile-home {
    max-width: 600px;
    margin: 0 auto;
  }
  .mobile-greeting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin: 0 0 24px;
  }
  .mobile-greeting > div {
    min-width: 0;
  }
  .mobile-greeting small {
    color: var(--muted);
    font-size: 12px;
  }
  .mobile-greeting h1 {
    font-size: 34px;
    line-height: 1.25;
    letter-spacing: -1.15px;
    margin: 8px 0;
  }
  .mobile-greeting p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
  }
  .mobile-greeting .btn {
    padding: 11px 15px;
    font-size: 14px;
    border-radius: 14px;
    flex-shrink: 0;
  }
  .segment,
  .mobile-filters {
    display: flex;
    gap: 4px;
    margin: 12px 0 20px;
  }
  .segment {
    background: #e7e9e9;
    border: 1px solid #e2e4e4;
    border-radius: 13px;
    padding: 4px;
  }
  .segment button,
  .mobile-filters button,
  .mobile-project-tabs button {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
  }
  .segment button {
    flex: 1;
  }
  .segment .selected {
    color: var(--text);
    background: #fff;
    box-shadow:
      0 2px 5px #18231c12,
      0 0 0 1px #17251c04;
    font-weight: 550;
  }
  .mobile-filters {
    position: sticky;
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    z-index: 8;
    background: #f5f5f7ee;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 8px 0;
    margin-top: 0;
    margin-bottom: 12px;
  }
  .mobile-filters button {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
  }
  .mobile-filters .selected {
    color: var(--accent);
    background: #e4ece5;
    font-weight: 600;
  }
  .mobile-task {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 21px;
    padding: 19px 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-card);
  }
  .mobile-task.overdue {
    border-color: #dfbfb1;
    box-shadow:
      inset 3px 0 0 #b7684a,
      var(--shadow-card);
  }
  .mobile-task-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    color: #627868;
    font-size: 12px;
  }
  .mobile-task-top small {
    color: var(--muted);
    font-size: 11px;
  }
  .overdue .mobile-task-top {
    color: var(--danger);
  }
  .task-detail-link {
    display: block;
    padding: 14px 0 16px;
  }
  .task-detail-link h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    letter-spacing: -0.5px;
    flex-wrap: wrap;
  }
  .task-detail-link h2 span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0;
  }
  .task-detail-link p {
    color: var(--muted);
    font-size: 13px;
    margin: 5px 0 13px;
    overflow-wrap: anywhere;
  }
  .task-detail-link strong {
    display: block;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.65;
  }
  .task-go {
    display: flex;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    background: #f1f5f1;
    color: var(--accent);
    border: 0;
    box-shadow: none;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13px;
  }
  .task-go:hover {
    background: #e8efe8;
  }
  .task-warning {
    padding: 12px 13px;
    margin-bottom: 14px;
    background: var(--warning-light);
    color: var(--warning);
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.7;
  }
  .mobile-project {
    padding-bottom: 86px;
    max-width: 640px;
    margin: 0 auto;
  }
  .mobile-project .back-link {
    min-height: 44px;
    margin: -13px 0 8px;
    font-size: 13px;
  }
  .mobile-project-title h1 {
    font-size: 29px;
    letter-spacing: -0.85px;
    line-height: 1.4;
    margin: 12px 0 22px;
    overflow-wrap: anywhere;
  }
  .mobile-project-title .badge {
    font-size: 12px;
  }
  .mobile-contact {
    padding: 19px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: #fff;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
  }
  .mobile-contact > div:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    flex-wrap: wrap;
  }
  .mobile-contact > div span {
    font-size: 13px;
    color: var(--muted);
  }
  .mobile-contact p {
    font-size: 14px;
    line-height: 1.7;
    margin: 11px 0 16px;
    overflow-wrap: anywhere;
  }
  .contact-actions {
    display: grid;
    grid-template-columns: 1fr 1.12fr;
    margin: 0;
    gap: 10px;
  }
  .contact-actions .btn {
    min-height: 46px;
    padding: 10px 8px;
    font-size: 13px;
    border: 0;
    background: #f0f3f0;
    box-shadow: none;
    color: var(--accent);
  }
  .contact-missing {
    font-size: 13px;
    color: var(--muted);
    padding: 14px 7px;
  }
  .mobile-project-tabs {
    display: flex;
    position: sticky;
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    z-index: 8;
    gap: 3px;
    padding: 6px 0;
    background: #f5f5f7ed;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    margin: 0 0 20px;
  }
  .mobile-project-tabs button {
    flex: 1;
    padding: 10px 5px;
    font-size: 13px;
    white-space: nowrap;
  }
  .mobile-project-tabs .selected {
    color: var(--accent);
    background: #e4ece5;
    font-weight: 600;
  }
  .current-task {
    padding: 15px 17px;
    margin-bottom: 18px;
    background: #eaf1eb;
    border: 1px solid #dbe6dd;
    border-radius: 15px;
  }
  .current-task small {
    display: block;
    color: #64796a;
    font-size: 12px;
    margin-bottom: 6px;
  }
  .current-task b {
    font-size: 15px;
    font-weight: 550;
    line-height: 1.65;
  }
  .mobile-project .panel {
    padding: 20px;
    margin-bottom: 18px;
  }
  .mobile-project .panel h2 {
    font-size: 17px;
  }
  .mobile-project .panel p {
    font-size: 15px;
    line-height: 1.75;
    margin: 10px 0;
    white-space: pre-wrap;
  }
  .mobile-last .section-head {
    margin-bottom: 12px;
  }
  .mobile-last .section-head small {
    color: var(--muted);
    font-size: 11px;
  }
  .mobile-last p {
    max-height: 180px;
    overflow: auto;
  }
  .mobile-quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0;
  }
  .mobile-quick .btn {
    min-height: 54px;
    padding: 13px 9px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    white-space: normal;
  }
  .mobile-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.75;
    margin: 0 2px 20px;
  }
  .mobile-actionbar {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 11px;
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    padding: 11px 18px;
    border-top: 1px solid #dde3deb3;
    background: #f9fbfaeb;
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    z-index: 35;
  }
  .mobile-actionbar .btn {
    min-height: 50px;
    font-size: 15px;
    border-radius: 14px;
  }
  .mobile-actionbar .primary {
    font-weight: 600;
  }
  .mobile-history {
    border-top: 1px solid var(--line);
    margin: 26px 0 12px;
  }
  .mobile-history summary {
    min-height: 48px;
    padding: 18px 0;
    color: #536c5c;
    font-size: 14px;
    cursor: pointer;
  }
  .mobile-history article {
    padding: 17px 0;
    border-bottom: 1px solid var(--line);
  }
  .mobile-history b {
    font-size: 14px;
  }
  .mobile-history p {
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 8px 0;
  }
  .mobile-history small {
    color: var(--muted);
    font-size: 12px;
  }
  .field-status {
    padding: 14px 16px;
    border: 1px solid #dce7de;
    background: var(--accent-light);
    color: #426d50;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.7;
  }
  .field-status.blocked {
    border-color: #ecdfc7;
    background: var(--warning-light);
    color: var(--warning);
  }
  .delivery-steps {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    margin: 21px 0;
  }
  .delivery-steps .done {
    color: var(--accent);
    font-weight: 600;
  }
  .cargo-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    border-top: 1px solid var(--line);
    padding: 18px 0;
  }
  .cargo-card h3 {
    font-size: 16px;
  }
  .cargo-card p {
    font-size: 13px !important;
    margin: 5px 0 !important;
  }
  .cargo-card small {
    color: var(--muted);
    font-size: 12px;
  }
  .cargo-card > b {
    color: var(--text);
    font-size: 27px;
    font-weight: 550;
    white-space: nowrap;
    letter-spacing: -0.6px;
  }
  .cargo-card > b small {
    margin-left: 6px;
    font-weight: 400;
    letter-spacing: 0;
  }

  /* Bottom sheets retain a scrollable body and visible save feedback. */
  .modal-mask {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-height: 94dvh;
    border: 0;
    border-radius: 26px 26px 0 0;
  }
  .modal::before {
    content: "";
    display: block;
    width: 34px;
    height: 5px;
    margin: 9px auto 0;
    border-radius: 4px;
    background: #cbd0cc;
    flex-shrink: 0;
  }
  .modal > header {
    padding: 10px 20px 16px;
  }
  .modal h2 {
    font-size: 20px;
    letter-spacing: -0.4px;
  }
  .modal .close {
    min-width: 44px;
    min-height: 44px;
    font-size: 27px;
  }
  .modal-body {
    padding: 21px 20px;
    overscroll-behavior: contain;
  }
  .modal label {
    font-size: 14px;
    margin-bottom: 20px;
  }
  .modal input,
  .modal select,
  .modal textarea {
    min-height: 49px;
    font-size: 16px;
    border-radius: 12px;
  }
  .modal textarea {
    min-height: 98px;
  }
  .modal footer {
    gap: 11px;
    padding: 13px 20px calc(13px + env(safe-area-inset-bottom, 0px));
    background: #fafafb;
  }
  .modal footer .btn {
    min-height: 51px;
    font-size: 16px;
    border-radius: 13px;
  }
  .modal footer .primary {
    flex: 1;
  }
  .modal .quick-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .modal .quick-choices .btn {
    min-height: 48px;
    font-size: 13px;
    line-height: 1.6;
    padding: 10px 11px;
    text-align: left;
  }
  .modal .previous-note {
    max-height: 130px;
    overflow: auto;
    font-size: 14px;
  }
  .modal .form-error {
    font-size: 14px;
    padding-left: 20px;
    padding-right: 20px;
  }
  .role-choice {
    min-height: 64px;
  }
  .mobile-more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .mobile-more-grid .btn {
    min-height: 52px;
    white-space: normal;
  }

  /* Tables become labelled records, including finance and project screens. */
  .page-content .table-scroll {
    overflow: visible;
  }
  .page-content table {
    display: block;
    min-width: 0;
    width: 100%;
  }
  .page-content thead {
    display: none;
  }
  .page-content tbody {
    display: grid;
    gap: 13px;
  }
  .page-content tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fafbfa;
  }
  .page-content td {
    border: 0;
    padding: 8px;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .page-content td:first-child {
    grid-column: 1 / -1;
    font-size: 16px;
    font-weight: 600;
  }
  .page-content td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
    margin-bottom: 5px;
  }
  .page-content td:first-child::before {
    display: none;
  }
  .mobile-project .material-row {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    gap: 10px;
    padding: 16px 0;
  }
  .mobile-project .material-row > img {
    width: 48px;
    height: 48px;
  }
  .mobile-project .material-row > div {
    grid-column: 2 / 4;
    min-width: 0;
  }
  .mobile-project .material-row > .link-btn {
    min-height: 44px;
    padding: 8px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
  }
  .mobile-project .material-row p {
    font-size: 12px;
    margin: 4px 0;
  }
  .mobile-project .section-head {
    flex-wrap: wrap;
    gap: 10px;
  }
  .mobile-project .quote-total {
    flex-direction: column-reverse;
    gap: 13px;
  }
  .mobile-project .quote-total > div {
    text-align: left;
    margin-left: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .mobile-project .quote-total strong {
    order: -1;
  }
  .mobile-project .quote-panel .section-head [data-action="contract"] {
    display: none;
  }
  .mobile-project .asset-grid {
    grid-template-columns: 1fr 1fr;
  }
  .mobile-home .empty {
    padding: 40px 15px;
  }
  .mobile-home .empty h3 {
    font-size: 20px;
  }
  .mobile-home .empty p {
    font-size: 14px;
    line-height: 1.8;
  }
}

@media (min-width: 540px) and (max-width: 800px) {
  .mobile-actionbar {
    padding-left: max(18px, calc((100% - 640px) / 2));
    padding-right: max(18px, calc((100% - 640px) / 2));
  }
  .modal {
    max-width: 620px;
    margin: 0 auto;
  }
}
@media (max-width: 360px) {
  .mobile-greeting .btn {
    padding: 10px 12px;
  }
  .mobile-filters button {
    padding-left: 11px;
    padding-right: 11px;
  }
  .mobile-task {
    padding: 18px;
  }
  .contact-actions .btn {
    gap: 5px;
    font-size: 12px;
  }
  .mobile-project-tabs button {
    font-size: 12px;
  }
}
@media print {
  .mobile-actionbar,
  .mobile-nav,
  #networkStatus {
    display: none !important;
  }
}
