
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 27, 32, 0.55);
}

.modal-backdrop.hidden {
  display: none;
}

.operation-progress-backdrop {
  z-index: 30;
}

.operation-progress-backdrop .sample-progress-bar span {
  width: 38%;
  animation: operation-progress-slide 1.15s ease-in-out infinite;
}

@keyframes operation-progress-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(290%);
  }
}

.modal-card {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: 0 24px 70px rgba(17, 27, 32, 0.28);
  padding: 16px;
}

.modal-backdrop.report-drawer-open {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}

.modal-backdrop.report-drawer-open .modal-card {
  width: min(560px, 100vw);
  max-height: none;
  height: 100%;
  border-radius: 0;
  padding: 18px;
}

.modal-backdrop.modal-client-create-open .modal-card {
  width: min(860px, calc(100vw - 48px));
  padding: 28px 32px 30px;
}

.modal-backdrop.source-statement-open .modal-card {
  width: min(1180px, calc(100vw - 48px));
}

.modal-backdrop.parser-analysis-open .modal-card {
  width: min(1320px, calc(100vw - 48px));
}

.modal-backdrop.modal-client-create-open .modal-header {
  margin-bottom: 20px;
}

.modal-backdrop.modal-client-create-open .modal-header h2 {
  font-size: 28px;
}

.modal-backdrop.modal-client-create-open .modal-header p {
  font-size: 16px;
  line-height: 1.4;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.modal-error {
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.operation-progress-modal {
  display: grid;
  gap: 14px;
}

.operation-progress-current {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 4px;
}

.operation-progress-current > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.operation-progress-current strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.operation-progress-current small,
.operation-progress-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.operation-progress-bar {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.operation-progress-bar span {
  display: block;
  width: var(--operation-progress, 8%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width var(--motion-medium);
}

.operation-progress-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.operation-progress-step {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.operation-progress-step svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.operation-progress-step span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.operation-progress-step.done {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
  background: var(--success-soft);
  color: var(--success);
}

.operation-progress-step.current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.operation-progress-note {
  margin: 0;
}

.modal-form {
  display: grid;
  gap: 18px;
}

.modal-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.modal-field > span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
  width: 100%;
  min-width: 0;
}

.modal-field textarea {
  resize: vertical;
}

.source-statement-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-statement-preview-meta span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  background: var(--surface-soft);
}

.source-statement-table-scroll {
  max-height: min(62vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.source-statement-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.source-statement-table th,
.source-statement-table td {
  max-width: 260px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-statement-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.source-statement-table td {
  color: var(--ink);
}

.source-statement-text-preview {
  max-height: min(62vh, 620px);
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 12px;
  white-space: pre-wrap;
}

.source-statement-pdf-preview {
  display: block;
  width: 100%;
  height: clamp(320px, 68vh, 720px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.client-create-form {
  gap: 18px;
  padding-top: 8px;
}

.client-directory-create-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.client-directory-create-form .client-create-name-field,
.client-directory-create-form .client-directory-create-wide,
.client-directory-create-form .client-create-actions {
  grid-column: 1 / -1;
}

.client-create-name-field input {
  min-height: 48px;
  font-size: 20px;
}

.client-create-actions {
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  gap: 14px;
}

.client-create-actions .icon-button {
  min-height: 48px;
  padding-inline: 20px;
}

.modal-destination-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.modal-destination-grid .icon-button {
  justify-content: center;
  min-height: 44px;
}

.workflow-completion-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--success-soft);
  color: var(--text);
  padding: 14px;
  margin-bottom: 14px;
}

.workflow-completion-next {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workflow-completion-next svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--success);
}

.workflow-completion-next div {
  min-width: 0;
}

.workflow-completion-next small {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workflow-completion-next strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.25;
}

.workflow-completion-summary p {
  margin: 10px 0 0 30px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#parser-problem-dialog { max-width: min(620px,92vw); padding:24px; border-radius:12px; }
#parser-problem-dialog fieldset label { display:block; margin:12px 0; }

#parser-problem-dialog { font:inherit; color:var(--ink); border:1px solid var(--line); box-shadow:0 24px 80px rgba(17,27,32,.3); }
#parser-problem-dialog::backdrop { background:rgba(17,27,32,.55); }
#parser-problem-dialog h2, #parser-problem-dialog h3 { margin:0 0 16px; }
#parser-problem-dialog .modal-form { gap:16px; }
#parser-problem-dialog fieldset { border:1px solid var(--line); border-radius:8px; }

.modal-backdrop.statement-reconciliation-open .modal-card {
  width: min(1240px, calc(100vw - 48px));
}

.agency-workspace-dialog { width: min(620px, calc(100vw - 36px)); color: var(--ink); }
.agency-workspace-dialog::backdrop { background: rgba(17, 27, 32, .55); }
.agency-workspace-dialog #agency-workspace-picker { display: block; width: 100%; margin-top: 6px; }
.agency-workspace-dialog .reference-picker { width: 100%; }
.agency-workspace-dialog .reference-picker > input { width: 100%; padding-right: 36px; }
.agency-workspace-dialog #agency-workspace-access { margin: 14px 0; color: var(--muted); }
@media (max-width: 480px) { .agency-workspace-dialog .modal-actions { flex-wrap: wrap; } }

.agency-support-banner { margin: 16px 18px; padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--surface-soft); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; }
.agency-support-banner a { margin-left: auto; color: var(--accent-strong); }
