/* Patient journey note matching — local UI. Light theme, system fonts only (no external assets). */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-2: #d0d5dd;

  --accent: #2f5bd3;
  --accent-soft: #eaf0fd;
  --accent-ink: #1d3f9e;

  --ok: #15803d;
  --ok-soft: #dcefe3;
  --warn: #b45309;
  --warn-ink: #92400e;
  --warn-soft: #fff4e0;
  --warn-line: #f5c26b;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fda29b;
  --grey-soft: #eef0f3;

  --e-reports: #475467;
  --e-cause: #c2410c;
  --e-depends: #7c3aed;
  --e-same: #0e7490;
  --e-link: #2f5bd3;
  --e-held: #d97706;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
code, pre, .mono { font-family: var(--mono); }
code { font-size: 12px; background: var(--grey-soft); padding: 0 4px; border-radius: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }
.err-text { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent) 0 50%, #7c3aed 50% 100%);
}
.brand h1 { font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 11.5px; }
.top-controls { display: flex; align-items: center; gap: 10px; }
.ds-label { color: var(--muted); font-size: 12px; }
select, input[type="text"], input[type="number"], input[type="date"], textarea {
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
  padding: 5px 8px; min-height: 30px;
}
select { padding-right: 24px; }
#dataset-select { min-width: 240px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.badge-offline { background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-line); }

.health-wrap { position: relative; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 99px; padding: 4px 11px;
  font-size: 12px; font-weight: 500; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill-ok { border-color: #a6d8b8; background: #f0faf3; color: #14532d; }
.pill-ok .pill-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(21, 128, 61, .15); }
.pill-bad { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.pill-bad .pill-dot { background: var(--danger); }
.pill-unknown .pill-dot { background: var(--faint); }
.popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
  padding: 10px 12px; font-size: 12px;
}
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 3px 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.banner-danger {
  flex: 0 0 auto; background: var(--danger); color: #fff; padding: 7px 18px; font-size: 12.5px;
}
.banner-danger strong { margin-right: 6px; }

/* ── three-column layout ─────────────────────────────────────────────── */
.layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(300px, 370px) minmax(0, 1fr);
}
.layout.wide { grid-template-columns: minmax(0, 1fr); }
.layout.wide .col-run, .layout.wide .col-pipeline { display: none; }
.col { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.col-pipeline { background: var(--panel-2); }
.col-result { border-right: 0; }
.col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 46px; flex: 0 0 auto;
}
.col-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.col-body { padding: 12px 14px 24px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.tag { font-size: 11px; color: var(--muted); background: var(--grey-soft); border-radius: 99px; padding: 1px 8px; }
.tag-synthetic { background: var(--ok-soft); color: var(--ok); }
.tag-real { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(280px, 300px) minmax(290px, 320px) minmax(0, 1fr); }
}
@media (max-width: 1099px) {
  body { height: auto; }
  .layout { display: block; }
  .col { border-right: 0; border-bottom: 1px solid var(--line); }
  .col-body { overflow: visible; }
}

/* ── run column ──────────────────────────────────────────────────────── */
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 2px 0 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; }
.events-head { margin-top: 16px; }
textarea#note-text { width: 100%; resize: vertical; line-height: 1.5; font-size: 13px; min-height: 150px; padding: 8px 10px; }
.btn-link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.btn-link:disabled { color: var(--faint); cursor: default; }
.other-notes { margin-top: 10px; font-size: 12px; }
.other-notes summary { cursor: pointer; color: var(--ink-2); }
.other-note { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--line-2); background: var(--panel-2); border-radius: 0 4px 4px 0; }
.other-note .d { color: var(--muted); font-size: 11px; }
.danger-inline {
  background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); border-radius: var(--radius-sm);
  padding: 6px 9px; font-weight: 600; font-size: 12px; margin-bottom: 10px;
}
.inline-row { display: flex; gap: 6px; }
.inline-row select { flex: 1 1 auto; min-width: 0; }
.temporary-editor { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.temporary-note { margin: 10px 0 0; padding: 8px 10px; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.temporary-note legend { color: var(--ink-2); font-weight: 600; font-size: 12px; padding: 0 4px; }
.temporary-note .field-head { align-items: center; }
.temporary-note .date-label { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; }
.temporary-note textarea { display: block; width: 100%; resize: vertical; margin-top: 3px; }
.result-meta.temporary-meta { color: var(--accent-ink); font-weight: 600; }
@media (max-width: 700px) {
  .topbar, .top-controls, .result-head, .result-tools { flex-wrap: wrap; }
  .topbar { gap: 7px; }
  #dataset-select { min-width: 0; max-width: 100%; }
  #note-select { max-width: min(240px, 50vw); }
  .tabs { overflow-x: auto; }
}

.event-list { display: flex; flex-direction: column; gap: 6px; }
.ev-card {
  display: grid; grid-template-columns: 18px 1fr; gap: 2px 8px; align-items: start;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff; cursor: pointer;
}
.ev-card:hover { border-color: var(--line-2); }
.ev-card.checked { border-color: #9db4ee; background: #f8faff; }
.ev-card.disabled { cursor: default; background: var(--panel-2); }
.ev-card input { margin: 2px 0 0; }
.ev-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; align-items: baseline; }
.ev-title { font-weight: 600; }
.ev-card > div { min-width: 0; }
.ev-date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ev-label { color: var(--ink-2); font-size: 12px; }
.ev-attrs { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.ev-window { font-size: 11.5px; color: var(--muted); }
.ev-window.known { color: var(--accent-ink); }
/* after a result: notes linked to this event + which monthly shipment each note meant (SPEC 3.6 D6) */
.ev-linked { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; padding-top: 3px; border-top: 1px dashed var(--line); }
.ev-linked-note { font-weight: 600; font-variant-numeric: tabular-nums; }
.ev-linked-choice { color: var(--accent-ink); }
.ev-type { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-radius: 3px; padding: 0 5px; margin-right: 6px; white-space: nowrap; }
.ev-type.shipment { background: #e0eaff; color: #1d3f9e; }
.ev-type.pa { background: #f3e8ff; color: #6b21a8; }
.ev-type.gap { background: var(--grey-soft); color: var(--muted); }

.run-options { display: flex; gap: 14px; align-items: center; margin: 14px 0 10px; flex-wrap: wrap; }
.opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.opt input[type="number"] { width: 70px; }
.opt-check { cursor: pointer; }
.btn, .btn-primary {
  border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-weight: 500; min-height: 30px;
  border: 1px solid var(--line-2); background: #fff;
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn-small { padding: 3px 9px; min-height: 26px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }
#run-btn { width: 100%; padding: 9px 12px; font-size: 14px; }
button:disabled { opacity: .55; cursor: default; }

/* ── pipeline timeline ───────────────────────────────────────────────── */
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.clock.live { color: var(--accent-ink); }
.run-status { font-size: 12px; margin-bottom: 10px; }
.run-status.err { color: var(--danger); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 10px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.stage { position: relative; padding-left: 28px; margin-bottom: 6px; }
.stage-dot {
  position: absolute; left: 4px; top: 9px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line-2);
}
.stage[data-state="running"] .stage-dot { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
.stage[data-state="ok"] .stage-dot { border-color: var(--ok); background: var(--ok); }
.stage[data-state="warn"] .stage-dot { border-color: var(--warn); background: var(--warn-soft); }
.stage[data-state="error"] .stage-dot { border-color: var(--danger); background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(47, 91, 211, .15); } }
@media (prefers-reduced-motion: reduce) { .stage[data-state="running"] .stage-dot { animation: none; } }
.stage details { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.stage[data-state="pending"] details { background: transparent; border-style: dashed; }
.stage[data-state="error"] details { border-color: var(--danger-line); }
.stage[data-state="warn"] details { border-color: var(--warn-line); }
.stage summary {
  list-style: none; cursor: pointer; padding: 7px 10px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 10px;
}
.stage-name { white-space: nowrap; }
.stage summary::-webkit-details-marker { display: none; }
.stage-name { font-weight: 600; font-size: 12.5px; }
.stage-sub { color: var(--muted); font-size: 11.5px; grid-column: 1 / -1; }
.stage-meta { grid-row: 1; grid-column: 2; align-self: baseline; text-align: right; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage[data-state="pending"] .stage-name { color: var(--muted); font-weight: 500; }
.stage-body { border-top: 1px solid var(--line); padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.stage-body:empty { display: none; }
.sev { font-size: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.sev:last-child { border-bottom: 0; padding-bottom: 0; }
.sev-head { display: flex; flex-wrap: wrap; gap: 3px 6px; align-items: baseline; }
.sev-msg { flex: 1 1 140px; min-width: 0; color: var(--ink-2); }
.sev-t { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sev.status-error .sev-msg { color: var(--danger); }
.sev.status-warn .sev-msg { color: var(--warn-ink); }
.sev-body { margin-top: 3px; display: flex; flex-direction: column; gap: 3px; }
.raw summary { cursor: pointer; color: var(--faint); font-size: 11px; display: inline; }
.raw pre { margin: 4px 0 0; padding: 6px 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; font-size: 11px; max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.qt { font-style: italic; color: var(--ink-2); border-left: 3px solid var(--line-2); padding-left: 7px; overflow-wrap: anywhere; }
.qt.match { border-left-color: var(--e-link); }
.clause-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.clause-text { color: var(--ink); }
.clause-row.skipped .clause-text { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-2); }
.sent-list { margin: 2px 0 0; padding-left: 18px; color: var(--ink-2); }
.sent-list li { margin: 1px 0; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mini-table th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 2px 4px; }
.mini-table td { border-bottom: 1px solid var(--line); padding: 3px 4px; vertical-align: top; font-variant-numeric: tabular-nums; }
.summary-card { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.summary-card.err { border-color: var(--danger-line); background: var(--danger-soft); }
.summary-card h3 { font-size: 12.5px; margin-bottom: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 6px; padding: 6px 8px; }
.stat .n { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); }

/* chips (cues, assertions, decisions) */
.chip {
  display: inline-flex; align-items: center; gap: 3px; border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px;
  background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; border: 1px solid transparent;
}
.chip-cue { background: #fff1e8; color: var(--e-cause); border-color: #fbd3b8; }
.chip-cue.depends_on { background: #f3edff; color: var(--e-depends); border-color: #dccbfb; }
.chip-cue.precedes, .chip-cue.same_as { background: #e8f6f8; color: var(--e-same); border-color: #b8e1e8; }
.chip-join { background: #f2f4f7; color: var(--muted); border-color: var(--line); }
.chip-date { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.chip-mod { background: var(--warn-soft); color: var(--warn-ink); border-color: #fde2b5; }
.chip-lat { background: var(--accent-soft); color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: #fde2b5; }
.chip-err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.chip-kind { background: #eef4ff; color: var(--accent-ink); }
.chip-dim { font-family: var(--mono); font-size: 10.5px; background: var(--panel-2); border-color: var(--line); color: var(--muted); }
.chip-choice { background: #eef4ff; color: var(--accent-ink); border-color: #c7d7fa; white-space: normal; line-height: 16px; padding: 1px 7px; }
.chip-choice.chip-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: #fde2b5; }
.chip-same { background: transparent; color: var(--muted); border: 1px dashed var(--line-2); }
.link-choice { font-size: 12px; color: var(--accent-ink); }
.as-occurred { background: var(--ok-soft); color: var(--ok); }
.as-ongoing { background: #e0eaff; color: var(--accent-ink); }
.as-intended, .as-conditional, .as-scheduled, .as-hypothetical { background: var(--warn-soft); color: var(--warn-ink); border-color: #fde2b5; }
.as-negated { background: var(--grey-soft); color: var(--muted); border-color: var(--line-2); }
.as-corrected { background: #f3e8ff; color: #6b21a8; }

/* ── result column ───────────────────────────────────────────────────── */
.result-head { flex-wrap: wrap; }
.result-tools { display: flex; align-items: center; gap: 6px; }
.note-pick { color: var(--muted); font-size: 12px; }
#note-select { max-width: 240px; min-height: 26px; padding-top: 2px; padding-bottom: 2px; font-size: 12px; }
.result-meta { padding: 4px 14px 0; font-size: 11.5px; min-height: 18px; }
.tabs { display: flex; gap: 2px; padding: 6px 14px 0; border-bottom: 1px solid var(--line); flex: 0 0 auto; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 7px 11px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--ink); }
.tabpanels { flex: 1 1 auto; min-height: 0; overflow: auto; }
.tabpanel { padding: 12px 14px 28px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 22px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.lg-reports::before { border-color: var(--e-reports); }
.lg-plans::before { border-color: var(--e-reports); border-top-style: dashed; }
.lg-cause::before { border-color: var(--e-cause); }
.lg-depends::before { border-color: var(--e-depends); }
.lg-same::before { border-color: var(--e-same); border-top-style: dotted; }
.lg-explains::before { border-color: var(--e-link); }
.lg-held::before { border-color: var(--e-held); border-top-style: dashed; }
.loading { color: var(--muted); padding: 20px 4px; }
.loading::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; }

/* graph */
.graph-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: #fcfcfd; overflow: auto; max-height: 68vh; }
.graph-wrap svg { display: block; }
.graph-svg text { font-family: var(--font); fill: var(--ink); }
.graph-svg .node, .graph-svg .edge, .graph-svg .elabel { transition: opacity .12s; }
.graph-svg.focus .node:not(.hl), .graph-svg.focus .edge:not(.hl), .graph-svg.focus .elabel:not(.hl) { opacity: .22; }
.graph-svg .fact-card { cursor: pointer; }
.graph-svg .card-bg { fill: #fff; stroke: var(--line-2); stroke-width: 1; }
.graph-svg .node.hl .card-bg { stroke: var(--accent); stroke-width: 1.6; }
.graph-svg .node.pinned .card-bg { stroke: var(--accent); stroke-width: 2.4; }
.graph-svg .event-card .card-bg { fill: #f8faff; stroke: #b8c8f0; }
.graph-svg .event-card.unlinked .card-bg { fill: #fafafa; stroke: var(--line-2); stroke-dasharray: 4 3; }
.graph-svg .patient-bg { fill: var(--ink); }
.graph-svg .patient-t { fill: #fff; font-weight: 600; font-size: 13px; }
.graph-svg .patient-k { fill: #cfd4dc; font-size: 10.5px; }
.graph-svg .t-title { font-weight: 600; font-size: 13px; }
.graph-svg .t-meta { font-size: 12px; fill: var(--ink-2); }
.graph-svg .t-meta-k { fill: var(--muted); }
.graph-svg .t-dim { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
.graph-svg .t-ev { font-style: italic; font-size: 12px; fill: var(--ink-2); }
.graph-svg .t-small { font-size: 10.5px; fill: var(--muted); }
.graph-svg .t-type { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; fill: var(--muted); }
.graph-svg .chip-r { stroke-width: 1; }
.graph-svg .chip-t { font-size: 10.5px; font-weight: 600; }
.graph-svg .held-bg { fill: var(--warn-soft); stroke: var(--warn-line); }
.graph-svg .held-t { fill: var(--warn-ink); font-size: 11px; }
.graph-svg .edge { fill: none; stroke-width: 1.6; }
.graph-svg .e-reports, .graph-svg .e-plans { stroke: var(--e-reports); }
.graph-svg .e-plans { stroke-dasharray: 6 4; }
.graph-svg .e-caused_by { stroke: var(--e-cause); stroke-width: 1.8; }
.graph-svg .e-depends_on, .graph-svg .e-precedes { stroke: var(--e-depends); }
.graph-svg .e-same_as { stroke: var(--e-same); stroke-dasharray: 1.5 4; stroke-linecap: round; stroke-width: 2; }
.graph-svg .e-explains { stroke: var(--e-link); stroke-width: 2.4; }
.graph-svg .e-about { stroke: var(--e-link); stroke-width: 1.4; }
.graph-svg .e-context { stroke-dasharray: 5 4; }
.graph-svg .e-held { stroke: var(--e-held); stroke-dasharray: 5 4; stroke-width: 1.6; }
.graph-svg .lbl-bg { fill: #fff; stroke-width: 1; }
.graph-svg .lbl-t { font-size: 11px; font-weight: 500; }
.graph-svg .lbl-d { font-size: 10.5px; fill: var(--muted); font-style: italic; }
.graph-svg .lbl-c { font-size: 10.5px; font-weight: 500; fill: var(--accent-ink); }
.graph-svg .t-same { font-size: 10.5px; fill: var(--muted); font-style: italic; }
/* svg chips + edge labels + arrow markers (tones) */
.graph-svg .sc-green .chip-r { fill: #dcefe3; stroke: #a6d8b8; }
.graph-svg .sc-green .chip-t { fill: #15803d; }
.graph-svg .sc-blue .chip-r { fill: #e0eaff; stroke: #b8c8f0; }
.graph-svg .sc-blue .chip-t { fill: #1d3f9e; }
.graph-svg .sc-amber .chip-r { fill: #fff4e0; stroke: #f5c26b; }
.graph-svg .sc-amber .chip-t { fill: #92400e; }
.graph-svg .sc-grey .chip-r { fill: #eef0f3; stroke: #d0d5dd; }
.graph-svg .sc-grey .chip-t { fill: #667085; }
.graph-svg .sc-purple .chip-r { fill: #f3e8ff; stroke: #e1c8fb; }
.graph-svg .sc-purple .chip-t { fill: #6b21a8; }
.graph-svg .lbl-reports .lbl-bg { stroke: #d0d5dd; }
.graph-svg .lbl-reports .lbl-t { fill: var(--e-reports); }
.graph-svg .lbl-cause .lbl-bg { stroke: #fbd3b8; fill: #fffaf6; }
.graph-svg .lbl-cause .lbl-t { fill: var(--e-cause); }
.graph-svg .lbl-depends .lbl-bg { stroke: #dccbfb; fill: #fcfaff; }
.graph-svg .lbl-depends .lbl-t { fill: var(--e-depends); }
.graph-svg .lbl-same .lbl-bg { stroke: #b8e1e8; fill: #f8fdfe; }
.graph-svg .lbl-same .lbl-t { fill: var(--e-same); }
.graph-svg .lbl-link .lbl-bg { stroke: #b8c8f0; fill: #f8faff; }
.graph-svg .lbl-link .lbl-t { fill: var(--e-link); }
.graph-svg .lbl-held .lbl-bg { stroke: var(--warn-line); fill: var(--warn-soft); }
.graph-svg .lbl-held .lbl-t { fill: var(--warn-ink); }
.graph-svg .m-reports { fill: var(--e-reports); }
.graph-svg .m-cause { fill: var(--e-cause); }
.graph-svg .m-depends { fill: var(--e-depends); }
.graph-svg .m-same { fill: var(--e-same); }
.graph-svg .m-link { fill: var(--e-link); }
.graph-svg .m-held { fill: var(--e-held); }
.sev-mark { width: 12px; flex: 0 0 12px; text-align: center; color: var(--faint); font-weight: 700; }
.sev-mark.ok { color: var(--ok); }
.sev-mark.warn { color: var(--warn); }
.sev-mark.error { color: var(--danger); }
.sev-mark.start { color: var(--accent); }

.evidence-strip { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.strip-title { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 0; }
.strip-body { padding: 4px 10px 9px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* customer tree */
pre.tree {
  margin: 0; padding: 14px 16px; background: #fcfcfd; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.5; overflow: auto; color: var(--ink); tab-size: 4;
}

/* note view */
.note-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.note-tools input { flex: 1 1 180px; max-width: 360px; }
.note-tools .muted { font-size: 12px; }
.note-list { display: grid; gap: 9px; margin-bottom: 10px; }
.note-review-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 12px; overflow-wrap: anywhere; }
summary.note-head { cursor: pointer; list-style: none; }
summary.note-head::-webkit-details-marker { display: none; }
summary.note-head::before { content: '▸'; color: var(--muted); }
.note-review-card[open] > summary.note-head::before { content: '▾'; }
.note-head .muted { font-size: 12px; }
.note-preview { width: 100%; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.note-review-content { padding: 10px 12px; border-top: 1px solid var(--line); }
.note-actions { display: flex; justify-content: flex-end; }
.note-source { margin: 2px 0 12px; }
.note-source summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.note-source[open] > summary { margin-bottom: 5px; }
.note-source .sent.no-fact { color: var(--ink-2); }
.note-body:focus-visible { outline: 2px solid var(--accent); }
.note-locate { padding: 2px 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; }
.note-locate:hover { text-decoration: underline; }
.note-head .title { font-weight: 600; }
.note-details { overflow-wrap: anywhere; margin: 0 0 8px; }
.note-details h3 { font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
.note-detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 5px 12px; flex-wrap: wrap; margin-bottom: 6px; }
.note-reading-key { margin: 0 0 7px; color: var(--muted); font-size: 12px; }
.note-provenance { grid-column: 1 / -1; font-size: 12px; }
.note-provenance summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.note-provenance dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px 14px; margin: 6px 0 0; }
.note-context-preview { margin-left: 8px; color: var(--muted); font-weight: 400; }
.note-provenance dt { color: var(--muted); }
.note-provenance dd { margin: 1px 0; }
.note-outcome { display: block; margin-top: 5px; font-size: 12px; }
.note-detail-heading select { font-size: 12px; }
.note-detail-row[hidden], .note-review-card[hidden] { display: none; }
.note-details ul { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.note-detail-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: 8px 16px; padding: 9px 12px; }
.note-detail-row + .note-detail-row { border-top: 1px solid var(--line); }
.note-detail-label { display: block; color: var(--ink-2); font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.note-detail-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.note-detail-value .muted, .note-detail-signal p { font-size: 12px; }
.note-detail-row blockquote { margin: 4px 0 0; padding-left: 7px; border-left: 2px solid var(--line-2); color: var(--ink-2); white-space: pre-wrap; }
.note-detail-signal p { margin: 3px 0 0; color: var(--muted); }
.note-pipeline-facts { margin-top: 7px; }
.note-pipeline-facts summary { cursor: pointer; color: var(--ink-2); font-size: 12px; }
.note-pipeline-facts .fact-legend { margin: 5px 0; }
.note-pipeline-facts + .note-head { margin-top: 18px; }
.fact-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fact-key {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 6px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; font-size: 12px; cursor: default; flex-wrap: wrap; max-width: 100%;
}
.fact-key .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .12); }
.fact-key.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.note-body {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  font-size: 14px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere;
}
.note-body + .note-head { margin-top: 18px; }
.sent { border-radius: 3px; }
.sent.no-fact { color: var(--faint); }
.sent.no-fact .ev { background: none !important; }
.so-tag {
  display: inline-block; font-size: 10px; line-height: 15px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--muted); background: var(--grey-soft); border-radius: 3px; padding: 0 5px; margin: 0 4px; vertical-align: 2px; white-space: nowrap;
}
mark.ev { color: var(--ink); border-radius: 3px; padding: 1px 0; transition: box-shadow .12s, opacity .12s; }
mark.ev.multi { box-shadow: inset 0 -3px 0 rgba(16, 24, 40, .25); }
.note-body.has-active mark.ev:not(.active) { opacity: .45; }
mark.ev.active { box-shadow: 0 0 0 2px var(--accent); }
.cue { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--e-cause); font-weight: 600; }
.cue.depends_on { text-decoration-color: var(--e-depends); }
.cue.precedes { text-decoration-color: var(--e-same); }
.mention { text-decoration: underline dotted; text-decoration-color: var(--e-same); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.rel-list { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.rel-list .arrow { color: var(--muted); }

/* dashboard preview */
.dash-event { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 12px; overflow: hidden; }
.dash-event-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.dash-event-head .title { font-weight: 600; }
.dash-event-body { padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 1400px) { .dash-event-body { grid-template-columns: 1fr; } }
.en-panel {
  display: flex; flex-direction: column; gap: 8px; border: 1px solid #e5e7eb; border-radius: 8px; background: #f9fafb;
  padding: 10px; font-size: 12px; line-height: 17px; color: #101828;
}
.en-sec-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #667085; margin-bottom: 3px; }
.en-sec { display: flex; flex-direction: column; gap: 6px; }
.en-row { display: flex; flex-direction: column; gap: 1px; }
.en-bold { font-weight: 600; }
.en-muted { color: #667085; }
.en-src { color: #667085; font-size: 11px; }
.en-none { color: #667085; font-size: 11.5px; font-style: italic; }
.en-possible { color: #667085; }
.en-empty { color: var(--muted); font-size: 12px; font-style: italic; }
.dash-side { font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.dash-side h4 { margin: 0 0 3px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.link-row { display: flex; flex-direction: column; gap: 2px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.link-row:last-child { border-bottom: 0; }
.en-source { border-top: 1px solid var(--line); padding-top: 5px; overflow-wrap: anywhere; }
.en-source summary, .en-choice-details summary, .dash-matches summary { cursor: pointer; }
.en-source .en-row, .en-choice-details .en-row { margin: 5px 0 4px 13px; }
.en-source .en-topics { display: block; margin-left: 13px; color: var(--muted); }
.en-source[open] .en-topics { display: none; }
.en-choice-details summary { color: var(--muted); }
.dash-matches summary { padding: 6px 0; font-weight: 600; }

/* ask */
.ask-scope { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ask-cohort { font-size: 12px; color: var(--muted); margin-top: 8px; }
.ask-cohort > button { margin: 6px 0 0; }
.ask-cohort summary, .ask-details summary, .ask-windows summary { cursor: pointer; width: fit-content; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1 1 auto; min-width: 0; min-height: 34px; font-size: 13.5px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 12px; }
.chip-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.answer-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 12px 14px; margin-top: 12px; }
.answer-q { font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.answer-q h3 { font-size: 14px; font-weight: 600; margin: 0; }
.answer-a { font-size: 14px; line-height: 1.55; margin: 6px 0 8px; white-space: pre-wrap; }
.answer-sec { margin-top: 10px; }
.answer-sec h4 { margin: 0 0 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cite { background: var(--panel-alt, #f8fafc); border-left: 2px solid var(--line-2); border-radius: 2px;
  padding: 6px 10px; margin-top: 5px; }
.cite .meta { font-size: 11px; color: var(--muted); }
.cite blockquote { margin: 2px 0; font-size: 13px; overflow-wrap: anywhere; }
.cite-link { display: inline; border: 0; padding: 2px 0; background: transparent; color: var(--accent-ink);
  font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.cite-link:hover { text-decoration: underline; }
.ask-details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; color: var(--muted); font-size: 12px; }
.ask-details .fact-chips { margin-top: 6px; }
.ask-search-meta { display: flex; flex-wrap: wrap; gap: 5px 18px; margin: 6px 0; }
.ask-search-meta div { display: flex; gap: 4px; }
.ask-search-meta dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.ask-windows { margin-top: 6px; }
.ask-windows ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 3px 12px; padding-left: 20px; }
.record-box { border: 1px dashed #b8c8f0; background: #f8faff; border-radius: 6px; padding: 8px 10px; }
.record-box h4 { color: var(--accent-ink); }
.scope-line { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.fact-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.layout.wide :is(#tab-episode,#tab-entity,#tab-dashboard) { max-width: 1200px; margin-inline: auto; }
.quality-links { display: flex; gap: 1.15rem; flex-wrap: wrap; margin-bottom: 12px; }
#dashboard-evidence { margin-top: 16px; }
#dashboard-evidence > summary { cursor: pointer; font-weight: 600; padding-block: 8px; }
