/* Culprit — Blueprint/Foundry dark industrial theme.
   Tokens verbatim from @blueprintjs/colors. 2px radii, 1px-border separation,
   dense 12px chrome, system font + mono data. No display fonts, no glows. */
:root {
  --bg: #1C2127;        /* DARK_GRAY1 app bg */
  --panel: #252A31;     /* DARK_GRAY2 */
  --panel-2: #2F343C;   /* DARK_GRAY3 hover */
  --table-bg: #383E47;  /* DARK_GRAY4 */
  --line: rgba(255,255,255,0.12);
  --line-2: rgba(255,255,255,0.2);
  --text: #F6F7F9;      /* LIGHT_GRAY5 */
  --muted: #ABB3BF;     /* GRAY4 */
  --dim: #8F99A8;       /* GRAY3 */
  --blue: #4C90F0;      /* BLUE4 (dark-theme intent) */
  --blue-solid: #2D72D2;
  --green: #32A467;     /* GREEN4 */
  --orange: #EC9A3C;    /* ORANGE4 */
  --red: #E76A6E;       /* RED4 */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.4, 1, 0.75, 0.9);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 13px; line-height: 1.35; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
a { color: #8ABBFF; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #404854; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- top bar (50px, Foundry chrome) */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50; height: 50px; }
.topbar-inner { padding: 0 16px; height: 50px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-width: 0; }
.brand-mark { width: 22px; height: 22px; border-radius: 2px; background: var(--blue-solid);
  color: #fff; font-family: var(--mono); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex: none; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.crumb .sep { color: var(--dim); }
.crumb .here { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 8px; flex: none; }
.nav-btn { background: none; border: none; padding: 5px 10px; border-radius: 2px;
  color: var(--muted); font-weight: 500; font-size: 12.5px; }
.nav-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-btn.active { color: var(--text); background: var(--panel-2); }
.key-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.key-dot.ok { background: var(--green); }

/* ---- layout: edge-to-edge workspace */
.main { max-width: 1400px; margin: 0 auto; padding: 0 16px 60px; }
.wsbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---- tags (Blueprint minimal variant: 20% intent bg + step-4 text) */
.tag { display: inline-flex; align-items: center; gap: 6px; min-height: 20px;
  padding: 1px 7px; border-radius: 2px; font-size: 11.5px; font-weight: 600;
  font-family: var(--mono); letter-spacing: .02em; }
.tag.blue { background: rgba(76,144,240,.2); color: var(--blue); }
.tag.green { background: rgba(50,164,103,.2); color: var(--green); }
.tag.orange { background: rgba(236,154,60,.2); color: var(--orange); }
.tag.red { background: rgba(231,106,110,.2); color: var(--red); }
.tag.gray { background: rgba(171,179,191,.15); color: var(--muted); }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag .dot.pulse { animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---- buttons (30px default / 24px small, flat) */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px;
  padding: 0 12px; border-radius: 2px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-weight: 500;
  font-size: 12.5px; transition: background .1s var(--ease); }
.btn:hover { background: #404854; }
.btn.primary { background: var(--blue-solid); border-color: var(--blue-solid); color: #fff; }
.btn.primary:hover { background: #215DB0; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: rgba(231,106,110,.15); }
.btn.small { height: 24px; padding: 0 9px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn .spin { width: 11px; height: 11px; border: 1.5px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- panels: 1px borders, no shadows */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 2px; }
.panel + .panel { margin-top: 10px; }
.panel-head { padding: 7px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title { font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); }
.panel-body { padding: 12px; }
.panel-body.tight { padding: 0; }
.caption { color: var(--dim); font-size: 11.5px; margin-top: 6px; line-height: 1.45; }

/* ---- tabs (flat words, Foundry style) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab { border: none; background: none; padding: 8px 13px; color: var(--muted);
  font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent;
  border-radius: 0; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--blue); }
.tab .n { color: var(--dim); font-family: var(--mono); font-size: 11px; margin-left: 5px; }

/* ---- run list */
.rlist { width: 100%; border-collapse: collapse; }
.rlist th { text-align: left; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--dim); padding: 7px 12px;
  border-bottom: 1px solid var(--line-2); font-weight: 650; }
.rlist td { padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.rlist tr.rrow { cursor: pointer; }
.rlist tr.rrow:hover { background: var(--panel-2); }
.rlist tr:last-child td { border-bottom: none; }
.rname { font-weight: 600; }
.rmeta { font-family: var(--mono); font-size: 11.5px; color: var(--dim); }

/* ---- pipeline DAG */
.dag-wrap { position: relative; overflow-x: auto; padding: 18px 12px; }
.dag { position: relative; display: flex; gap: 44px; align-items: center;
  min-width: max-content; }
.dag-col { display: flex; flex-direction: column; gap: 12px; }
.node { width: 172px; background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 2px; padding: 8px 10px; cursor: pointer; position: relative;
  transition: border-color .1s var(--ease); }
.node:hover { border-color: var(--dim); }
.node.sel { outline: 2px solid var(--blue); outline-offset: -1px; }
.node.st-done { border-color: rgba(50,164,103,.6); }
.node.st-run { border-color: var(--blue); }
.node.st-pending { opacity: .55; }
.node.st-fail { border-color: var(--red); }
.node-label { font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.node-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px;
  font-size: 11px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; }
.node-sub .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.st-done .node-sub .dot { background: var(--green); }
.st-run .node-sub .dot { background: var(--blue); animation: pulse 1.2s ease infinite; }
.st-pending .node-sub .dot { background: var(--dim); }
.st-fail .node-sub .dot { background: var(--red); }
.dag-svg { position: absolute; inset: 0; pointer-events: none; }
.dag-svg path { stroke: #5F6B7C; stroke-width: 1.5; fill: none; opacity: .7; }

/* ---- inspector */
.inspector { border-top: 1px solid var(--line); background: var(--panel); padding: 12px; }
.insp-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.4fr); gap: 16px; }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 3px 0; font-size: 12px; vertical-align: top; }
.kv td:first-child { color: var(--dim); padding-right: 14px; white-space: nowrap; }
.kv td:last-child { font-family: var(--mono); font-size: 11.5px; }
.hist { display: flex; align-items: flex-end; gap: 1px; height: 54px; margin-top: 6px; }
.hist > div { flex: 1; background: #5F6B7C; min-height: 1px; border-radius: 1px 1px 0 0; }
.hist > div.hot { background: var(--blue); }
.sparkline { stroke: var(--blue); stroke-width: 1.5; fill: none; }
.spark-wrap { margin-top: 6px; }
.axis-note { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 2px; }

/* ---- data grid (spreadsheet) */
.grid-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grid-count { font-family: var(--mono); font-size: 11.5px; color: var(--dim); margin-left: auto; }
.ginput { height: 24px; background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 2px; padding: 0 8px; font-size: 12px; color: var(--text); width: 200px; }
.ginput:focus { outline: none; border-color: var(--blue); }
select.ginput { width: auto; }
.dgrid-wrap { overflow: auto; max-height: 640px; }
.dgrid { width: 100%; border-collapse: collapse; font-size: 12px; }
.dgrid th { position: sticky; top: 0; z-index: 5; background: var(--panel-2);
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 0 8px; height: 30px; border-bottom: 1px solid var(--line-2);
  border-right: 1px solid var(--line); font-weight: 650; cursor: pointer; user-select: none;
  white-space: nowrap; }
.dgrid th:hover { color: var(--text); }
.dgrid th .arr { color: var(--blue); font-size: 10px; }
.dgrid td { padding: 2px 8px; height: 24px; border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 340px; }
.dgrid td.num { font-family: var(--mono); font-size: 11.5px; text-align: right;
  font-variant-numeric: tabular-nums; }
.dgrid td.gut { color: var(--dim); font-family: var(--mono); font-size: 11px;
  text-align: right; background: var(--panel); width: 44px; }
.dgrid tr.grow { cursor: pointer; }
.dgrid tr.grow:hover td { background: rgba(76,144,240,.07); }
.dgrid tr.grow.sel td { background: rgba(76,144,240,.14); }
.cell-flag { color: var(--red); font-weight: 700; }
.txtcell { color: var(--muted); }
.txtcell b { color: var(--text); font-weight: 500; }

/* ---- row drawer (why panel) */
.drawer { border-top: 1px solid var(--line-2); background: var(--panel); padding: 12px; }
.why-row { display: grid; grid-template-columns: 150px 1fr 120px; gap: 10px;
  align-items: center; margin-bottom: 6px; }
.why-name { font-size: 12px; color: var(--muted); }
.zbar-wrap { height: 14px; background: var(--bg); border-radius: 2px; position: relative; overflow: hidden; }
.zbar { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.zbar.pos { background: var(--blue); }
.zbar.neg { background: #5F6B7C; }
.zmark { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.why-val { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.term-chip { display: inline-block; background: rgba(76,144,240,.15); color: var(--blue);
  border-radius: 2px; padding: 1px 6px; font-size: 11px; font-family: var(--mono); margin: 2px 3px 0 0; }
.fulltext { background: var(--bg); border: 1px solid var(--line); border-radius: 2px;
  padding: 9px 11px; font-size: 12px; margin-top: 8px; }
.fulltext .p { color: var(--muted); white-space: pre-wrap; }
.fulltext .r { margin-top: 6px; font-family: var(--mono); font-size: 11.5px;
  white-space: pre-wrap; color: var(--text); }

/* ---- gauges (gate features vs thresholds) */
.gauge { margin-bottom: 10px; }
.gauge-head { display: flex; justify-content: space-between; font-size: 11.5px;
  color: var(--muted); margin-bottom: 3px; }
.gauge-head b { color: var(--text); font-family: var(--mono); }
.gauge-bar { height: 8px; background: var(--bg); border-radius: 2px; position: relative; }
.gauge-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 2px; }
.gauge-fill.green { background: var(--green); } .gauge-fill.orange { background: var(--orange); }
.gauge-fill.red { background: var(--red); } .gauge-fill.blue { background: var(--blue); }
.gauge-thresh { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .5; }
.gauge-note { font-size: 10.5px; color: var(--dim); margin-top: 2px; font-family: var(--mono); }

/* ---- scree plot */
.scree { width: 100%; height: 150px; }
.scree circle { fill: #5F6B7C; }
.scree circle.hot { fill: var(--red); }
.scree circle.planted { stroke: var(--orange); stroke-width: 1.5; }
.scree .cliff-line { stroke: var(--orange); stroke-width: 1; stroke-dasharray: 3 3; }
.scree text { fill: var(--dim); font-size: 9.5px; font-family: var(--mono); }

/* ---- callout */
.callout { border-radius: 2px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 10px;
  border: 1px solid transparent; }
.callout.blue { background: rgba(76,144,240,.12); border-color: rgba(76,144,240,.4); }
.callout.green { background: rgba(50,164,103,.12); border-color: rgba(50,164,103,.4); }
.callout.orange { background: rgba(236,154,60,.12); border-color: rgba(236,154,60,.4); }
.callout.red { background: rgba(231,106,110,.12); border-color: rgba(231,106,110,.4); }
.callout b { display: block; margin-bottom: 2px; }

/* ---- forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.field .hint { color: var(--dim); font-size: 11.5px; margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; height: 30px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 2px; background: var(--bg); font-size: 13px; }
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical;
  font-family: var(--mono); font-size: 12px; }
textarea.input.prose { font-family: var(--sans); font-size: 13px; }
.input:focus { outline: none; border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.drop { border: 1px dashed var(--line-2); border-radius: 2px; padding: 18px;
  text-align: center; color: var(--muted); cursor: pointer; font-size: 12.5px; }
.drop:hover, .drop.over { border-color: var(--blue); background: rgba(76,144,240,.06); }
.drop.hasfile { border-style: solid; border-color: var(--green); color: var(--green); }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 2px;
  width: fit-content; overflow: hidden; margin-bottom: 10px; }
.seg button { border: none; background: none; padding: 5px 12px; color: var(--muted);
  font-size: 12px; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--blue-solid); color: #fff; }
details.adv summary { cursor: pointer; color: var(--muted); font-weight: 600;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.behavior-block { border: 1px solid var(--line); border-radius: 2px; padding: 10px; margin-bottom: 8px; }

/* ---- livelog */
.livelog { font-family: var(--mono); font-size: 11.5px; background: #111418;
  color: #C5CBD3; border-radius: 2px; padding: 10px 12px; max-height: 220px;
  overflow-y: auto; line-height: 1.6; }
.livelog .lg-stage { color: var(--blue); }
.progress { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--blue-solid); transition: width .5s var(--ease); }

/* ---- non-ideal state */
.nis { text-align: center; padding: 48px 16px; color: var(--muted); font-size: 12.5px; }
.nis b { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; }

/* ---- verify chart */
.vchart { display: flex; gap: 24px; align-items: flex-end; height: 130px; padding: 8px 4px 0; }
.vgroup { display: flex; gap: 6px; align-items: flex-end; }
.vbar { width: 30px; border-radius: 2px 2px 0 0; position: relative; }
.vbar span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--muted); }
.vlabel { font-size: 10.5px; color: var(--dim); text-align: center; margin-top: 4px; }

/* ---- toast */
#toast-holder { position: fixed; bottom: 18px; right: 18px; display: flex;
  flex-direction: column; gap: 6px; z-index: 100; }
.toast { background: #404854; color: #fff; border-radius: 2px; border: 1px solid var(--line-2);
  padding: 8px 13px; font-size: 12.5px; animation: rise .15s var(--ease); max-width: 380px; }
.toast.err { background: #8E292C; }
@keyframes rise { from { transform: translateY(5px); opacity: 0; } }

.muted { color: var(--dim); font-size: 11.5px; }
.mono { font-family: var(--mono); }
.protocol-footer { max-width: 1400px; margin: 30px auto 0; padding: 10px 16px;
  border-top: 1px solid var(--line); color: var(--dim);
  font-family: var(--mono); font-size: 10.5px; }
@media (max-width: 860px) { .grid2, .grid3, .insp-grid { grid-template-columns: 1fr; } }
