@font-face {
  font-family: Inter;
  src: url('/portal-font/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --primary: #173d59;
  --action: #204f72;
  --active: #102e44;
  --background: #f1f5f9;
  --surface: #fff;
  --secondary: #f8fafc;
  --selected: #eaf1f6;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --input-border: #cbd5e1;
  --success: #15803d;
  --warning: #b45309;
  --error: #dc2626;
  --focus-ring: 0 0 0 3px rgb(32 79 114 / 12%);
  --padding: 20px;
  --shadow: 0 1px 3px rgb(15 23 42 / 5%), 0 8px 24px rgb(15 23 42 / 4%);
  --control-height: 48px;
  --step-size: 32px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 16px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font: 400 15px/1.55 Inter, system-ui, sans-serif;
}
h1, h2, h3, p, ol, dl, dd { margin: 0; }
h1 { font-size: 24px; line-height: 32px; font-weight: 600; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
img { display: block; flex: none; width: 18px; height: 18px; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }
.portal {
  max-width: 480px;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.portal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: var(--padding);
  border-radius: 16px 16px 0 0;
  color: white;
  background: var(--primary);
}
.brand-title { flex: 1; min-width: 0; }
.brand-title p { margin-top: 4px; color: #dce7ee; font-size: 14px; }
.brand-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgb(255 255 255 / 12%);
}
.brand-icon img { width: 32px; height: 32px; }
.portal-header img, .primary img, .step.complete img { filter: invert(1); }
.logout {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: 44px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 8px;
  padding: 0 8px;
  background: transparent;
  color: white;
  font: 600 14px Inter, system-ui, sans-serif;
  cursor: pointer;
}
.logout:hover { background: rgb(255 255 255 / 12%); }
.logout:focus-visible { outline-color: white; }
.portal-body { padding: var(--padding); }
.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  padding: 0 0 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.stepper li { position: relative; text-align: center; }
.stepper li + li::before {
  content: '';
  position: absolute;
  top: calc(var(--step-size) / 2 - 1px);
  left: calc(-50% + var(--step-size) / 2 + 4px);
  width: calc(100% - var(--step-size) - 8px);
  height: 2px;
  background: var(--border);
}
.stepper li.reached::before { background: var(--action); }
.step { display: grid; justify-items: center; gap: 8px; font-size: 12px; line-height: 16px; color: var(--muted); }
.step > span { display: grid; place-items: center; width: var(--step-size); height: var(--step-size); border-radius: 50%; background: var(--secondary); border: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.step.complete, .step[aria-current] { color: var(--primary); font-weight: 600; }
.step.complete > span, .step[aria-current] > span { background: var(--action); color: white; border-color: var(--action); }
#workspace > *, #access form { animation: appear 200ms ease both; }
.stage > h2 + p, .stage > form, .stage > .stack { margin-top: 12px; }
.stage > p { color: var(--muted); }
.stage > h2:focus { outline: none; }
.stack { display: grid; gap: 16px; min-width: 0; }
.sections { gap: 24px; }
.field { display: grid; gap: 8px; min-width: 0; font-size: 14px; font-weight: 500; }
.field input, .field select {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: 8px 14px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font: 400 16px Inter, system-ui, sans-serif;
  transition: border-color 150ms, box-shadow 150ms;
}
.field input:focus, .field select:focus { border-color: var(--action); box-shadow: var(--focus-ring); outline: none; }
.field [aria-invalid="true"] { border-color: var(--error); }
.field :disabled { opacity: 1; background: var(--background); }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  min-height: var(--control-height);
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--action);
  text-align: center;
  text-decoration: none;
  font: 600 15px/1.35 Inter, system-ui, sans-serif;
  transition: background 150ms, border-color 150ms;
  cursor: pointer;
}
.button:hover { background: var(--selected); }
.button:active { border-color: var(--action); }
.primary { border-color: var(--action); background: var(--action); color: white; }
.primary:hover { background: var(--primary); }
.primary:active { background: var(--active); }
.tertiary { min-height: 44px; border-color: transparent; background: transparent; color: var(--muted); }
.button:disabled { color: #475569; background: var(--background); border-color: var(--border); cursor: default; }
.button:disabled img { filter: none; opacity: .6; }
.button[aria-busy="true"]::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.inline > .button { flex: 1 1 144px; }
.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--secondary);
}
.panel h3 { margin-bottom: 12px; }
.icon-title, .file-row, .signature-list li { display: flex; align-items: center; gap: 8px; }
.icon-title img { opacity: .7; }
.detail-list { display: grid; gap: 12px; }
.detail-list dt { font-size: 12px; color: var(--muted); }
.detail-list dd, .file-row { overflow-wrap: anywhere; }
.detail-list dd { font-size: 14px; font-weight: 500; }
.check, .method { cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.check input, .method input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--action); }
.message {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--selected);
  font-size: 13px;
}
.message.error { color: #991b1b; border: 1px solid #fecaca; background: #fef2f2; }
.message.pending { color: var(--warning); border: 1px solid #fed7aa; background: #fff7ed; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 12px; font-size: 16px; font-weight: 600; }
.method {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  padding: 16px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  transition: background 150ms, border-color 150ms;
}
.method:hover { background: var(--secondary); }
.method img { width: 28px; height: 28px; }
.method:has(input:checked) { background: var(--selected); border-color: var(--action); }
.method span { flex: 1; min-width: 0; }
.method small, .file-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.drop-area {
  position: relative;
  min-height: 180px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  background: var(--secondary);
  text-align: center;
}
.drop-area > img { width: 40px; height: 40px; }
.drop-area.dragging { background: var(--selected); border-color: var(--action); }
.drop-area:has([aria-invalid="true"]) { border-color: var(--error); }
.drop-area > label { width: auto; }
.drop-area:focus-within > label { outline: 2px solid var(--action); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.file-row > div { min-width: 0; flex: 1; }
.file-row .button { width: auto; }
.signed-pdf-actions > .button {
  flex:0 1 auto;
  width:auto;
  max-width:100%;
  padding-inline:8px;
  font-size:.875rem;
}
.inline-error { margin: 0; color: #991b1b; font-size: 13px; }
.success-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: #dcfce7;
}
.success-mark img { width: 48px; height: 48px; filter: invert(31%) sepia(66%) saturate(1309%) hue-rotate(101deg) brightness(91%); }
.signature-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.signature-list li { flex-wrap: wrap; font-size: 14px; }
.signature-list li img { opacity: .7; }
.signature-list li span:last-child { margin-left: auto; font-size: 12px; color: var(--muted); }
.signature-list .signed { color: var(--success); }
.portal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px var(--padding);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.portal-footer img { width: 14px; height: 14px; opacity: .65; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 389px) {
  .portal-header { gap: 8px; }
  .brand-title h1 { font-size: 20px; line-height: 26px; }
  .logout img { display: none; }
}
@media (min-width: 640px) {
  :root { --padding: 24px; }
  body { padding: 24px; }
  .pair, .detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .detail-list .wide { grid-column: 1 / -1; }
}
@media (min-width: 1024px) { body { padding: 32px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.worker-pdf-dialog {
  width:min(980px,calc(100vw - 24px));
  max-height:calc(100dvh - 24px);
  margin:auto;
  padding:0;
  border:1px solid #8295a8;
  border-radius:12px;
  background:#fff;
  color:#14243c;
}
.worker-pdf-dialog[open] { display:flex; flex-direction:column; }
.worker-pdf-dialog::backdrop { background:rgb(12 22 36 / 66%); }
.worker-pdf-header {
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:10px; padding:12px 16px; border-bottom:1px solid #d6e0e9;
}
.worker-pdf-header h2 { margin:0; min-width:0; }
.worker-pdf-pages:not([hidden]) {
  display:grid;
  grid-template-columns:auto auto auto;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:8px;
}
.worker-pdf-pages span { font-size:.875rem; text-align:center; }
.worker-pdf-header .inline > .button,
.worker-pdf-pages > .button {
  flex:0 1 auto;
  width:auto;
  min-height:40px;
  padding:6px 10px;
  font-size:.875rem;
}
.worker-pdf-content {
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  padding:13px;
  background:#e9eef3;
}
.worker-pdf-content canvas:not([hidden]) { display:block; height:auto; max-width:100%; margin:auto; background:#fff; }
@media (max-width:480px) {
  .worker-pdf-header { padding:9px 12px; gap:6px; }
  .worker-pdf-header h2 { flex-basis:100%; font-size:1rem; line-height:1.3; }
  .worker-pdf-header .inline > .button,
  .worker-pdf-pages > .button { padding-inline:8px; }
}
