.agreement-pdf-dialog { box-sizing: border-box; inset: 0; width: min(1180px, calc(100vw - 40px)); height: min(1100px, calc(100dvh - 40px)); max-width: none; max-height: none; margin: auto; padding: 0; border: 1px solid var(--stroke-2); border-radius: 14px; background: var(--bg-surface); color: var(--fg-1); box-shadow: var(--shadow-lg); overflow: hidden; }
.agreement-pdf-dialog::backdrop { background: rgb(7 19 49 / 72%); }
.agreement-pdf-shell { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; height: 100%; min-width: 0; }
.agreement-pdf-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--stroke-1); }
.agreement-pdf-heading > div { min-width: 0; }
.agreement-pdf-heading p { margin: 0 0 4px; font-size: 12px; color: var(--fg-3); }
.agreement-pdf-heading h2 { margin: 0; font-family: var(--font-display); font-size: 24px; line-height: 1.2; color: var(--fg-1); overflow-wrap: anywhere; }
.agreement-pdf-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 20px; border-bottom: 1px solid var(--stroke-1); }
.agreement-pdf-toolbar > span { font-size: 13px; line-height: 1.4; color: var(--fg-2); }
.agreement-pdf-toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }
.agreement-pdf-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 44px; box-sizing: border-box; padding: 8px 12px; border: 1px solid var(--stroke-2); border-radius: 7px; color: var(--fg-1); background: var(--bg-surface); font: inherit; font-size: 14px; font-weight: 600; line-height: 1.25; text-transform: none; text-decoration: none; cursor: pointer; }
.agreement-pdf-button:hover { background: var(--bg-subtle); border-color: var(--gold-500); }
.agreement-pdf-button:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.agreement-pdf-content { grid-row: 4; position: relative; min-width: 0; min-height: 0; background: var(--bg-subtle); }
.agreement-pdf-message { display: grid; align-content: center; justify-items: center; gap: 16px; box-sizing: border-box; height: 100%; padding: 24px; text-align: center; }
.agreement-pdf-message p { max-width: 48ch; margin: 0; color: var(--fg-1); font-size: 16px; line-height: 1.5; }
.agreement-pdf-viewport { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: #525659; }
.agreement-pdf-viewport:focus-visible { outline: 3px solid var(--gold-500); outline-offset: -3px; }
.agreement-pdf-content .agreement-pdf-message { position: absolute; inset: 0; z-index: 5; background: var(--bg-subtle); }
.agreement-pdf-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 8px 20px; border-bottom: 1px solid var(--stroke-1); }
.agreement-pdf-pages { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.agreement-pdf-pages label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--fg-1); font: inherit; font-size: 16px; }
.agreement-pdf-pages input { box-sizing: border-box; width: 52px; min-height: 44px; padding: 6px; text-align: center; border: 1px solid var(--stroke-2); border-radius: 7px; background: var(--bg-surface); color: var(--fg-1); font: inherit; font-size: 16px; }
.agreement-pdf-controls select { box-sizing: border-box; width: 116px; min-height: 44px; padding: 6px 8px; border: 1px solid var(--stroke-2); border-radius: 7px; background: var(--bg-surface); color: var(--fg-1); font: inherit; font-size: 14px; }
.agreement-pdf-controls .agreement-pdf-button { min-width: 44px; padding: 8px; }
.agreement-pdf-controls input:focus-visible, .agreement-pdf-controls select:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.agreement-pdf-button:disabled { opacity: 0.45; cursor: default; }
.agreement-pdf-footer { grid-row: 5; margin: 0; padding: 9px 20px; border-top: 1px solid var(--stroke-1); color: var(--fg-2); background: var(--bg-surface); font-size: 12px; line-height: 1.4; }
.agreement-pdf-dialog [hidden] { display: none !important; }
@media (max-width: 600px) {
  .agreement-pdf-dialog { width: calc(100vw - 12px); height: calc(100dvh - 12px); border-radius: 10px; }
  .agreement-pdf-heading { align-items: flex-start; gap: 12px; padding: 12px; }
  .agreement-pdf-heading h2 { font-size: 20px; max-height: 72px; overflow-y: auto; }
  .agreement-pdf-toolbar { padding: 8px 12px; gap: 8px; }
  .agreement-pdf-toolbar > span { font-size: 12px; }
  .agreement-pdf-button { min-height: 44px; font-size: 13px; padding: 8px 10px; }
  .agreement-pdf-footer { padding: 8px 12px; }
  .agreement-pdf-controls { padding: 8px 10px; gap: 8px; }
  .agreement-pdf-pages { gap: 5px; font-size: 13px; }
  .agreement-pdf-controls select { width: 106px; font-size: 16px; }
}

.agreement-recipient-shell { display: flex; flex-direction: column; height: 100%; min-width: 0; min-height: 0; }
.agreement-recipient-dialog .agreement-pdf-heading { flex: 0 0 auto; }
.agreement-recipient-dialog .agreement-recipient-notice { margin: 6px 0 0; font-size: 13px; line-height: 1.4; }
.agreement-recipient-dialog .agreement-pdf-button { flex-shrink: 0; }
.agreement-recipient-loading { flex: 0 0 auto; margin: 0; padding: 12px 20px; color: var(--fg-2); }
.agreement-recipient-frame { display: block; flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #fff; }
@media (max-width: 600px) {
  .agreement-recipient-dialog .agreement-pdf-heading { flex-wrap: wrap; gap: 10px; }
  .agreement-recipient-dialog .agreement-pdf-heading > div { flex: 1 1 180px; }
  .agreement-recipient-dialog .agreement-pdf-button { min-height: 44px; }
}

.agreement-test-delivery, .agreement-lifecycle, .agreement-fulfillment { margin: 0; padding: 20px 14px; border-top: 1px solid var(--stroke-1); min-width: 0; }
.agreement-test-delivery > p:last-of-type, .agreement-lifecycle > p:last-of-type { margin-bottom: 0; }
.agreement-test-delivery > header, .agreement-lifecycle > header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.agreement-test-delivery h3, .agreement-lifecycle h3 { margin: 0; }
.agreement-test-delivery > p { margin: 8px 0 16px; color: var(--fg-2); }
.agreement-test-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; margin: 16px 0; }
.agreement-test-fields label { display: grid; gap: 6px; margin: 0; min-width: 0; }
.agreement-test-fields input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
/* F1P-42: the client on the agreement and the tester DocuSign emails are separate facts. */
/* Reset the legacy uppercase micro-label rule for agreement-record spans inside these facts. */
.agreement-delivery-parties span, .agreement-delivery-parties strong, .agreement-delivery-callout span, .agreement-delivery-callout strong { color: inherit; font-size: inherit; font-weight: inherit; letter-spacing: normal; text-transform: none; }
.agreement-delivery-parties strong, .agreement-delivery-callout strong { font-weight: 700; }
.agreement-delivery-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.agreement-delivery-party { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; border: 1px solid var(--stroke-1); border-radius: 8px; background: var(--bg-subtle); overflow-wrap: anywhere; }
.agreement-delivery-party.test { border-color: color-mix(in oklab, var(--warning) 45%, var(--stroke-1)); border-left: 4px solid var(--warning); background: color-mix(in oklab, var(--warning) 7%, var(--bg-surface)); }
.agreement-delivery-party-label { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--fg-2); font-size: 13px; font-weight: 600; }
.agreement-delivery-party-label .ui-icon { flex: 0 0 auto; color: var(--fg-3); }
.agreement-delivery-party.test .agreement-delivery-party-label .ui-icon { color: var(--warning); }
.agreement-delivery-party > strong { font-size: 18px; line-height: 1.3; color: var(--fg-1); }
.agreement-delivery-party > span { margin-top: 2px; min-height: 1.4em; color: var(--fg-2); font-size: 15px; line-height: 1.4; font-weight: 400; text-transform: none; letter-spacing: normal; }
.agreement-delivery-party[data-state="empty"] > strong, .agreement-delivery-party[data-state="checking"] > strong { color: var(--fg-2); font-weight: 600; }
.agreement-delivery-party-note { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--stroke-1); color: var(--fg-2); font-size: 14px; line-height: 1.45; }
.agreement-delivery-party.test .agreement-delivery-party-note { color: var(--fg-1); }
.agreement-delivery-restored { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 8px 0 0; color: var(--fg-1); font-size: 14px; line-height: 1.4; }
.agreement-delivery-restored .button { min-height: 36px; padding-inline: 10px; }
.agreement-delivery-callout .agreement-delivery-supersedes { display: block; margin-top: 6px; font-weight: 400; }
.agreement-test-delivery[data-delivery-mode="summary"] > p { margin-bottom: 12px; }
.agreement-test-delivery[data-delivery-mode="summary"] .agreement-delivery-parties { margin-bottom: 0; }
.agreement-delivery-callout { margin: 0 0 16px; padding: 12px 14px; border-left: 4px solid var(--warning); border-radius: 6px; background: color-mix(in oklab, var(--warning) 10%, var(--bg-surface)); color: var(--fg-1); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.agreement-delivery-facts .agreement-delivery-fact-secondary { display: block; margin-top: 2px; color: var(--fg-2); font-size: 14px; font-weight: 400; letter-spacing: normal; text-transform: none; }
.agreement-lifecycle > header { justify-content: space-between; }
.agreement-lifecycle ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.agreement-lifecycle li { min-width: 0; padding: 12px; border: 1px solid var(--stroke-1); border-top: 3px solid var(--stroke-2); border-radius: 8px; background: var(--bg-subtle); overflow-wrap: anywhere; }
.agreement-lifecycle li strong, .agreement-lifecycle li span { display: block; line-height: 1.4; }
.agreement-lifecycle li span { margin-top: 6px; color: var(--fg-2); font-size: 14px; font-weight: 400; text-transform: none; letter-spacing: normal; }
.agreement-lifecycle li[data-state="complete"] { border-top-color: var(--success, #2f8566); }
.agreement-lifecycle li[data-state="attention"] { border-top-color: var(--gold-500); }
.agreement-delivery-dialog { box-sizing: border-box; width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 1px solid var(--stroke-2); border-radius: 14px; color: var(--fg-1); background: var(--bg-surface); box-shadow: var(--shadow-lg); overflow-y: auto; }
.agreement-delivery-dialog::backdrop { background: rgb(7 19 49 / 72%); }
.agreement-delivery-dialog > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--stroke-1); }
.agreement-delivery-dialog > header > div { min-width: 0; }
.agreement-delivery-dialog > header > .button { flex: 0 0 auto; white-space: nowrap; overflow-wrap: normal; }
.agreement-delivery-dialog h2 { margin: 4px 0 0; font-size: 24px; line-height: 1.2; }
.agreement-delivery-content { padding: 20px; }
.agreement-delivery-facts { margin: 0 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.agreement-delivery-facts > div { min-width: 0; }
.agreement-delivery-facts dt { color: var(--fg-2); font-size: 13px; margin-bottom: 4px; }
.agreement-delivery-facts dd { margin: 0; overflow-wrap: anywhere; }
.agreement-delivery-recipient { grid-column: 1 / -1; padding: 14px; border: 1px solid var(--stroke-2); border-radius: 8px; background: var(--bg-subtle); }
.agreement-delivery-recipient strong, .agreement-delivery-recipient span { display: block; }
.agreement-delivery-recipient strong { font-size: 20px; }
.agreement-delivery-dialog .agreement-delivery-recipient span { margin-top: 4px; font-size: 15px; font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--fg-2); }
.agreement-delivery-dialog .agreement-delivery-confirm { display: flex; align-items: flex-start; gap: 10px; margin: 20px 0 0; font-size: 15px; line-height: 1.5; text-transform: none; letter-spacing: normal; cursor: pointer; }
.agreement-delivery-confirm input[type="checkbox"] { flex: 0 0 20px; width: 20px; height: 20px; min-height: 20px; margin: 2px 0 0; padding: 0; accent-color: var(--gold-500); }
.agreement-delivery-dialog .agreement-delivery-confirm span { flex: 1 1 auto; min-width: 0; color: var(--fg-1); font-size: 15px; font-weight: 400; line-height: 1.5; text-transform: none; letter-spacing: normal; }
.agreement-delivery-dialog > footer { padding: 16px 20px; border-top: 1px solid var(--stroke-1); }
.agreement-delivery-dialog > footer .button { width: 100%; white-space: normal; line-height: 1.35; min-height: 44px; }
.agreement-delivery-dialog .button:focus-visible, .agreement-test-delivery input:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.agreement-test-delivery [hidden] { display: none !important; }
@media (max-width: 600px) {
  .agreement-test-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .agreement-delivery-parties { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .agreement-delivery-party { padding: 12px 14px; }
  .agreement-delivery-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .agreement-delivery-dialog > header, .agreement-delivery-content { padding: 16px; }
  .agreement-delivery-facts { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .agreement-lifecycle ol { grid-template-columns: minmax(0, 1fr); }
  .agreement-lifecycle li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; }
  .agreement-lifecycle li span { margin-top: 0; }
}

.agreement-artifact-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.agreement-artifact-actions[hidden] { display: none !important; }

.agreement-fulfillment > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.agreement-fulfillment > header > button { flex: 0 0 auto; white-space: nowrap; }
.agreement-fulfillment h3 { margin: 0; }
.agreement-fulfillment > header p { margin: 6px 0 0; color: var(--fg-2); }
.agreement-fulfillment-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.agreement-fulfillment-fields label { display: grid; gap: 6px; margin: 0; min-width: 0; }
.agreement-fulfillment-fields input, .agreement-fulfillment-fields select { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
.agreement-fulfillment-fields :is(input, select):disabled { color: var(--fg-3); background: var(--bg-subtle); cursor: not-allowed; }
.agreement-fulfillment-locked { margin: 0 0 12px; }
.agreement-fulfillment-progress { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.agreement-fulfillment-progress > div { min-width: 0; padding: 12px; background: var(--bg-subtle); border: 1px solid var(--stroke-1); border-radius: 8px; }
.agreement-fulfillment-progress dt { color: var(--fg-2); font-size: 13px; margin-bottom: 6px; }
.agreement-fulfillment-progress dd { margin: 0; overflow-wrap: anywhere; }
.agreement-fulfillment-effects { list-style: none; margin: 12px 0 20px; padding: 0; }
.agreement-fulfillment-effects li { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--stroke-1); }
.agreement-fulfillment .agreement-fulfillment-effects strong { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 600; }
.agreement-fulfillment .agreement-fulfillment-effects span { flex: 0 1 40%; color: var(--fg-2); font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: normal; text-align: right; overflow-wrap: anywhere; }
.agreement-fulfillment [hidden] { display: none !important; }
.agreement-fulfillment-receipts > h3 { margin-bottom: 12px; }
.agreement-delivery-dialog[data-fulfillment-access-dialog] > header { position: sticky; top: 0; z-index: 1; background: var(--bg-surface); }
.agreement-fulfillment-receipts details { margin-top: 10px; border: 1px solid var(--stroke-1); border-radius: 8px; overflow: hidden; }
.agreement-fulfillment-receipts summary { padding: 12px; cursor: pointer; font-weight: 600; }
.agreement-fulfillment-receipts summary:focus-visible { outline: 3px solid var(--gold-500); outline-offset: -3px; }
.agreement-fulfillment-receipts details > div { padding: 0 12px 12px; }
.agreement-fulfillment-receipts p { margin: 0 0 12px; color: var(--fg-2); font-size: 12px; }
.agreement-fulfillment-receipts dl { display: grid; gap: 12px; margin: 0; }
.agreement-fulfillment-receipts dt { margin-bottom: 4px; color: var(--fg-2); font-size: 13px; }
.agreement-fulfillment-receipts dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (min-width: 601px) {
  .agreement-fulfillment-receipts details:not(.agreement-fulfillment-receipt-welcome) dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .agreement-fulfillment-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agreement-fulfillment-fields > label:first-child { grid-column: 1 / -1; }
  .agreement-fulfillment-progress { grid-template-columns: minmax(0, 1fr); }
}

/* Funding and delivery failures must remain readable on the existing dark surfaces. */
[data-theme="dark"] .agreement-test-delivery [data-agreement-funding-status].error,
[data-theme="dark"] .agreement-test-delivery [data-agreement-test-status].error,
[data-theme="dark"] .agreement-delivery-dialog [data-agreement-delivery-status].error { color: #ffd9d5; }
