/* ==========================================================================
   BH Reporting Console - Design System
   A small token-driven system: color, type, space, radius, elevation, motion.
   Components below only consume tokens, so re-theming is a one-place change.
   ========================================================================== */

:root {
  /* Brand + semantic palette */
  --brand-700: #17385a;
  --brand-600: #1f4e78;
  --brand-500: #2f6fb0;
  --brand-050: #eaf2fb;

  --ok-600: #12784a;   --ok-050: #e7f6ee;
  --warn-600: #9a6b00; --warn-050: #fdf3dd;
  --bad-600: #c0362c;  --bad-050: #fdecea;

  /* Neutral (slate) ramp */
  --ink: #16202b;
  --ink-2: #45525f;
  --muted: #6b7885;
  --line: #e4e9ef;
  --line-2: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --bg: #f2f5f9;

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 13.5px; --fs-lg: 15px;
  --fs-xl: 18px; --fs-2xl: 24px; --fs-3xl: 28px;

  /* Space scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;

  /* Radius + elevation + motion */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --e-1: 0 1px 2px rgba(16,32,43,.06), 0 1px 3px rgba(16,32,43,.04);
  --e-2: 0 2px 6px rgba(16,32,43,.06), 0 8px 24px rgba(16,32,43,.07);
  --e-focus: 0 0 0 3px rgba(47,111,176,.28);
  --dur: .16s; --ease: cubic-bezier(.2,.6,.2,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--e-focus); border-radius: var(--r-sm); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s6);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  position: sticky; top: 0; z-index: 30;
  box-shadow: var(--e-1);
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.logo {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
  background: rgba(255,255,255,.15);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.topbar h1 { font-size: var(--fs-lg); }
.topbar .sub { font-size: var(--fs-sm); opacity: .82; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: var(--s3); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: var(--s1);
  padding: 0 var(--s5);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 72px; z-index: 20;
  overflow-x: auto;
}
.tab {
  border: 0; background: none; cursor: pointer;
  padding: var(--s4) var(--s4);
  font: inherit; font-weight: 550; color: var(--muted);
  border-bottom: 2.5px solid transparent;
  white-space: nowrap; transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ---------- Layout ---------- */
main { max-width: 1160px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }
.panel { display: none; }
.panel.active { display: block; animation: rise var(--dur) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5) var(--s5);
  margin-bottom: var(--s5);
  box-shadow: var(--e-1);
}
.card h3 { font-size: var(--fs-lg); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-head p { margin: var(--s1) 0 0; }
.card.warn-card { border-color: #f0e2bd; background: var(--warn-050); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5);
  box-shadow: var(--e-1);
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-500); opacity: .9; }
.kpi .v { font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -.02em; }
.kpi .l { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: var(--s1); }
.kpi .s { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: .02em;
  background: rgba(255,255,255,.2); color: #fff;
}
.pill.success { background: var(--ok-600); }
.pill.needs_review { background: var(--warn-600); }
.pill.failed { background: var(--bad-600); }

.badge { display: inline-block; padding: 2px 9px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 650; }
.badge.rate_code { background: var(--brand-050); color: var(--brand-600); }
.badge.alias { background: var(--ok-050); color: var(--ok-600); }
.badge.fuzzy { background: var(--warn-050); color: var(--warn-600); }
.badge.success { background: var(--ok-050); color: var(--ok-600); }
.badge.needs_review { background: var(--warn-050); color: var(--warn-600); }
.badge.failed { background: var(--bad-050); color: var(--bad-600); }

.count { font-size: var(--fs-sm); font-weight: 700; background: var(--bad-050); color: var(--bad-600); padding: 2px 10px; border-radius: var(--r-pill); margin-left: 6px; }
.count.ok { background: var(--ok-050); color: var(--ok-600); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 15px; border-radius: var(--r-md);
  font: inherit; font-size: var(--fs-md); font-weight: 600; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { border-color: #cdd6df; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-600); color: #fff; border-color: var(--brand-600); box-shadow: var(--e-1); }
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.big { padding: 13px 24px; font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--brand-050); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Fix rows (the one-click remap workflow) ---------- */
.fixrow {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: var(--s2); background: var(--surface);
}
.fixrow + .fixrow { margin-top: 0; }
.fixrow .svc { font-weight: 600; }
.fixrow .meta { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.fixrow select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font: inherit; font-size: var(--fs-md);
  min-width: 260px; max-width: 380px;
}
@media (max-width: 760px) { .fixrow { grid-template-columns: 1fr; } .fixrow select { max-width: none; width: 100%; } }

.empty-ok {
  margin: 0; padding: var(--s4); border-radius: var(--r-md);
  background: var(--ok-050); color: var(--ok-600); font-weight: 550;
}

/* ---------- Source mode tag ---------- */
.mode-tag {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  background: var(--warn-050); color: var(--warn-600); border: 1px solid #f0dca0;
}
.mode-tag.live { background: var(--ok-050); color: var(--ok-600); border-color: #bfe3cd; }

/* ---------- Source upload rows ---------- */
.src-template { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s2); }
.src-mode { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s3); }
.uprow {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: var(--s2); background: var(--surface);
}
.uprow .upinfo .svc { font-weight: 600; }
.uprow .upinfo .meta { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.upfile, .wf-upfile { font: inherit; font-size: var(--fs-sm); max-width: 240px; }
.wf-upload { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s2); }
@media (max-width: 760px) { .uprow { grid-template-columns: 1fr; } .upfile { max-width: none; width: 100%; } }

/* ---------- Audit log ---------- */
td.mono, .mono {
  font-family: var(--mono);
  font-size: var(--fs-sm); color: var(--muted); white-space: nowrap;
}

/* ---------- Banners ---------- */
#banners { max-width: 1160px; margin: 0 auto; padding: 0 var(--s5); }
#banners:not(:empty) { padding-top: var(--s4); }
.banner {
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2);
  margin-bottom: var(--s2); font-size: var(--fs-md);
}
.banner.warn { background: var(--warn-050); border-color: #f0dca0; color: #6d4d00; }
.banner.bad { background: var(--bad-050); border-color: #f2c3bd; color: var(--bad-600); }
.banner.info { background: var(--brand-050); border-color: #cfe0f5; color: var(--brand-700); }

/* pill tones reused on light surfaces (hero, filing) */
.pill.ok { background: var(--ok-600); }
.pill.warn { background: var(--warn-600); }
.pill.bad { background: var(--bad-600); }
.pill.neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ---------- Home hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: var(--s6); align-items: stretch;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s5) var(--s6); margin-bottom: var(--s5); box-shadow: var(--e-1);
}
.hero .eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.hero h2 { font-size: var(--fs-2xl); margin-top: 4px; letter-spacing: -.02em; }
.hero .hero-meta { color: var(--muted); margin-top: var(--s2); font-size: var(--fs-md); }
.hero .scaffold-tag { color: var(--warn-600); font-weight: 650; }
.hero-actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s5); }
.hero-side {
  min-width: 220px; border-left: 1px solid var(--line); padding-left: var(--s6);
  display: flex; flex-direction: column; gap: var(--s3); justify-content: center; align-items: flex-start;
}
.hero-side .l { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hero-side .due { font-size: var(--fs-lg); font-weight: 700; margin-top: 2px; }
.hero-side .v { font-weight: 600; margin-top: 2px; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: var(--s4); }
  .hero-side { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: var(--s4); }
}

/* ---------- Onboarding checklist ---------- */
.steps-progress { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 2px 10px; border-radius: var(--r-pill); margin-left: 6px; }
.steps { display: grid; gap: var(--s2); }
.step-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.step-item.active { border-color: var(--brand-500); background: var(--brand-050); }
.step-item.done .step-body .t { color: var(--muted); }
.step-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: var(--fs-sm); font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.step-item.active .step-num { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.step-item.done .step-num { background: var(--ok-600); color: #fff; border-color: var(--ok-600); }
.step-body .t { font-weight: 650; }
.step-body .d { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.step-cta { margin-left: auto; white-space: nowrap; }

/* ---------- Recent activity ---------- */
.recent { display: grid; }
.recent-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line-2); }
.recent-row:last-child { border-bottom: 0; }
.recent-period { font-weight: 600; margin-left: var(--s2); }
.recent .when { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }

/* ---------- Drag & drop upload ---------- */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface-2); padding: var(--s5); text-align: center;
  margin-bottom: var(--s3); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.dropzone.drag { border-color: var(--brand-500); background: var(--brand-050); }
.dz-inner { display: flex; flex-direction: column; gap: var(--s1); align-items: center; }
.link { color: var(--brand-600); cursor: pointer; text-decoration: underline; }

/* ---------- Insight (change vs previous) ---------- */
.insight { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.insight h4 { margin: 0 0 var(--s2); font-size: var(--fs-md); }
.num.up { color: var(--ok-600); }
.num.down { color: var(--bad-600); }

/* ---------- Search ---------- */
.search {
  padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--r-md);
  min-width: 240px; font: inherit; font-size: var(--fs-md); background: var(--surface);
}

/* ---------- Charts ---------- */
.bar-row { display: grid; grid-template-columns: 96px 1fr 72px; align-items: center; gap: var(--s3); margin: var(--s3) 0; }
.bar-track { background: var(--line-2); border-radius: var(--r-pill); height: 18px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: var(--r-pill); transition: width .55s var(--ease); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.donut-wrap { display: flex; align-items: center; gap: var(--s6); }
.legend { font-size: var(--fs-md); }
.legend div { margin: var(--s2) 0; display: flex; align-items: center; gap: var(--s2); }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Alerts / forms ---------- */
.alerts { margin: var(--s2) 0 0; padding-left: 18px; }
.alerts li { margin: var(--s1) 0; }
.alerts li.issue { color: var(--bad-600); }
.alerts li.warn { color: var(--warn-600); }

.form { display: grid; gap: var(--s4); max-width: 480px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: var(--fs-md); }
.form input, .form select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  font: inherit; font-size: var(--fs-md); background: var(--surface);
}
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.switch-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-600); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

/* ---------- Run log (console) ---------- */
.run-hero { text-align: center; }
.run-hero .muted { max-width: 580px; margin: 0 auto var(--s4); }
.runlog {
  margin: var(--s4) auto 0; max-width: 620px; text-align: left;
  font-family: var(--mono); font-size: var(--fs-sm); color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s3) var(--s4); min-height: 0;
}
.runlog:empty { display: none; }
.runlog .step { padding: 3px 0 3px 16px; position: relative; }
.runlog .step::before { content: ""; position: absolute; left: 2px; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-500); }
.runlog .step.err { color: var(--bad-600); }
.runlog .step.err::before { background: var(--bad-600); }
.runlog .done { padding: 4px 0 0; font-weight: 700; color: var(--ok-600); }
.result-actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: var(--s5); bottom: var(--s5);
  background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: var(--r-md); font-size: var(--fs-md);
  box-shadow: var(--e-2); opacity: 0; transform: translateY(12px);
  pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 60; max-width: 380px;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok-600); }
.toast.err { background: var(--bad-600); }

/* ---------- Spinner ---------- */
.spinner { width: 15px; height: 15px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Workflow canvas (n8n-style node graph)
   ========================================================================== */
.wf-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--e-1); flex-wrap: wrap;
}
.wf-toolbar-left, .wf-toolbar-right { display: flex; align-items: center; gap: var(--s3); }

.wf-stage {
  position: relative; height: calc(100vh - 240px); min-height: 460px;
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, #d7dee7 1px, transparent 0) 0 0 / 22px 22px,
    var(--surface-2);
  box-shadow: var(--e-1); touch-action: none; cursor: grab;
}
.wf-stage.panning { cursor: grabbing; }

.wf-viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.wf-edges { position: absolute; left: 0; top: 0; width: 4000px; height: 3000px; overflow: visible; pointer-events: none; }
.wf-edge { fill: none; stroke: #b7c2cf; stroke-width: 2.5; transition: stroke .2s var(--ease); pointer-events: none; }
.wf-edge.active { stroke: var(--brand-500); stroke-width: 3; }
.wf-edge.ghost { stroke: var(--brand-500); stroke-dasharray: 6 5; opacity: .8; }
.wf-edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.wf-edge-group:hover .wf-edge { stroke: var(--brand-500); }
.wf-edge-del { opacity: 0; pointer-events: none; cursor: pointer; transition: opacity var(--dur) var(--ease); }
.wf-edge-group:hover .wf-edge-del { opacity: 1; pointer-events: all; }
.wf-edge-del circle { fill: #fff; stroke: var(--bad-600); stroke-width: 1.5; }
.wf-edge-del line { stroke: var(--bad-600); stroke-width: 1.8; stroke-linecap: round; }
.wf-port.out { cursor: crosshair; }
.wf-port.out:hover { border-color: var(--brand-500); background: var(--brand-050); transform: translateY(-50%) scale(1.25); }

/* minimap */
.wf-minimap {
  position: absolute; left: var(--s3); bottom: var(--s3);
  width: 200px; height: 128px; background: rgba(255,255,255,.9);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--e-1); overflow: hidden; cursor: pointer; z-index: 6;
  backdrop-filter: blur(2px);
}
.wf-minimap svg { width: 100%; height: 100%; display: block; }
.wf-mini-node { fill: #c3ccd6; }
.wf-mini-node.sel { fill: var(--brand-500); }
.wf-mini-edge { stroke: #cbd4de; stroke-width: 1; }
.wf-mini-view { fill: rgba(47,111,176,.14); stroke: var(--brand-500); stroke-width: 1.5; }

.wf-nodes { position: absolute; left: 0; top: 0; }
.wf-node {
  position: absolute; width: 232px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--e-1); cursor: grab; user-select: none;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.wf-node:hover { box-shadow: var(--e-2); border-color: #cdd6df; }
.wf-node.dragging { cursor: grabbing; box-shadow: var(--e-2); z-index: 5; }
.wf-node.selected { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-050), var(--e-2); }
.wf-node.running { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(47,111,176,.18), var(--e-2); }

.wf-node-head { display: flex; align-items: center; gap: var(--s2); padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.wf-ico { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.wf-ico.src { background: #6b7c93; } .wf-ico.region { background: #7a5ea8; }
.wf-ico.map { background: var(--brand-500); } .wf-ico.populate { background: #2f8f6b; }
.wf-ico.validate { background: var(--warn-600); } .wf-ico.export { background: #2b6cb0; }
.wf-node-title { font-weight: 650; font-size: var(--fs-md); line-height: 1.2; }
.wf-node-kind { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.wf-status { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: #cbd4de; flex: 0 0 auto; }
.wf-status.ok { background: var(--ok-600); } .wf-status.warn { background: var(--warn-600); } .wf-status.bad { background: var(--bad-600); }
.wf-node-body { padding: 9px 12px 11px; font-size: var(--fs-sm); color: var(--ink-2); }
.wf-node-body .m { display: flex; justify-content: space-between; gap: var(--s2); padding: 1px 0; }
.wf-node-body .m b { font-variant-numeric: tabular-nums; }
.wf-node-body .idle { color: var(--muted); }

/* connection anchors */
.wf-port { position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid #b7c2cf; transform: translateY(-50%); }
.wf-port.in { left: -6px; } .wf-port.out { right: -6px; }
.wf-node.running .wf-port { border-color: var(--brand-500); }

/* inspector drawer */
.wf-inspector {
  position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 86%;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(16,32,43,.08); padding: var(--s4) var(--s5);
  overflow: auto; z-index: 8; animation: slidein var(--dur) var(--ease);
}
@keyframes slidein { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.wf-inspector-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.wf-close { padding: 5px 10px; font-size: var(--fs-sm); }
.wf-insp-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-bottom: var(--s4); }
.wf-insp-metric { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.wf-insp-metric .v { font-size: var(--fs-xl); font-weight: 700; }
.wf-insp-metric .l { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.wf-insp-section-title { font-size: var(--fs-sm); font-weight: 650; margin: var(--s3) 0 var(--s2); color: var(--ink-2); }

/* ---------- Trends (run-over-run sparklines) ---------- */
.trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); }
.trend { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4) var(--s3); background: var(--surface); }
.trend-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.trend-title { font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.trend-now { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; }
.spark { width: 100%; height: 84px; display: block; margin: var(--s1) 0; }
.trend-foot { font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.trend-foot.good { color: var(--ok-600); }
.trend-foot.bad { color: var(--bad-600); }
.trend-foot.flat { color: var(--muted); }
.trend-arrow { font-size: 10px; }

/* ---------- Small-screen responsiveness ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: var(--s3); padding: var(--s3) var(--s4); }
  .topbar h1 { font-size: var(--fs-md); }
  .topbar-right { width: 100%; justify-content: space-between; }
  /* Topbar height is variable when wrapped, so don't pin the tabs beneath a fixed offset. */
  .tabs { position: static; top: auto; padding: 0 var(--s4); }
  main { padding: var(--s4) var(--s4) var(--s7); }
  .hero { padding: var(--s4); }
  .hero-actions .btn { flex: 1 1 auto; }
  .runlog { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .bar-fill { transition: none; }
}
