/* ----------------------------------------------------------------------- *
 * automatic-paperscan dashboard — light theme
 * ----------------------------------------------------------------------- */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-soft: #5b6472;
  --line: #e3e6eb;
  --line-strong: #cbd1da;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --added: #15803d;
  --added-bg: #e7f6ec;
  --removed: #b91c1c;
  --removed-bg: #fdeaea;
  --changed: #b45309;
  --changed-bg: #fdf3e2;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
}

body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* -- top bar + tabs ----------------------------------------------------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 18px 4px;
}
.brand-logo { font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-sub { color: var(--ink-soft); font-size: 12px; }

.tabbar {
  display: flex; gap: 2px; padding: 0 12px;
  overflow-x: auto;
}
.tab {
  appearance: none; border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--ink-soft);
  padding: 9px 16px; margin-top: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: 9px 9px 0 0; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--bg); color: var(--accent);
  border-color: var(--line); border-bottom: 2px solid var(--bg);
  margin-bottom: -1px;
}
.tab .tab-ico { font-size: 14px; }

/* -- content shell ------------------------------------------------------ */
.content { flex: 1 1 auto; overflow: auto; padding: 18px; }
.loading { color: var(--ink-soft); padding: 40px; text-align: center; }
.error-box {
  background: var(--removed-bg); color: var(--removed);
  border: 1px solid #f3c2c2; border-radius: 8px; padding: 12px 14px;
}

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 4px; font-size: 16px; }
.panel .sub { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 12px; }

.layout-split { display: grid; grid-template-columns: 270px 1fr; gap: 16px; height: 100%; }
.sidebar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; overflow: auto; align-self: start; max-height: calc(100vh - 130px);
}
.sidebar h3 { margin: 6px 8px 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--ink-soft); }
.list-item {
  display: block; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.list-item:hover { background: var(--bg); }
.list-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent);
  border-color: #cfe0fd; font-weight: 600; }
.list-item .meta { display: block; color: var(--ink-soft); font-size: 11.5px; font-weight: 400; }

/* -- controls ----------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="text"] {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px;
  font-size: 13px; font-family: var(--sans); background: #fff; color: var(--ink);
}
.toolbar input[type="search"] { min-width: 240px; }
.btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.muted { color: var(--ink-soft); font-size: 12.5px; }
.teaching-panel .pipeline-control-fields { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.teaching-panel select, .teaching-panel textarea { max-width: 100%; min-width: 0; }
.teaching-panel > textarea { width: 100%; padding: 10px; border: 1px solid var(--line-strong);
  border-radius: 7px; font: 13px var(--sans); }
.teaching-panel > h3 { margin-top: 20px; }
.teaching-panel > [role="status"] { overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 600; background: var(--accent-soft); color: var(--accent); }

/* -- data grid ---------------------------------------------------------- */
.grid-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px;
  max-height: calc(100vh - 250px); background: #fff; }
table.grid { border-collapse: collapse; font-size: 12.5px; width: max-content; min-width: 100%; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 6px 10px; text-align: left; vertical-align: top;
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.grid th {
  position: sticky; top: 0; z-index: 2; background: #f1f3f7;
  font-weight: 700; white-space: nowrap; cursor: default;
}
table.grid tbody tr:hover td { background: #fafbfc; }
table.grid td.expand { white-space: normal; }
.rownum { color: var(--ink-soft); font-variant-numeric: tabular-nums;
  background: #f7f8fa !important; position: sticky; left: 0; z-index: 1; }

.colmenu { position: relative; }
.colmenu-pop {
  position: absolute; right: 0; top: 38px; z-index: 10; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px;
  max-height: 320px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 240px;
}
.colmenu-pop label { display: flex; gap: 8px; align-items: center; padding: 4px 6px;
  font-size: 12.5px; border-radius: 6px; }
.colmenu-pop label:hover { background: var(--bg); }

/* -- markdown ----------------------------------------------------------- */
.markdown { background: #fff; }
.markdown h1 { font-size: 22px; margin: 6px 0 14px; }
.markdown h2 { font-size: 18px; margin: 22px 0 10px; border-bottom: 1px solid var(--line);
  padding-bottom: 5px; }
.markdown h3 { font-size: 15px; margin: 18px 0 8px; }
.markdown p, .markdown li { font-size: 14px; }
.markdown code { font-family: var(--mono); background: var(--bg); padding: 1px 5px;
  border-radius: 5px; font-size: 12.5px; }
.markdown pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px;
  overflow: auto; }
.markdown pre code { background: transparent; color: inherit; padding: 0; }
.markdown table { border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--line-strong); padding: 6px 10px; }
.markdown blockquote { border-left: 3px solid var(--line-strong); margin: 10px 0;
  padding: 2px 14px; color: var(--ink-soft); }
.markdown img { max-width: 100%; }

/* -- pipeline operator view --------------------------------------------- */
:root {
  --ph-ingest: #2563eb;   --ph-ingest-bg: #e8f0fe;
  --ph-abstract: #15803d; --ph-abstract-bg: #e7f6ec;
  --ph-fulltext: #7c3aed; --ph-fulltext-bg: #f0e9fd;
  --ph-merge: #b45309;    --ph-merge-bg: #fdf3e2;
  --ph-report: #0e7490;   --ph-report-bg: #e0f2f5;
}
[data-phase="ingest"]   { --ph: var(--ph-ingest);   --ph-bg: var(--ph-ingest-bg); }
[data-phase="abstract"] { --ph: var(--ph-abstract); --ph-bg: var(--ph-abstract-bg); }
[data-phase="fulltext"] { --ph: var(--ph-fulltext); --ph-bg: var(--ph-fulltext-bg); }
[data-phase="merge"]    { --ph: var(--ph-merge);    --ph-bg: var(--ph-merge-bg); }
[data-phase="report"]   { --ph: var(--ph-report);   --ph-bg: var(--ph-report-bg); }

.flow-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.flow-legend-item { display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-soft); }
.flow-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ph);
  border: 1px solid rgba(0,0,0,.08); }

.pipeline-control-panel { padding: 14px 18px; }
.pipeline-control-head { display: flex; justify-content: space-between; gap: 16px; }
.pipeline-control-fields { display: grid; grid-template-columns: minmax(240px, 1fr) auto minmax(160px, 220px) minmax(190px, 260px) auto;
  align-items: end; gap: 10px; }
.pipeline-control-field { display: flex; min-width: 0; flex-direction: column; gap: 4px;
  color: var(--ink-soft); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.pipeline-control-field select { width: 100%; min-height: 36px; border: 1px solid var(--line-strong);
  border-radius: 7px; padding: 6px 9px; background: #fff; color: var(--ink); font: 13px var(--sans); }
.pipeline-control-fields > .btn { min-height: 36px; white-space: nowrap; }
.pipeline-control-notice { margin-top: 10px; color: var(--ink-soft); font-size: 12px; }
.pipeline-control-notice[data-tone="warning"] { color: var(--changed); }
.pipeline-control-panel .error-box { margin-top: 10px; }
.pipeline-job-summary { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.pipeline-job-main { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.pipeline-job-message { margin-top: 4px; color: var(--ink-soft); font-size: 12px; }

.pipeline-error-panel { padding: 14px 18px; border-color: #e8b4b4; }
.pipeline-error-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; }
.pipeline-error-head h2 { margin: 0; color: var(--removed); font-size: 17px; }
.pipeline-error-count { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 11px; }
.pipeline-error-list { max-height: 420px; margin-top: 10px; overflow: auto;
  border-top: 1px solid var(--line); }
.pipeline-error-empty { padding: 14px 0 2px; color: var(--ink-soft); font-size: 12px; }
.pipeline-error-entry { padding: 11px 0; border-bottom: 1px solid var(--line); }
.pipeline-error-entry:last-child { border-bottom: 0; }
.pipeline-error-entry-head { display: flex; align-items: center; gap: 8px; }
.pipeline-error-index { display: inline-flex; flex: none; width: 20px; height: 20px;
  align-items: center; justify-content: center; border-radius: 50%;
  background: var(--removed-bg); color: var(--removed); font-size: 10px; font-weight: 800; }
.pipeline-error-meta { min-width: 0; flex: 1; color: var(--ink-soft); font-size: 11px;
  overflow-wrap: anywhere; }
.pipeline-error-copy { flex: none; min-height: 30px; padding: 4px 9px; }
.pipeline-error-command { display: block; margin: 7px 0 0 28px; color: var(--ink-soft);
  font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipeline-error-message { margin: 7px 0 0 28px; max-height: 240px; overflow: auto;
  border: 1px solid #f0cccc; border-radius: 6px; padding: 9px 10px;
  background: #fff8f8; color: #6f2020; font: 11px/1.45 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; }

.pipeline-heading { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 18px 0 10px; }
.pipeline-heading h2 { margin: 0; font-size: 17px; }
.pipeline-heading .sub { color: var(--ink-soft); font-size: 12px; }
.pipeline-heading .flow-legend { margin: 0; }

.pipeline-vertical { position: relative; width: min(980px, 100%); margin: 0 auto; padding: 0 0 8px 54px; }
.pipeline-vertical::before { content: ""; position: absolute; top: 28px; bottom: 28px; left: 22px;
  width: 2px; background: var(--line-strong); }
.pipeline-stage { --stage-status: var(--line-strong); position: relative; margin: 0 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--ph);
  border-radius: 8px; overflow: visible; }
.pipeline-stage::before { content: ""; position: absolute; top: 25px; left: -35px;
  width: 32px; height: 2px; background: var(--line-strong); }
.pipeline-stage[data-status="running"] { --stage-status: var(--accent); border-color: #abc8fb; }
.pipeline-stage[data-status="completed"] { --stage-status: var(--added); }
.pipeline-stage[data-status="failed"] { --stage-status: var(--removed); border-color: #efb3b3; }
.pipeline-stage[data-status="skipped"] { --stage-status: #8b94a3; }
.pipeline-stage > summary { min-height: 54px; display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 42px; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; list-style: none; }
.pipeline-stage > summary::-webkit-details-marker { display: none; }
.pipeline-stage > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pipeline-stage-number { display: inline-flex; width: 28px; height: 28px; align-items: center;
  justify-content: center; border-radius: 50%; background: var(--ph); color: #fff;
  font-size: 12px; font-weight: 800; }
.pipeline-stage-heading { min-width: 0; }
.pipeline-stage-title { font-size: 13.5px; font-weight: 750; }
.pipeline-stage-meta { display: flex; align-items: center; gap: 8px; min-width: 0;
  margin-top: 2px; color: var(--ink-soft); font-size: 10.5px; }
.pipeline-stage-meta .chip-script { max-width: 480px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.pipeline-status { display: inline-flex; min-width: 72px; justify-content: center;
  border-radius: 999px; padding: 3px 8px; background: #eef0f3; color: #626c79;
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; }
.pipeline-status.status-running, .pipeline-status.status-queued { background: var(--accent-soft); color: var(--accent); }
.pipeline-status.status-completed { background: var(--added-bg); color: var(--added); }
.pipeline-status.status-failed { background: var(--removed-bg); color: var(--removed); }
.pipeline-status.status-skipped { background: #eef0f3; color: #6f7886; }
.pipeline-progress-value { color: var(--ink-soft); font: 11px var(--mono); text-align: right; }
.pipeline-stage-body { border-top: 1px solid var(--line); padding: 12px 14px 14px; }
.pipeline-stage-summary { margin: 0 0 10px; color: var(--ink-soft); font-size: 12.5px; }
.pipeline-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pipeline-detail-label { color: var(--ink-soft); font-size: 10px; font-weight: 750;
  text-transform: uppercase; }
.pipeline-detail-block ul { margin: 4px 0 0; padding-left: 17px; }
.pipeline-detail-block li { margin: 2px 0; font-size: 12px; }
.pipeline-references { display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.pipeline-reference { border: 1px solid #c9dafe; border-radius: 6px; padding: 3px 8px;
  background: #f5f8ff; font-size: 11.5px; font-weight: 650; text-decoration: none; }
.pipeline-reference:hover { background: var(--accent-soft); }
.pipeline-progress { height: 5px; margin-top: 12px; overflow: hidden; border-radius: 3px;
  background: #edf0f4; }
.pipeline-progress-fill { display: block; width: 0; height: 100%; background: var(--stage-status);
  transition: width .2s ease; }
.pipeline-stage-message { min-height: 18px; margin-top: 6px; color: var(--ink-soft); font-size: 11.5px; }
.pipeline-stage-logs { max-height: 150px; margin-top: 8px; overflow: auto; border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; background: #f7f8fa; color: #3f4855;
  font: 10.5px/1.45 var(--mono); }
.prompt-audit-link { margin-bottom: 12px; }
.prompt-reference-badge { display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eef0f3; color: #626c79; font-size: 11px; font-weight: 650; }
.prompt-view-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 5px 0 8px; }
.prompt-view-meta .sub { margin: 0; }
.kv { margin: 4px 0; }
.kv .k { font-weight: 700; font-size: 12px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .4px; }
.kv ul { margin: 4px 0 0; padding-left: 18px; }
.chip-script { font-family: var(--mono); font-size: 12px; background: var(--bg);
  padding: 2px 7px; border-radius: 6px; }

/* -- diff --------------------------------------------------------------- */
.cards { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; min-width: 120px; }
.stat-card .n { font-size: 22px; font-weight: 800; }
.stat-card .l { color: var(--ink-soft); font-size: 12px; }
.stat-card.added .n { color: var(--added); }
.stat-card.removed .n { color: var(--removed); }
.stat-card.changed .n { color: var(--changed); }

.legend { display: flex; gap: 16px; margin: 6px 0 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.1); }
.swatch.added { background: var(--added-bg); }
.swatch.removed { background: var(--removed-bg); }
.swatch.changed { background: var(--changed-bg); }

td.cell-changed { background: var(--changed-bg); }
tr.row-added td { background: var(--added-bg); }
tr.row-removed td { background: var(--removed-bg); }
.val-old { color: var(--removed); }
.val-new { color: var(--added); font-weight: 600; }
td.cell-same { color: #9aa1ab; }
.diff-label { color: var(--ink-soft); font-size: 10.5px; margin: 0 3px 0 0; text-transform: uppercase; letter-spacing: .3px; }
.diff-title { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
td.cell-changed { background: var(--changed-bg); white-space: normal; max-width: 340px; }
.arrow-sep { color: var(--ink-soft); margin: 0 6px; }
.finding-key { font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
  white-space: normal; max-width: 380px; display: inline-block; }

/* -- ER schema diagram -------------------------------------------------- */
.er-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin-bottom: 4px; }
.er-heading h2 { margin: 0; }
.er-mode-toggle { display: inline-flex; flex: none; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.er-mode-button { min-height: 30px; padding: 4px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-soft); font: 600 12px var(--sans); cursor: pointer; }
.er-mode-button:hover { color: var(--ink); background: #fff; }
.er-mode-button.active { color: #fff; background: var(--accent); }
.er-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 10px;
  background: #fafbfc; padding: 4px; }
.er-canvas { position: relative; }
.er-lines { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none; }
.er-table {
  position: absolute; width: 236px; z-index: 2; background: var(--panel);
  border: 1px solid var(--line-strong); border-top: 3px solid var(--ph);
  border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.07); overflow: hidden;
}
.er-th {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px; background: var(--ph-bg); border: none;
  border-bottom: 1px solid var(--line); cursor: pointer; text-align: left;
}
.er-th:hover { filter: brightness(.97); }
.er-tname { font-family: var(--mono); font-weight: 700; font-size: 12.5px; color: var(--ph); }
.er-trows { font-size: 10.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.er-col { display: flex; align-items: center; gap: 7px; padding: 3px 10px; font-size: 11.5px;
  border-bottom: 1px solid #f1f3f6; }
.er-col:last-child { border-bottom: none; }
.er-col.is-pk { background: #fffdf4; }
.er-col.is-fk { background: #f6f9ff; }
.er-key { flex: none; width: 22px; font-size: 9px; font-weight: 700; text-align: center;
  border-radius: 4px; line-height: 14px; color: transparent; }
.er-key.pk { background: #fde68a; color: #92600a; }
.er-key.fk { background: #c7dbff; color: #1e40af; }
.er-cname { font-family: var(--mono); color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.er-col.is-pk .er-cname { font-weight: 700; }
.er-ref { margin-left: auto; font-size: 10px; color: var(--ink-soft); white-space: nowrap; }
.er-extra[hidden] { display: none; }
.er-more { width: 100%; padding: 6px 10px; border: 0; border-top: 1px solid #f1f3f6;
  background: #fafbfc; color: var(--accent); font: 600 10.5px var(--sans);
  text-align: left; cursor: pointer; }
.er-more:hover { background: var(--accent-soft); }
.er-example-row { min-height: 62px; display: flex; align-items: flex-start; gap: 7px;
  padding: 5px 10px; border-bottom: 1px solid #f1f3f6; }
.er-example-row:last-child { border-bottom: none; }
.er-example-row.is-pk { background: #fffdf4; }
.er-example-row.is-fk { background: #f6f9ff; }
.er-example-cell { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.er-example-row .er-key { margin-top: 2px; }
.er-example-name { color: var(--ink-soft); font-size: 9.5px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.er-example-value { color: var(--ink); font-family: var(--mono); font-size: 11px;
  line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.er-example-meaning { margin-top: 2px; color: var(--ink-soft); font-size: 9.5px;
  line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
.er-example-row.is-pk .er-example-value { font-weight: 700; }
.er-example-empty { min-height: 54px; display: flex; align-items: center; padding: 10px;
  color: var(--ink-soft); font-size: 11px; }

.er-line { fill: none; stroke: var(--line-strong); stroke-width: 1.6; }
.er-card-many { fill: var(--accent); }
.er-card-one { fill: #fff; stroke: var(--accent); stroke-width: 1.6; }
.er-card-1 { fill: var(--accent); font-size: 9px; font-weight: 700; text-anchor: middle; }
.er-line-label { fill: var(--ink-soft); font-family: var(--mono); font-size: 10px; text-anchor: middle; }
.er-line-label-bg { fill: #fafbfc; }

/* -- paper pages -------------------------------------------------------- */
.pages-strip { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0; }
.pages-strip img { height: 150px; border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer; background: #fff; }
.page-modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none;
  align-items: center; justify-content: center; z-index: 100; }
.page-modal.open { display: flex; }
.page-modal img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

.md-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 16px 0 8px; }
.md-toolbar .k { font-weight: 700; font-size: 12px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .4px; }
.variant-toggle { display: inline-flex; gap: 4px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.variant-toggle .btn { border: none; background: transparent; padding: 5px 11px; }
.variant-toggle .btn.primary { background: var(--accent); color: #fff; }
.md-host { background: #fff; }
.markdown img.md-figure { display: block; margin: 10px auto; max-width: 100%;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.markdown a[id] { scroll-margin-top: 70px; }

.fail-tag { font-family: var(--mono); font-size: 11px; color: var(--removed);
  background: var(--removed-bg); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.failure-run-picker { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.failure-run-picker label { flex: none; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.failure-run-picker select { min-width: 0; width: min(760px, 100%); padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  color: var(--ink); font: 12px var(--sans); }
.failure-run-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.failure-meta-item { min-width: 0; display: inline-flex; flex-direction: column; }
.failure-meta-label { color: var(--ink-soft); font-size: 9.5px; font-weight: 700; text-transform: uppercase; }
.failure-meta-value { max-width: 420px; overflow: hidden; color: var(--ink); font-size: 11.5px;
  line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.failure-log-kind { padding: 3px 7px; border-radius: 6px; background: var(--accent-soft);
  color: var(--accent); font-size: 10.5px; font-weight: 700; }

.empty { color: var(--ink-soft); padding: 30px; text-align: center; }
a { color: var(--accent); }

@media (max-width: 760px) {
  .content { padding: 12px; }
  .panel { padding: 14px; }
  .pipeline-control-fields { grid-template-columns: minmax(0, 1fr) auto; }
  .pipeline-control-field { grid-column: 1 / -1; }
  .pipeline-control-fields .btn.primary { justify-self: stretch; }
  .pipeline-error-head { align-items: flex-start; }
  .pipeline-error-command, .pipeline-error-message { margin-left: 0; }
  .pipeline-heading { align-items: flex-start; flex-direction: column; }
  .pipeline-vertical { padding-left: 38px; }
  .pipeline-vertical::before { left: 13px; }
  .pipeline-stage::before { left: -27px; width: 24px; }
  .pipeline-stage > summary { grid-template-columns: 30px minmax(0, 1fr) auto;
    padding: 9px 10px; }
  .pipeline-progress-value { display: none; }
  .pipeline-status { min-width: 0; }
  .pipeline-stage-meta .chip-script { max-width: 180px; }
  .pipeline-detail-grid { grid-template-columns: 1fr; gap: 8px; }
  .layout-split { grid-template-columns: 1fr; }
  .sidebar { max-height: 260px; }
}
/* Keep historical extraction tables visibly separate from current job results. */
.workspace-notice { padding: 10px 24px; background: #eef5fa; color: #234b64; border-bottom: 1px solid #d6e4ee; font-size: 13px; }
