:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1c2330;
  --muted: #5a6474;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --pending-bg: #eceff3; --pending-fg: #3b4453;
  --processing-bg: #dbe8fb; --processing-fg: #0f4a9e;
  --awaiting-bg: #fff1cc; --awaiting-fg: #7a4d00;
  --completed-bg: #dcf2e3; --completed-fg: #17603a;
  --failed-bg: #fbdcd9; --failed-fg: #8c1d16;
  --ready-bg: #1e7d4a; --ready-fg: #ffffff;
  --review-bg: #f3c65b; --review-fg: #3d2b00;
  --notfound-bg: #6b7280; --notfound-fg: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
h1, h2, h3 { margin: 0; }
h2 { font-size: 15px; }
h3 { font-size: 13px; margin: 8px 0 4px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #14213d; color: #fff; position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.brand h1 { font-size: 18px; }
.brand h1 span { font-weight: 400; opacity: .8; }
.run-status { font-size: 13px; opacity: .95; }
.run-status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9aa3b2; margin-right: 6px; }
.run-status.running .dot { background: #4ade80; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .run-status.running .dot { animation: none; } }

.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions .sep { width: 1px; height: 22px; background: rgba(255,255,255,.3); margin: 0 4px; }
.actions .inline { font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.actions input[type=number] { width: 58px; padding: 4px; border-radius: 4px; border: 1px solid #8892a6; }

button, .button {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 5px; border: 1px solid #c3c9d4;
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.2;
}
button:hover, .button:hover { background: #eef2f8; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, tr:focus-visible, summary:focus-visible {
  outline: 3px solid #f59e0b; outline-offset: 1px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: #184d9b; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }

.message { margin: 10px 16px 0; padding: 8px 12px; border-radius: 6px; background: #e7f0ff; border: 1px solid #b8cff5; }
.message.error { background: #fdecea; border-color: #f2b8b3; color: #7a1a13; }

main { padding: 12px 16px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
section, .legend { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }

.counters { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.counter { min-width: 104px; padding: 8px 10px; border-radius: 6px; background: var(--pending-bg); }
.counter b { display: block; font-size: 20px; }
.counter span { font-size: 12px; color: var(--muted); }
.counter.c-total { align-self: flex-end; background: #eef1f5; }
.counter-group { display: flex; flex-direction: column; gap: 4px; }
.counter-group h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.counter-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* In progress = outlined; final result = solid tint. */
.g-progress .counter { background: #fff; border: 1.5px dashed #9aa6b8; }
.g-progress .counter.c-processing { border-color: #5b8fd9; }
.g-progress .counter.c-awaiting { border-color: #c79a2a; }
.g-final .counter.c-oc-ready { background: #cdebd9; }
.g-final .counter.c-oc-review { background: #fbecc4; }
.g-final .counter.c-oc-notfound { background: #e3e5e9; }
.g-final .counter.c-oc-failed { background: var(--failed-bg); }
.counter-sep { width: 2px; background: var(--border); margin: 0 4px; border-radius: 1px; }
.progress { position: relative; margin-top: 10px; height: 22px; background: #e6e9ee; border-radius: 9px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #1e7d4a, #34a36a); transition: width .4s; }
/* The label sits on a light pill so it stays readable over both the filled and the empty part of the bar. */
.progress-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.progress-label span { background: rgba(255, 255, 255, .92); color: #111; font-size: 12px; font-weight: 600; line-height: 16px; padding: 1px 10px; border-radius: 8px; }

.statistics-drawer { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows .25s ease, visibility .25s; }
.statistics-drawer.expanded { grid-template-rows: 1fr; visibility: visible; }
.statistics-inner { min-height: 0; overflow: hidden; }
.statistics-toggle { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; margin: 12px auto 0; padding: 6px 18px; border: 1px solid #b8cce7; border-radius: 24px; background: #eef4fc; color: #184d9b; font-size: 13px; font-weight: 600; }
.statistics-toggle:hover { background: #dfeafb; border-color: #739bce; }
.statistics-arrow { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #dce8f8; transition: transform .25s ease; }
.statistics-toggle[aria-expanded=true] .statistics-arrow { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .statistics-drawer, .statistics-arrow { transition: none; } }
.stats-coverage { width: min(100%, 640px); }
.stats-basis, .stats-footnote { font-size: 12px; color: var(--muted); line-height: 1.6; }
.stats-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; margin-top: 16px; }
.stats-block { min-width: 0; }
.stats-block h3 { margin: 0 0 8px; }
.stats-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.stats-groups .stats-scroll { height: 260px; overflow-y: auto; }
.stats-block table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stats-block th, .stats-block td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.stats-block thead th { background: #eef1f5; color: var(--muted); font-weight: 600; }
.stats-block th:first-child { text-align: left; }
.stats-block th { cursor: default; }
.stats-block tbody th { font-weight: 500; position: static; background: transparent; }
.stats-block tbody tr:last-child > * { border-bottom: 0; }
.stats-meter { width: 100%; min-width: 80px; height: 4px; background: #e6e9ee; margin-top: 5px; border-radius: 2px; overflow: hidden; }
.stats-meter span { display: block; height: 100%; }
.stats-meter .oc-ready { background: var(--ready-bg); }
.stats-meter .oc-review { background: var(--review-bg); }
.stats-meter .oc-notfound { background: var(--notfound-bg); }
.stats-met { color: #17603a; font-weight: 600; }
.stats-unmet { color: #8c1d16; font-weight: 600; }
.stats-ready { color: #17603a; font-weight: 700; }
.stats-review { color: #805600; font-weight: 700; }
.stats-notfound { color: #596273; font-weight: 700; }
.stats-block tbody th { font-weight: 600; }
.stats-groups thead th:nth-last-child(4) { color: #17603a; }
.stats-groups thead th:nth-last-child(3) { color: #805600; }
.stats-groups thead th:nth-last-child(2) { color: #596273; }

.pipeline h2 { margin-bottom: 0; }
.pipeline-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 5px; }
.pipeline-heading button { padding: 4px 9px; font-size: 11px; }
.pipeline-intro { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.pipeline-phases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }
.pipeline-phase, .pipeline-details { --phase-color: #426b9f; --phase-tint: #eef4fb; }
.pipeline-phase { position: relative; min-width: 0; }
.phase-search { --phase-color: #9b721e; --phase-tint: #fff7e5; }
.phase-copy { --phase-color: #7555b4; --phase-tint: #f4f0fb; }
.phase-decision { --phase-color: #297751; --phase-tint: #eef8f2; }
.pipeline-phase:not(:last-child)::after { content: '→'; position: absolute; right: -18px; top: 28px; color: #7a879a; font-size: 16px; }
.phase-selector { width: 100%; height: 100%; padding: 10px; text-align: left; border: 1px solid var(--border); border-top: 3px solid var(--phase-color); border-radius: 6px; background: #fff; }
.phase-selector:hover { background: var(--phase-tint); }
.phase-selector[aria-pressed=true] { background: var(--phase-tint); border-color: var(--phase-color); }
.phase-heading { display: flex; align-items: center; gap: 8px; }
.phase-number { display: grid; place-items: center; flex-shrink: 0; width: 25px; height: 25px; border-radius: 50%; background: var(--phase-tint); color: var(--phase-color); font-size: 11px; font-weight: 700; }
.phase-range { display: block; font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.phase-title { font-size: 13px; font-weight: 600; }
.phase-purpose { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; margin: 7px 0 0; }
.phase-status { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 7px; font-size: 11px; }
.phase-status b { color: var(--accent); }
.phase-active .phase-selector { box-shadow: inset 0 0 0 1px #b6cdec; }
.pipeline-details { margin-top: 12px; border: 1px solid var(--phase-color); border-radius: 6px; }
.detail-heading { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--phase-tint); border-radius: 5px 5px 0 0; }
.detail-heading h3 { font-size: 12px; margin: 0; }
.detail-heading > span { font-size: 11px; color: var(--phase-color); }
.phase-steps { list-style: none; padding: 10px; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; }
.pipeline-step { position: relative; display: flex; align-items: flex-start; gap: 6px; padding: 4px; border-radius: 4px; min-width: 0; }
.pipeline-step:not(:last-child)::after { content: '→'; position: absolute; right: -13px; top: 8px; color: #7a879a; }
.pipeline-step.active { background: var(--processing-bg); }
.step-number { display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; color: var(--phase-color); background: var(--phase-tint); font-size: 10px; font-weight: 700; border-radius: 3px; }
.step-content { min-width: 0; flex: 1; }
.step-title { font-size: 12px; font-weight: 600; padding-right: 17px; }
.step-purpose { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin: 4px 0 5px; }
.step-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; font-size: 10.5px; color: var(--muted); }
.agent-label { color: #69459f; }
.step-count { color: var(--accent); font-weight: 600; white-space: nowrap; }
.pipeline .await { color: var(--awaiting-fg); background: var(--awaiting-bg); padding: 1px 5px; border-radius: 3px; font-size: 10.5px; }
.pipeline-step .info { position: absolute; top: 4px; right: 0; width: 15px; height: 15px; padding: 0; border-radius: 50%; border: 1px solid #9aa6b8; color: var(--muted); font: italic 700 10px/13px Georgia, serif; cursor: help; }
.pipeline-step .info:hover, .pipeline-step .info:focus-visible { background: var(--text); color: #fff; }
.pipeline-step .tip { display: none; position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: min(340px, 80vw); padding: 10px; border-radius: 6px; background: var(--text); color: #fff; font-size: 12px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.pipeline-step .info:hover + .tip, .pipeline-step .info:focus-visible + .tip { display: block; }
.pipeline-step:last-child .tip { left: auto; right: 0; }
.phase-loop { margin: 0; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 11px; line-height: 1.4; color: #67583c; }
.phase-loop b { color: #765511; }
@media (max-width: 900px) { .pipeline-phases { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .pipeline-phase::after, .pipeline-step::after { display: none; } }
@media (max-width: 480px) { .phase-title { font-size: 12px; } .phase-selector { padding: 8px; } .phase-heading { gap: 5px; } .phase-number { width: 20px; height: 20px; } .phase-steps { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
.queue-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.filters select, .filters input { font: inherit; padding: 4px 6px; border: 1px solid #b8bfcb; border-radius: 4px; }
.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--border); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 6px 8px; border-bottom: 1px solid #e8ebef; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #eef1f5; cursor: pointer; white-space: nowrap; user-select: none; z-index: 1; }
th[aria-sort=ascending]::after { content: " ▲"; font-size: 10px; }
th[aria-sort=descending]::after { content: " ▼"; font-size: 10px; }
th.num, td.num { text-align: right; }
td.wide { min-width: 220px; max-width: 360px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f3f7fd; }
tbody tr.selected { background: #e3edfb; }
td ul { margin: 0; padding-left: 16px; }
.code { font-family: ui-monospace, Consolas, monospace; }
.empty { padding: 20px; text-align: center; color: var(--muted); }

.chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.st-pending { background: var(--pending-bg); color: var(--pending-fg); }
.st-processing { background: var(--processing-bg); color: var(--processing-fg); }
.st-awaiting { background: var(--awaiting-bg); color: var(--awaiting-fg); }
.st-completed { background: var(--completed-bg); color: var(--completed-fg); }
.st-failed { background: var(--failed-bg); color: var(--failed-fg); }
.oc-ready { background: var(--ready-bg); color: var(--ready-fg); }
.oc-review { background: var(--review-bg); color: var(--review-fg); }
.oc-notfound { background: var(--notfound-bg); color: var(--notfound-fg); }
.oc-failed { background: var(--danger); color: #fff; }

/* State column: outlined + icon while in progress, solid colour once final. */
.state { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.state.progress { background: #fff; color: var(--pending-fg); border: 1.5px solid #9aa6b8; }
.state.progress.awaiting { color: var(--awaiting-fg); border-color: #c79a2a; }
.state.final { border: 1.5px solid transparent; }
.ico { display: inline-block; width: 11px; height: 11px; flex: none; }
.ico.spin { border: 2px solid #9dbdf0; border-top-color: var(--processing-fg); border-radius: 50%; animation: spin .9s linear infinite; }
.ico.clock { border: 1.5px solid currentColor; border-radius: 50%; position: relative; }
.ico.clock::after { content: ""; position: absolute; left: 3.5px; top: 1px; width: 1.5px; height: 4px; background: currentColor; }
.ico.wait { background: currentColor; clip-path: polygon(0 0, 100% 0, 55% 50%, 100% 100%, 0 100%, 45% 50%); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ico.spin { animation: none; } }

td.why { min-width: 220px; max-width: 360px; }
.hide-why .why, .hide-actions .col-actions { display: none; }
/* Not ".actions": that class styles the toolbar (display: flex) and would turn these cells into flex boxes. */
td.col-actions { white-space: nowrap; text-align: right; }
.btn-icon { flex: none; }
.row-requeue, .bulk-requeue { display: inline-flex; align-items: center; gap: 6px; }
.row-requeue { font-size: 12px; padding: 3px 10px 3px 8px; }
.row-requeue .btn-icon { width: 14px; height: 14px; }
.tab-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; }
.oc-review-bar { background: #fdf5e0; border-color: #ecd28f; }
.proc-bar { background: #f3f7fd; border-color: #c9d8ee; flex-direction: column; align-items: stretch; gap: 6px; }
.proc-progress { display: flex; align-items: center; gap: 10px; }
.proc-progress .progress { flex: 1; margin-top: 0; }
.progress.small { height: 18px; }
.progress.small .progress-label span { font-size: 11.5px; line-height: 14px; }
.warn-text { color: #8a5a00; }
.oc-notfound-bar { background: #f1f2f4; border-color: #d3d6dc; }
.bulk-requeue { font-weight: 600; padding: 6px 14px 6px 11px; }
.oc-review-bar .bulk-requeue { background: var(--review-bg); border-color: #d9a93a; color: var(--review-fg); }
.oc-review-bar .bulk-requeue:hover:not(:disabled) { background: #eab73f; }
.oc-notfound-bar .bulk-requeue { background: var(--notfound-bg); border-color: var(--notfound-bg); color: var(--notfound-fg); }
.oc-notfound-bar .bulk-requeue:hover:not(:disabled) { background: #575d68; }
td.srcs { min-width: 210px; max-width: 340px; }
.srcgrp { display: flex; flex-wrap: wrap; gap: 3px 4px; align-items: baseline; margin: 1px 0; font-size: 11.5px; line-height: 1.5; }
.srcgrp .lvl { font-weight: 700; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-right: 2px; }
.srcgrp .none { font-size: 11px; }
.src { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 9px; border: 1px solid var(--border); background: #f6f7f9; white-space: nowrap; }
.src .vi { font-weight: 700; }
.src.v-selected { background: #dcf1e5; border-color: #8fcbab; color: #145c35; }
.src.v-draft { background: #fdf0cf; border-color: #e3c06b; color: #7a5400; }
.src.v-rejected { background: #fbe9e9; border-color: #e6b3b3; color: #8c2626; }
.src.v-pending { color: var(--muted); }
.copy-peek { position: relative; display: inline-flex; vertical-align: middle; margin-right: 6px; padding: 4px; border-radius: 4px; color: #3d5a80; cursor: help; }
.copy-peek:hover, .copy-peek:focus-visible { background: #e8eef7; }
.copy-pop { display: none; position: absolute; z-index: 30; right: 0; top: calc(100% + 4px); width: 380px; max-height: 360px; overflow: auto;
  padding: 10px 12px; text-align: left; white-space: normal; font-size: 12.5px; line-height: 1.45; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); cursor: auto; }
.copy-pop p { margin: 0 0 6px; }
.copy-pop ul { margin: 0; padding-left: 18px; }
.copy-peek:hover .copy-pop, .copy-peek:focus .copy-pop { display: block; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-review { font-size: 12px; padding: 3px 9px; }
.rerun-dialog { width: min(590px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  padding: 22px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25); }
.rerun-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.rerun-dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 86px); }
.rerun-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rerun-head h2 { margin: 0; font-size: 19px; }
.rerun-options { margin: 14px 0; padding: 0 3px 3px; border: 0; display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 0; }
.rerun-head, .rerun-note, .rerun-next, .rerun-footer { flex-shrink: 0; }
.rerun-legend { margin: 0 0 1px; font-weight: 600; }
.rerun-options > * { flex-shrink: 0; }
.rerun-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.rerun-option:has(input:checked) { border-color: #6394d9; background: #f1f6fe; }
.rerun-option:has(input:focus-visible) { outline: 2px solid #2563eb; outline-offset: 2px; }
.rerun-option:has(input:disabled) { background: #f7f8fa; color: var(--muted); cursor: default; }
.rerun-option input { margin: 3px 0 0; flex: none; }
.rerun-option strong { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; font-size: 14px; }
.rerun-option small { font-size: 11px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.rerun-option span span { display: block; margin-top: 4px; font-size: 12px; line-height: 1.5; }
.rerun-field { padding: 0 12px 4px 36px; }
.rerun-field label { display: block; font-size: 12px; margin-bottom: 5px; }
.rerun-field select { width: 100%; padding: 7px; }
.rerun-note { background: #fdf5e0; border-radius: 7px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.rerun-note p { margin: 3px 0 0; }
.rerun-next { font-size: 12px; color: var(--muted); line-height: 1.5; }
.rerun-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.json-dialog[open] { width: min(1000px, calc(100vw - 32px)); display: flex; flex-direction: column; }
.json-body { flex: 1; min-height: 0; overflow: auto; margin: 12px 0 0; padding: 12px; background: #f7f8fa; border: 1px solid var(--border); border-radius: 7px;
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulk-controls { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-editor input { width: 100%; min-width: 90px; font: inherit; font-size: 12px; padding: 3px 5px; border: 1px solid #b8bfcb; border-radius: 4px; }
.site-editor .remove-site { padding: 2px 8px; }
.add-site { margin: 4px 0 10px; font-size: 12px; }
.tab-action { display: flex; flex: 1 1 100%; align-items: center; justify-content: space-between; gap: 12px; }
.oc-ready-bar { background: #e8f5ee; border-color: #b5dcc5; }
.oc-ready-bar .bulk-requeue { background: var(--ready-bg); border-color: var(--ready-bg); color: var(--ready-fg); }
.oc-ready-bar .bulk-requeue:hover:not(:disabled) { background: #176a3d; }
.queue-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.queue-tabs [role=tab] { border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; padding: 7px 14px; font-size: 13px; cursor: pointer; }
.queue-tabs [role=tab][aria-selected=true] { background: #fff; border-color: var(--border); font-weight: 600; margin-bottom: -1px; }
.queue-tabs .tab-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 9px; background: #e6e9ee; font-size: 11.5px; text-align: center; }
.why-list { margin: 0; padding-left: 14px; }
.why-list li { white-space: normal; overflow-wrap: anywhere; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Actions stay visible at the right edge of the horizontally scrolling grid. */
#queue th.col-actions, #queue td.col-actions { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -6px 0 6px -6px rgba(0, 0, 0, .25); }
#queue td.col-actions:has(.copy-peek:hover, .copy-peek:focus) { z-index: 5; }

.mode-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; cursor: help; }
.mode-badge.external { background: #f3e8ff; color: #4c1d95; border: 1px solid #c4b5fd; }
.mode-badge.internal { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.icon-button { padding: 5px 7px; line-height: 0; }

.legend summary { cursor: pointer; font-weight: 600; }
.legend-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.4fr); gap: 20px; margin-top: 8px; }
.legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; margin: 0; }
.legend dd { margin: 0; color: var(--muted); }
.legend-steps { margin: 0; padding-left: 20px; }
.legend-steps li { margin-bottom: 4px; }
.legend-steps b { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.st-Succeeded { color: var(--completed-fg); font-weight: 600; }
.st-Redirected { color: var(--processing-fg); font-weight: 600; }
.st-Skipped { color: var(--muted); }
.st-Failed { color: var(--failed-fg); font-weight: 600; }

@media (max-width: 1100px) {
  .legend-grid { grid-template-columns: 1fr; }
}

/* ---------- drawers (item review + settings) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 9; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(1180px, 96vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.18); z-index: 10; display: flex; flex-direction: column;
}
.drawer-head { display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); background: #f7f8fa; }
.drawer-head h2 { font-size: 16px; margin-right: auto; }
.drawer-body { overflow: auto; padding: 14px 18px 40px; }
.drawer-body h3 { margin-top: 18px; font-size: 14px; }
.drawer table { font-size: 12px; }
.drawer td { word-break: break-word; }
.facts-row { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; padding: 10px 12px; background: #f7f8fa; border: 1px solid var(--border); border-radius: 8px; }
.facts-row .muted { margin-right: 4px; }
.requeue { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.pending-box { margin-top: 10px; padding: 8px 12px; border: 1.5px dashed #c79a2a; border-radius: 8px; background: #fffaf0; }
.pending-box ul { margin: 4px 0 0; }
.warn { color: var(--awaiting-fg); font-weight: 600; }
.narrative { margin: 0; padding: 10px 12px; list-style: none; font-size: 13px; background: #fbfcfd; border: 1px solid var(--border); border-radius: 8px; }
.narrative li { padding: 3px 0; white-space: pre-wrap; }
.narrative li.sub { padding-left: 18px; color: #394253; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.tl-step { position: relative; margin: 0 0 12px; }
.tl-step::before { content: ""; position: absolute; left: -25px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #9aa6b8; }
.tl-Succeeded::before { border-color: var(--completed-fg); background: var(--completed-bg); }
.tl-Redirected::before { border-color: var(--processing-fg); background: var(--processing-bg); }
.tl-Failed::before { border-color: var(--failed-fg); background: var(--failed-bg); }
.tl-step article { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fff; }
.tl-step header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-step h4 { margin: 0; font-size: 13.5px; font-family: ui-monospace, Consolas, monospace; }
.tl-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #eef1f5; font-size: 11px; font-weight: 700; }
.tl-time { margin-left: auto; font-size: 12px; }
.tl-desc { margin: 6px 0 2px; color: var(--muted); font-size: 12px; }
.tl-summary { margin: 2px 0 6px; font-weight: 600; }
.tl-findings { border-top: 1px dashed var(--border); padding-top: 8px; }
.tl-round > details { border: 1px solid #e3cf9e; border-left: 4px solid #d9a93a; border-radius: 8px; background: #fdfaf2; }
.tl-round > details > summary { cursor: pointer; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 13px; }
.tl-round > details[open] > summary { border-bottom: 1px solid #e3cf9e; }
.tl-round .tl-num { width: auto; padding: 0 6px; border-radius: 11px; background: #f3e3b8; }
.tl-round .tl-outcome { flex-basis: 100%; font-weight: 600; }
.timeline.nested { margin: 10px 10px 4px 22px; }
.chip.st-Succeeded { background: var(--completed-bg); color: var(--completed-fg); }
.chip.st-Redirected { background: var(--processing-bg); color: var(--processing-fg); }
.chip.st-Skipped { background: var(--pending-bg); color: var(--pending-fg); }
.chip.st-Failed { background: var(--failed-bg); color: var(--failed-fg); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 4px 0; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv ul, .cands, .dropped, .urls { margin: 0; padding-left: 18px; }
.tag { display: inline-block; padding: 0 5px; margin: 1px 0; border-radius: 4px; background: #eef1f5; font-size: 12px; }
.sub-h { margin: 8px 0 2px; font-weight: 600; font-size: 12.5px; }
.dropped li { color: var(--failed-fg); }
.cand { border-left: 3px solid #e3e7ed; padding: 4px 0 4px 10px; margin: 8px 0; }
.cand-h { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.more-text { margin: 4px 0; }
.more-text summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }
pre.src { white-space: pre-wrap; background: #f7f8fa; border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 12px; max-height: 320px; overflow: auto; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs figure, .pair figure { margin: 0; text-align: center; font-size: 11.5px; color: var(--muted); }
.thumb img { display: block; width: 140px; height: 140px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.thumbs.small .thumb img, .pair.small .thumb img { width: 84px; height: 84px; }
.thumb.missing { display: inline-grid; place-items: center; width: 140px; min-height: 60px; border: 1px dashed var(--border); border-radius: 6px; font-size: 12px; padding: 4px; word-break: break-all; }
.pair { display: flex; gap: 12px; align-items: flex-start; margin: 6px 0; }
.pairs { display: flex; flex-wrap: wrap; gap: 12px; }
.pair.small { flex-direction: row; gap: 4px; align-items: center; }
table.mini { margin: 6px 0; }
table.mini th { position: static; cursor: default; }
tr.removed td { background: #fdf2f1; }
td.quote { font-style: italic; color: #394253; }
.copy-preview { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; background: #fffef9; font-size: 13.5px; }

/* settings */
.tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--border); background: #f7f8fa; }
.tabs [role=tab] { border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; padding: 8px 14px; }
.tabs [role=tab][aria-selected=true] { background: #fff; border-color: var(--border); font-weight: 600; margin-bottom: -1px; }
.pane h4 { margin: 12px 0 4px; }
.desc { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; max-width: 110ch; }
.field { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; font-size: 12.5px; }
.field input, .field textarea { font: inherit; padding: 5px 7px; border: 1px solid #b8bfcb; border-radius: 4px; }
.field.locked input { background: #f1f3f6; color: var(--muted); }
.lock { vertical-align: -2px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.raw { margin-top: 16px; }
.raw summary { cursor: pointer; font-weight: 600; }
.prompt-editor { width: 100%; font: 12px/1.45 ui-monospace, Consolas, monospace; padding: 8px; border: 1px solid #b8bfcb; border-radius: 6px; }
.prompt-fixed { white-space: pre-wrap; font: 12px/1.45 ui-monospace, Consolas, monospace; padding: 8px; background: #f3f4f6; border: 1px solid #d3d6dc; border-radius: 6px; }
.raw textarea { width: 100%; font: 12px/1.45 ui-monospace, Consolas, monospace; padding: 8px; border: 1px solid #b8bfcb; border-radius: 6px; }
.row-actions { display: flex; gap: 8px; margin: 8px 0; }
.level-order-editor { border: 1px solid var(--border); border-radius: 6px; padding: 8px; max-width: 520px; min-width: 250px; }
.order-summary { cursor: pointer; color: var(--accent); line-height: 1.6; }
.order-inherit { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.order-options { margin-top: 6px; }
.order-row { display: flex; align-items: center; gap: 5px; padding: 3px 0; }
.order-row label { display: flex; align-items: center; gap: 7px; flex: 1; }
.order-row button { padding: 2px 8px; }
.level-order-editor .excluded-levels { font-size: 12px; margin: 6px 0 0; }

/* Long "what is happening" sentences: 3 lines, full text in the tooltip. */
.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rules-version { font-size: 12px; white-space: nowrap; }
.topbar .rules-version { color: #c3cddc; }
label.button.disabled, a.button[aria-disabled="true"] { opacity: .5; pointer-events: none; }
