/* "Recent results" panel: compact job cards, one filter row, one footer row, same white surface as "Current pipeline".
   Loaded after every other stylesheet; selectors start with `body #history` to win over the older layered rules. */

/* Same surface in both tabs, so switching tabs does not flash a different colour. */
body .pipeline-side #history { background: var(--bg-surface); padding-inline: 12px; align-self: stretch; width: 100%; }

/* Filters + bulk-actions menu on one row */
body #history .result-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 3px; margin: 12px 0 10px; overflow: visible; position: relative; }
body #history .result-filters > button { flex: 0 0 auto; min-height: 32px; padding: 6px 9px; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 500; box-shadow: none; }
body #history .result-filters > button:hover { background: var(--bg-page); }
body #history .result-filters > button[aria-pressed=true] { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--fg-inverse); box-shadow: var(--shadow-card); }
#history .result-filters > button span { margin-left: 3px; }

body #history .result-filters > .history-disclosure { position: relative; margin: 0 0 0 auto; padding: 0; border: 0; flex: none; }
body #history .history-disclosure > summary { min-height: 32px; padding: 6px 9px; gap: 4px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); font-size: 12.5px; font-weight: 600; cursor: pointer; }
body #history .history-disclosure > summary:hover { background: var(--bg-page); }
body #history .history-disclosure > summary::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0; border: solid currentColor; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); transition: transform .15s ease; }
#history .history-disclosure[open] > summary::after { margin-top: 3px; transform: rotate(-135deg); }
body #history .history-disclosure .panel-bulk-actions {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: max-content; min-width: 210px; margin: 0; padding: 8px;
  border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--bg-surface); box-shadow: var(--shadow-card);
}
#history .history-disclosure .panel-bulk-actions .secondary,
#history .history-disclosure .panel-bulk-actions #download-all { width: 100%; min-height: 36px; margin: 0; justify-content: flex-start; text-align: left; white-space: nowrap; }
body #history[data-single=true] .result-filters { display: none; }

/* Job card: icon + name + one meta line, then status (left) and actions (right) */
body #history .jobs { gap: 8px; }
body #history .job.job-recent {
  display: grid; gap: 10px; margin: 0 0 8px; padding: 12px; border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  background: var(--bg-subtle); box-shadow: none;
}
body #history .job-recent .job-top { display: flex; align-items: flex-start; gap: 10px; min-width: 0; margin: 0; }
body #history .job-recent .job-symbol { flex: none;    margin: 0; }
body #history .job-recent .job-copy { min-width: 0; flex: 1; }
body #history .job-recent .job-title {
  display: flex; min-width: 0; max-width: 100%; margin: 0; padding: 0; border: 0; background: none; box-shadow: none;
  color: var(--text-primary); font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.35; text-align: left; cursor: pointer;
}
#history .job-recent .job-title:hover { text-decoration: underline; }
body #history .job-recent .job-title-stem { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body #history .job-recent .job-title-ext { flex: none; white-space: nowrap; }
body #history .job-recent .job-subtitle { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); font-size: 12px; line-height: 1.4; }

body #history .job-recent .job-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
body #history .job-recent .job-status { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; margin: 0; padding: 0; border: 0; background: none; font-size: 12.5px; font-weight: 500; line-height: 1.35; }
body #history .job-recent .job-status-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
#history .job-recent .job-status.completed { color: var(--brand-tint-fg); }
#history .job-recent .job-status.failed { color: var(--danger); }
#history .job-recent .job-status.pending,
#history .job-recent .job-status.processing { color: var(--text-secondary); }
#history .job-recent .job-status.cancelled { color: var(--text-secondary); }

body #history .job-recent .job-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 0 auto; width: auto; margin: 0; }
body #history .job-recent .job-actions > button,
body #history .job-recent .job-more > summary { flex: none; width: auto; min-height: 32px; margin: 0; padding: 6px 12px; border-radius: var(--radius-md); font-size: 12.5px; line-height: 1.2; }
#history .job-recent .download::before { content: "↓ "; }
body #history .job-recent .job-more > summary { min-width: 32px; padding: 6px 9px; text-align: center; }
#history .job-recent .job-more { position: relative; }
body #history .job-recent .job-more-items { right: 0; left: auto; width: max-content; min-width: 190px; max-width: 250px; }

/* Footer: "Showing 3 of 4" on the left, one link on the right */
body #history .results-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 2px 0; padding-top: 10px; border-top: 1px solid var(--border-default); font-size: 12px; }
body #history .results-foot .jobs-preview-note { margin: 0; color: var(--text-secondary); }
#history .results-foot .jobs-preview-note[hidden] { display: none; }
#history .results-foot .all-results-link { margin-left: auto; font-weight: 500; text-decoration: none; white-space: nowrap; }
#history .results-foot .all-results-link:hover { text-decoration: underline; }

/* The "deletes in 7 days" line repeats the page footer on every card: show retention only when it matters. */
#history .job-recent .job-retention:not(.expiring):not(.expired):not(.kept) { display: none; }
body #history .job-recent .job-retention { margin: 0; font-size: 12px; }

/* Batch card: one card for a whole multi-file submission */
body #history .job-batch .batch-symbol { display: grid; place-items: center; background: var(--bg-muted); color: var(--text-primary); }
body #history .job-batch .batch-symbol svg { width: 20px; height: 20px; }
body #history .job-batch .batch-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); font-size: 13.5px; font-weight: 500; }
body #history .job-batch .batch-card-progress { width: 100%; height: 8px; border-radius: 999px; overflow: hidden; accent-color: var(--text-primary); }
#history .job-batch .batch-card-progress-text { margin-top: -4px; color: var(--text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
body #history .job-batch .batch-state { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; flex: 0 0 auto; }
#history .job-batch .batch-ok { color: var(--brand-tint-fg); }
#history .job-batch .batch-bad { color: var(--danger); }
#history .job-batch .batch-muted { color: var(--text-secondary); }
body #history .job-batch .batch-toggle { min-height: 0; padding: 0; border: 0; background: none; color: var(--text-primary); font-size: 12px; font-weight: 500; text-decoration: underline; cursor: pointer; }
body #history .job-batch .batch-foot { flex-wrap: wrap; row-gap: 8px; }
#history .job-batch .batch-foot .batch-actions { flex-wrap: wrap; justify-content: flex-end; width: auto; margin-left: auto; }
#history .job-batch .batch-toggle-row { margin-top: -2px; }
#history .job-batch .batch-state span { white-space: nowrap; }
body #history .job-batch .batch-items { display: grid; gap: 6px; }
#history .job-batch .batch-items[hidden] { display: none; }
body #history .job-batch .batch-search { width: 100%; min-height: 32px; padding: 6px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); font: inherit; font-size: 12.5px; }
body #history .job-batch .batch-item-list { max-height: 220px; overflow: auto; display: grid; gap: 2px; padding-right: 2px; scrollbar-width: thin; }
body #history .job-batch .batch-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 8px; align-items: center; padding: 6px 8px; border-radius: var(--radius-md); background: var(--bg-surface); font-size: 12.5px; }
#history .job-batch .batch-item[hidden] { display: none; }
#history .job-batch .batch-item.failed { background: var(--bg-page); }
#history .job-batch .batch-item-name { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#history .job-batch .batch-item-info { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); font-size: 11.5px; }
#history .job-batch .batch-item.failed .batch-item-info { color: var(--danger); white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
body #history .job-batch .batch-item-download { grid-column: 2; grid-row: 1 / span 2; width: 28px; min-height: 28px; padding: 0; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-subtle); cursor: pointer; }

/* The panel sits inside the tabbed card: it must fill it (the old grid rule left it `align-self: start`, ~65% wide) */
