.contract-desk-page {
  background: #faf7f1;
}

.contract-desk {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.desk-topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: #6d766e;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.desk-topbar h1,
.auth-panel h2,
.results-toolbar h2,
.pane-heading h2 {
  margin: 0;
  color: #20242e;
  font-weight: 700;
  letter-spacing: 0;
}

.desk-topbar h1 {
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1;
}

.desk-status-row,
.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill,
.metric-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #d8cebd;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

.status-pill.ready {
  border-color: rgba(45, 122, 110, 0.35);
  color: #2d7a6e;
}

.status-pill.closed {
  border-color: rgba(181, 73, 54, 0.35);
  color: #9a3c30;
}

.status-pill.soft {
  background: #f3eee5;
}

.auth-panel[hidden],
.auth-panel.is-hidden {
  display: none;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid rgba(181, 73, 54, 0.25);
  border-radius: 8px;
  background: #fff7f3;
}

.auth-panel p {
  max-width: 760px;
  margin: 8px 0 0;
  color: #5c6470;
}

.desk-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.search-pane,
.pipeline-section,
.review-section,
.audit-section {
  min-width: 0;
  border: 1px solid #e8e1d5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(32, 36, 46, 0.04);
}

.search-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid #e8e1d5;
}

.form-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.form-row.wide {
  grid-column: span 2;
}

.form-row.compact {
  max-width: 100px;
}

.form-row label {
  color: #5c6470;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-row input,
.form-row select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d8cebd;
  border-radius: 7px;
  background: #fbfaf7;
  color: #20242e;
  font: inherit;
  font-size: 0.92rem;
  padding: 0 11px;
}

.form-row input:focus,
.form-row select:focus {
  outline: 3px solid rgba(45, 122, 110, 0.16);
  border-color: #2d7a6e;
}

.form-row input:disabled,
.form-row select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  grid-column: span 2;
}

.primary-action,
.secondary-action,
.inline-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 7px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.primary-action {
  border: 1px solid #2d7a6e;
  background: #2d7a6e;
  color: #fff;
  padding: 0 18px;
}

.secondary-action {
  border: 1px solid #d8cebd;
  background: #fff;
  color: #334155;
  padding: 0 14px;
}

.inline-action {
  border: 1px solid #d8cebd;
  background: #fbfaf7;
  color: #334155;
  padding: 0 10px;
  min-height: 34px;
}

.danger-action {
  border-color: #e4b8aa;
  color: #8f3528;
}

.primary-action:hover,
.secondary-action:hover,
.inline-action:hover {
  filter: brightness(0.98);
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid #e8e1d5;
}

.metric-strip strong {
  margin-right: 4px;
  color: #2d7a6e;
}

.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th {
  padding: 12px 14px;
  background: #f3eee5;
  color: #5c6470;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.results-table td {
  padding: 14px;
  border-top: 1px solid #eee7dc;
  color: #2d333d;
  vertical-align: top;
}

.result-title {
  display: block;
  margin-bottom: 4px;
  color: #20242e;
  font-weight: 700;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #7b828a;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #d8cebd;
  border-radius: 999px;
  background: #fbfaf7;
  color: #334155;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
}

.fit-cell {
  color: #2d7a6e;
  font-weight: 700;
}

.empty-cell,
.empty-state {
  color: #7b828a;
  font-style: italic;
}

.empty-cell {
  height: 180px;
  text-align: center;
  vertical-align: middle !important;
}

.pipeline-pane {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.pipeline-section,
.review-section,
.audit-section {
  padding: 16px;
}

.pane-heading {
  margin-bottom: 14px;
}

.pipeline-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #e8e1d5;
  border-radius: 8px;
  background: #fbfaf7;
}

.pipeline-filter-row,
.pipeline-control-grid > div {
  display: grid;
  gap: 5px;
}

.pipeline-control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pipeline-controls label {
  color: #5c6470;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pipeline-controls input,
.pipeline-controls select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d8cebd;
  border-radius: 7px;
  background: #fff;
  color: #20242e;
  font: inherit;
  font-size: 0.82rem;
  padding: 0 9px;
}

.pipeline-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pipeline-nav span {
  flex: 1 1 88px;
  color: #5c6470;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-align: center;
}

.pipeline-list {
  display: grid;
  gap: 10px;
  max-height: min(72vh, 980px);
  overflow: auto;
  padding-right: 4px;
}

.pipeline-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #e8e1d5;
  border-radius: 8px;
  background: #fbfaf7;
}

.pipeline-item strong {
  color: #20242e;
}

.pipeline-item span,
.pipeline-label {
  color: #5c6470;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

.pipeline-label {
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pipeline-control,
.pipeline-notes {
  width: 100%;
  border: 1px solid #d8cebd;
  border-radius: 7px;
  background: #fff;
  color: #20242e;
  font: inherit;
  font-size: 0.86rem;
  padding: 8px 10px;
}

.pipeline-notes {
  min-height: 78px;
  resize: vertical;
}

.pipeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.review-steps {
  display: grid;
  gap: 10px;
}

.review-steps div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.review-steps span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #2d7a6e;
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 700;
}

.review-steps p {
  margin: 2px 0 0;
  color: #5c6470;
  font-size: 0.9rem;
  line-height: 1.45;
}

.review-note {
  margin: 12px 0 0;
  color: #6d766e;
  font-size: 0.84rem;
  line-height: 1.5;
}

.audit-log {
  min-height: 110px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid #e8e1d5;
  border-radius: 8px;
  background: #20242e;
  color: #d6eadf;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 12px;
}

@media (max-width: 1180px) {
  .desk-layout {
    grid-template-columns: 1fr;
  }

  .pipeline-pane {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .desk-topbar,
  .results-toolbar,
  .auth-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .desk-status-row,
  .metric-strip {
    justify-content: flex-start;
  }

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

  .form-row.wide,
  .form-actions {
    grid-column: span 2;
  }

  .pipeline-pane {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .contract-desk {
    width: min(1480px, calc(100% - 20px));
    padding-top: 22px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .form-row.wide,
  .form-actions {
    grid-column: auto;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }
}
