/* Modal and action-footer styles, in original cascade order. */
.form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 20px 24px; background: #fbfcfe; }
.user-modal-backdrop { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 20px; background: rgba(16,24,40,.42); }
.user-modal { width: min(720px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 16px; background: white; box-shadow: 0 24px 60px rgba(16,24,40,.2); }
.user-modal .modal-top { align-items: flex-start; }
.user-modal .modal-top h3 { margin-bottom: 5px; }
.user-modal .modal-top p { margin: 0; font-size: 12px; }
.registration-review-modal { width: min(760px, 100%); }
.snapshot-modal { width: min(820px, 100%); }
.task-detail-modal { max-width: 760px; }
.task-update-section .form-footer { margin: 0; padding: 4px 0 0; background: transparent; }
.contract-modal { width: min(820px, 100%); }
.project-detail-modal { width: min(920px, 100%); }
.modal-backdrop { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(16,24,40,.42); }
.modal { width: min(760px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 16px; background: white; box-shadow: 0 24px 60px rgba(16,24,40,.2); }
.modal-top { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-top h3 { margin: 0; font-size: 16px; }
.modal-close { width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-muted); }
.alert-modal { position: relative; display: grid; grid-template-columns: 42px 1fr; column-gap: 13px; width: min(390px, 100%); padding: 26px 26px 22px; border: 1px solid var(--border); border-radius: 16px; background: white; box-shadow: 0 24px 60px rgba(16,24,40,.2); }
.alert-modal > .modal-close { position: absolute; top: 17px; right: 17px; }
.preview-modal { width: min(1060px, 100%); height: min(88vh, 820px); display: flex; flex-direction: column; overflow: hidden; border-radius: 16px; background: white; box-shadow: 0 24px 70px rgba(16,24,40,.3); }
@media (max-width: 760px) {
  .form-footer { padding: 16px; }
  .contract-modal { width: 100%; }
  .task-detail-modal .form-footer { align-items: stretch; flex-direction: column; }
  .task-detail-modal .form-footer .btn, .task-detail-status-actions { width: 100%; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .user-modal-backdrop { align-items: end; padding: 0; }
  .user-modal { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .preview-modal { width: 100%; height: 94vh; border-radius: 16px 16px 0 0; }
}
.page-actions { flex-wrap: wrap; }
.workflow-transfer-modal { width: min(920px, 96vw); }
.workflow-transfer-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.workflow-transfer-row { display: flex; gap: 12px; padding: 12px; margin: 0 !important; border-bottom: 1px solid var(--border); cursor: pointer; }
.workflow-transfer-row:last-child { border-bottom: 0; }
.workflow-transfer-row input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 4px; }
.workflow-transfer-row > span { min-width: 0; overflow-wrap: anywhere; }
.workflow-transfer-row strong, .workflow-transfer-row small { display: block; line-height: 1.6; }
.workflow-transfer-row small { color: var(--muted); font-weight: 400; }
.workflow-transfer-paging { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.workflow-transfer-paging > span { margin-right: auto; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .form-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .form-footer .btn { flex: 1 1 120px; }
  .modal, .user-modal { max-height: 94dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* Keep the last line clear of modal corner clipping and mobile safe areas. */
.modal, .user-modal { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); scroll-padding-bottom: 24px; box-sizing: border-box; overscroll-behavior-y: contain; scrollbar-gutter: stable; }
.modal > .form-tip, .user-modal > .form-tip { margin: 0; padding: 0 24px 8px; line-height: 1.65; overflow-wrap: anywhere; }
.modal .modal-top, .user-modal .modal-top { min-width: 0; gap: 12px; }
.modal .modal-top > :first-child, .user-modal .modal-top > :first-child { min-width: 0; overflow-wrap: anywhere; }
.project-person-picker { min-width: 0; border: 1px solid var(--border); border-radius: 9px; background: white; }
.project-person-picker > summary { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 12px; box-sizing: border-box; cursor: pointer; list-style: none; }
.project-person-picker > summary::-webkit-details-marker { display: none; }
.project-person-picker > summary [data-person-summary] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-person-picker > summary small { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.project-person-picker[open] { border-color: #edb4b0; }
.project-person-panel { padding: 10px; border-top: 1px solid var(--border); }
.project-person-panel [data-person-search] { width: 100%; min-width: 0; box-sizing: border-box; margin-bottom: 8px; }
.project-person-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 176px; overflow-y: auto; overscroll-behavior: contain; }
.project-person-option { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 38px; margin: 0 !important; padding: 7px 8px; box-sizing: border-box; font-weight: 400 !important; border-radius: 6px; cursor: pointer; }
.project-person-option:hover, .project-person-option:has(input:checked) { background: var(--red-soft); }
.project-person-option input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 16px; margin: 0; padding: 0; accent-color: var(--red); }
.project-person-option span { min-width: 0; overflow-wrap: anywhere; }
.project-person-option[hidden], .project-person-empty[hidden] { display: none !important; }
.project-person-empty { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.project-approval-fold { padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.project-approval-fold > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.project-approval-fold > summary small { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: 8px; }
.project-approval-fold > select { margin-top: 12px; }
.project-modal .modal-top { position: sticky; top: 0; z-index: 3; background: white; }
.project-modal #project-form > .form-footer { position: sticky; bottom: 0; z-index: 2; background: white; box-shadow: 0 -4px 12px rgba(16,24,40,.04); }
.project-modal #project-form .user-form-grid > .form-field:not(.full) { grid-column: auto; }
.project-modal { scroll-padding-top: 100px; scroll-padding-bottom: 100px; }
@media (max-width: 600px) {
  .modal > .form-tip, .user-modal > .form-tip { padding-left: 16px; padding-right: 16px; }
}
