/* Run history (filter bar, compare tray), the finished-run report and the comparison page. Same
   tokens and components as the rest of the console. */

/* Filter bar: labelled selects above the table, a filter is a link. */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.select { min-width: 180px; max-width: 100%; padding-right: 28px; cursor: pointer; }
.input:hover { border-color: var(--text-faint); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.select option { background: var(--panel); color: var(--text); }

/* A visually hidden label inside a scrolled table must stay inside the scroller, not widen the page. */
.table-scroll { position: relative; }

/* Runs table: pick column and figure cells. */
.col-pick { width: 36px; padding-right: 0 !important; }
.pick { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.pick:disabled { cursor: not-allowed; opacity: 0.45; }
.pick-hit { display: contents; } /* the label is a touch hit area only (touch.css); on a fine pointer it vanishes from layout */
.runs-table tbody tr:has(.pick:checked) { background: var(--accent-soft); }
.attrib { text-decoration: underline dotted var(--text-faint); text-underline-offset: 4px; cursor: help; }

/* Compare tray: sticks to the bottom of the viewport while two runs are being picked. */
.compare-tray {
  position: sticky; bottom: 12px; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-top: 16px; padding: 10px 14px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.compare-tray[data-count="0"] { position: static; box-shadow: none; background: transparent; border-style: dashed; }
.tray-text { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; color: var(--text); }
.tray-actions { display: flex; gap: 8px; }
.tray-run { overflow-wrap: anywhere; }
.tray-tag { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--s-p50); color: var(--bg); font-size: 12px; font-weight: 700; flex: none; }
.tray-b { background: var(--warn); }

/* Finished-run report. */
.report { display: grid; gap: 16px; margin-top: 16px; }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 14px 16px; margin: 12px 0 4px; }
.fig dt { font-size: 12px; color: var(--text-dim); }
.fig dd { margin: 2px 0 0; }
.fig-value, .cell-value { font-weight: 600; text-decoration: underline dotted var(--text-faint); text-underline-offset: 4px; cursor: help; }
.fig-value { font-size: 18px; }
.cell-value.is-bad { color: var(--bad); }
.report-endpoints .table-scroll, .cmp-section .table-scroll { border: 0; border-radius: 0; background: none; margin: 8px -18px -12px; }
.endpoints .ep-name { overflow-wrap: anywhere; max-width: 48ch; }
.sort-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; cursor: pointer; }
.sort-btn:hover { color: var(--text); }
.sort-btn:hover .sort-icon { opacity: 0.5; }
.sort-icon { opacity: 0; width: 12px; height: 12px; }
.sort-btn[data-dir="asc"] .sort-icon, .sort-btn[data-dir="desc"] .sort-icon { opacity: 1; }
.sort-btn[data-dir="asc"] .sort-icon { transform: rotate(180deg); }
th[aria-sort] { color: var(--text); }
.kvs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 12px 0 4px; }
.kv { display: contents; }
.kv dt { color: var(--text-dim); font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.shape-lines { display: grid; gap: 4px; }
.shape-line { color: var(--text-dim); }
.shape-line.is-used { color: var(--text); }
.shape-src { display: inline-block; min-width: 104px; font-size: 12.5px; font-weight: 600; }
.shape-used { margin-left: 8px; padding: 0 8px; font-size: 11.5px; }
.env-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tag { display: inline-block; margin: 0 6px 4px 0; padding: 1px 8px; border-radius: 6px; background: var(--panel-2); }

/* Comparison. */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 16px; }
.pair-card { min-width: 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.pair-role { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.pair-name { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.pair-name a { color: var(--text); }
.pair-card .run-id { margin: 2px 0 8px; }
.pair-facts { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.banner { display: flex; align-items: flex-start; gap: 8px; }
.banner .icon { margin-top: 3px; color: var(--warn); }
.filter-ignored { margin: 12px 0 0; max-width: 70ch; align-items: center; }
.filter-ignored > span { flex: 1; overflow-wrap: anywhere; }
.filter-ignored .btn-icon { min-height: 28px; padding: 4px 6px; }
.filter-ignored .icon { margin-top: 0; }
.filter-ignored .btn-icon .icon { color: inherit; }
.cmp-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 16px; }
.cmp-verdict { margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 600; background: var(--good-soft); color: var(--good); }
.cmp-verdict[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }
.cmp-tables { display: grid; gap: 16px; margin-bottom: 16px; }
.cmp-table { table-layout: fixed; }
.cmp-table thead th:nth-child(1) { width: 26%; }
.cmp-table thead th:nth-child(2) { width: 11%; }
.cmp-table thead th:nth-child(7) { width: 132px; }
.cmp-table tbody + tbody { border-top: 1px solid var(--border); }
.cmp-table th[scope="rowgroup"] { vertical-align: top; font-weight: 600; color: var(--text); background: none; border-bottom: 0; font-size: 13px; letter-spacing: 0; overflow-wrap: anywhere; max-width: 36ch; }
.cmp-stat { color: var(--text-dim); white-space: nowrap; }
.cmp-delta { color: var(--text-dim); }
.is-regression .cmp-delta { color: var(--bad); font-weight: 600; }
.cmp-flag { width: 1%; white-space: nowrap; }
.overlay .legend-item.s-a .swatch { background: var(--s-p50); height: 3px; }
.overlay .legend-item.s-b .swatch { background: var(--s-p99); height: 3px; }
.chart .line.s-a { stroke: var(--s-p50); }
.chart .line.s-b { stroke: var(--s-p99); }
.chart .dot.s-a { fill: var(--s-p50); }
.chart .dot.s-b { fill: var(--s-p99); }
.cli-note { margin: 16px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.cli-line { color: var(--text); background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }
.state-alt { margin: 12px 0 0; }

@media (max-width: 640px) {
  /* Every column stays (and stays in the accessibility tree); the table scrolls sideways under a
     pinned pick + Run pair, so a row keeps its name while the figures slide past. */
  .runs-table { width: max-content; min-width: 100%; }
  .runs-table .col-pick, .runs-table .col-run { position: sticky; z-index: 1; background-color: var(--panel); }
  .runs-table thead .col-pick, .runs-table thead .col-run { z-index: 2; background-color: var(--panel-2); }
  .runs-table .col-pick { left: 0; width: 36px; min-width: 36px; max-width: 36px; }
  .runs-table .col-run { left: 36px; max-width: 40vw; min-width: 120px; box-shadow: inset -1px 0 0 var(--border); }
  .runs-table .col-run .run-name { overflow-wrap: anywhere; }
  .runs-table tbody tr:hover > .col-pick, .runs-table tbody tr:hover > .col-run { background-color: var(--panel-2); }
  .runs-table tbody tr:has(.pick:checked) > .col-pick, .runs-table tbody tr:has(.pick:checked) > .col-run { background-image: linear-gradient(var(--accent-soft), var(--accent-soft)); }
  .select { min-width: 0; width: 100%; }
  .filter-bar .field { flex: 1 1 140px; }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .pair-swap { justify-self: start; }
  .kvs { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .cmp-table th, .cmp-table td { padding: 8px 6px; }
  .cmp-table { table-layout: auto; }
  .cmp-table thead th { width: auto !important; }
  .cmp-table th[scope="rowgroup"] { min-width: 15ch; font-size: 12px; }
}

/* Regression verdicts and baselines: one vocabulary on the run list, run page and compare page.
   A state word with a drawn icon, never colour alone. Improved is the accent, not green. */
.pill-reg-bad { background: var(--bad-soft); color: var(--bad); }
.pill-reg-good { background: var(--good-soft); color: var(--good); }
.pill-reg-accent { background: var(--accent-soft); color: var(--accent); }
.pill-reg-warn { background: var(--warn-soft); color: var(--warn); }
.pill-unclean { margin-right: 6px; white-space: normal; }
.bl-unclean b { font-weight: 600; }
.pill-reg:focus-visible, .chip:focus-visible, .cmp-decisive li:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-bad { color: var(--bad); background: var(--bad-soft); }
.chip-accent { color: var(--accent); background: var(--accent-soft); }
.chip-warn { color: var(--warn); background: var(--warn-soft); }
.chip-muted { color: var(--text-dim); background: var(--panel-2); border-color: var(--border); font-weight: 600; }
.reg-none { cursor: help; }
.is-improved .cmp-delta { color: var(--accent); font-weight: 600; }
.cmp-strip { margin: 0 0 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-strip[data-verdict="regressed"] { border-color: var(--bad); }
.cmp-strip[data-verdict="inconclusive"] { border-color: var(--warn); }
.cmp-strip-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.cmp-strip .pill-reg { font-size: 14px; padding: 3px 12px; }
.cmp-reason { margin: 0; flex: 1 1 32ch; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.cmp-decisive { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.cmp-decisive li { overflow-wrap: anywhere; }
.cmp-rule { margin: 10px 0 0; font-size: 12.5px; }
.bl-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 16px; color: var(--text-dim); font-size: 13.5px; }
.bl-note .icon { flex: none; }
.bl-panel { margin-top: 16px; }
.bl-panel .panel-head { flex-wrap: wrap; row-gap: 4px; }
.bl-panel .panel-scope { white-space: normal; min-width: 0; overflow-wrap: anywhere; }
.bl-body { display: grid; gap: 10px; }
.bl-line { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; overflow-wrap: anywhere; }
.bl-line .icon { flex: none; align-self: center; color: var(--text-dim); }
.bl-warn .icon { color: var(--warn); }
.bl-verdict { display: grid; gap: 8px; }
.bl-verdict .cmp-decisive { margin: 0; }
.bl-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bl-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.bl-field { flex: 1 1 280px; }
.bl-field .input { width: 100%; }
.bl-form-actions { display: flex; gap: 8px; }
.bl-history summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.bl-history summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.bl-history-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.bl-history-list li { display: flex; flex-wrap: wrap; gap: 2px 10px; overflow-wrap: anywhere; }
.bl-when { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 12ch; }
@media (max-width: 640px) {
  .cmp-controls { align-items: stretch; }
}
.cmp-controls { justify-content: flex-start; }
.cmp-controls .field-inline { display: flex; flex: none; flex-wrap: nowrap; }
.cmp-controls .inline-msg:empty { display: none; }
.bl-note > span { flex: 1 1 20ch; min-width: 0; }

/* Insights: problems as full rows (mark, title + severity, finding, advice, evidence), then one quiet line per audit that found nothing. */
.ins-list, .ins-quiet-list { list-style: none; margin: 10px 0 0; padding: 0; }
.ins { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--border-soft); }
.ins:first-child { border-top: 0; padding-top: 6px; }
.ins-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); }
.ins-mark .icon { width: 16px; height: 16px; }
.ins-mark-bad { background: var(--bad-soft); color: var(--bad); }
.ins-mark-warn { background: var(--warn-soft); color: var(--warn); }
.ins-mark-good { color: var(--good); width: 20px; height: 20px; }
.ins-mark-muted { color: var(--text-faint); width: 20px; height: 20px; }
.ins-body { min-width: 0; }
.ins-title { margin: 3px 0 6px; font-size: 15px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ins-finding { margin: 0; max-width: 75ch; color: var(--text); }
.ins-advice { margin: 6px 0 0; max-width: 75ch; color: var(--text-dim); }
.ins-evidence { margin: 8px 0 0; font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; width: fit-content; max-width: 100%; cursor: help; text-decoration: underline dotted var(--text-faint); text-underline-offset: 4px; }
.ins-ev-label { font-weight: 600; color: var(--text-faint); }
.ins-list + .ins-quiet-list { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.ins-quiet { display: grid; grid-template-columns: 20px max-content minmax(0, 1fr); align-items: baseline; gap: 4px 10px; padding: 5px 0; font-size: 13.5px; }
.ins-quiet .ins-mark { align-self: center; }
.ins-q-title { font-weight: 600; }
.ins-q-finding { color: var(--text-dim); width: fit-content; cursor: help; text-decoration: underline dotted var(--text-faint); text-underline-offset: 4px; }
.ins-quiet.is-na .ins-q-title { color: var(--text-dim); }
.ins-evidence:focus-visible, .ins-q-finding:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (max-width: 640px) {
  .ins-quiet { grid-template-columns: 20px minmax(0, 1fr); }
  .ins-q-finding { grid-column: 2; }
}
