/* ===========================================
   Workflow operations (design §E.3 Slice 4)

   One page of record sections: filters, the metric row, and the run table.
   Sections are a heading over a hairline, not nested cards. The run table
   scrolls inside its .table-responsive region (components/table.css), so the
   document never scrolls sideways. Mobile-first, tokens only.
   =========================================== */

.workflow-operations {
  display: grid;
  gap: var(--spacing-xl);
  min-width: 0;
}

/* Every grid child (the live #workflow-operations-report included) may shrink
   below its content, so the wide run table scrolls inside its region instead
   of widening the page's single grid track. */
.workflow-operations > * {
  min-width: 0;
}

.workflow-operations .page-header {
  margin-bottom: 0;
}

.workflow-operations__authority,
.workflow-operations__derived,
.workflow-operations__freshness,
.workflow-operations__help {
  max-width: var(--prose-max-width);
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* A failed refresh says the facts may be stale: danger text and a word. */
.workflow-operations__freshness[data-stale="true"] {
  color: var(--color-danger);
  font-weight: var(--font-semibold);
}

.workflow-operations__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm) var(--spacing-md);
  min-width: 0;
}

.workflow-operations__actions .button {
  width: 100%;
}

.workflow-operations__api {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.workflow-operations__api code {
  overflow-wrap: anywhere;
}

/* Record sections */
.workflow-operations__panel {
  min-width: 0;
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

.workflow-operations__panel h2 {
  margin: 0 0 var(--spacing-md);
  color: var(--color-text-emphasis);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

details.workflow-operations__panel > summary {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: var(--touch-target);
  color: var(--color-text-emphasis);
  font-weight: var(--font-medium);
  list-style: none;
  cursor: pointer;
}

details.workflow-operations__panel > summary::-webkit-details-marker {
  display: none;
}

details.workflow-operations__panel > summary::before {
  content: "";
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  mask: var(--icon-chevron-mask) center / 1.25rem no-repeat;
  transform: rotate(-90deg);
}

details.workflow-operations__panel[open] > summary::before {
  transform: none;
}

details.workflow-operations__panel[open] > summary {
  margin-bottom: var(--spacing-sm);
}

details.workflow-operations__panel .workflow-operations__help {
  margin-bottom: var(--spacing-md);
}

/* Filters and the baseline form: one column on phones */
.workflow-operations__filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--spacing-md);
  align-items: end;
}

.workflow-operations__filters > div {
  display: grid;
  gap: var(--spacing-xs);
  min-width: 0;
}

.workflow-operations__filters .form__label {
  margin-bottom: 0;
}

.workflow-operations__filters select[multiple] {
  min-height: 6.5rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  background-image: none;
}

.workflow-operations__filters .button {
  width: 100%;
}

.workflow-operations__checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: var(--touch-target);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
}

.workflow-operations__checkbox input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--color-primary);
}

/* Metrics: a hairline grid of figures, label beneath */
.workflow-operations__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: var(--spacing-md) 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-border-subtle);
}

.workflow-operations__metrics article {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: var(--spacing-md);
  background: var(--color-surface);
}

.workflow-operations__metrics strong {
  overflow-wrap: anywhere;
  color: var(--color-text-emphasis);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}

.workflow-operations__metrics span {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* The run table: cells carry a primary value and muted detail lines */
.workflow-operations__table td {
  min-width: 9rem;
}

.workflow-operations__table th.table__num {
  text-align: right;
}

.workflow-operations__table small {
  display: block;
  margin-top: var(--spacing-xs);
  overflow-wrap: anywhere;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.workflow-operations__table code {
  font-size: var(--text-xs);
}

.workflow-operations__pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm) var(--spacing-md);
  margin-top: var(--spacing-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

@media (min-width: 640px) {
  .workflow-operations__actions .button,
  .workflow-operations__filters .button {
    width: auto;
  }

  .workflow-operations__filters {
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  }

  .workflow-operations__metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
