/* ============================================================
   SBR PIPELINE TERMINAL — BETA
   Direction: Bloomberg terminal × Swiss editorial.
   Warm graphite ground, three signal colours, mono-forward.
   ============================================================ */

:root {
  /* Ground — warm graphite, not blue-black */
  --ink-0:   #0a0b0d;
  --ink-1:   #101216;
  --ink-2:   #161a20;
  --ink-3:   #1d222a;
  --ink-4:   #262d37;
  --rule:    #1a1f27;
  --rule-2:  #232a34;

  /* Type */
  --type-1:  #e7e2d6;
  --type-2:  #a6a193;
  --type-3:  #6c6a62;
  --type-4:  #4a4944;

  /* Signals — three colours doing all semantic work */
  --signal:    #ffb454;
  --signal-dim:#b67a2c;
  --signal-bg: #221a0e;
  --go:        #6dd49b;
  --go-dim:    #2f7a52;
  --go-bg:     #0e1d16;
  --halt:      #f47174;
  --halt-dim:  #8a2b2e;
  --halt-bg:   #21100f;
  --info:      #7fc8e8;
  --info-dim:  #335f72;
  --violet:    #c9a4ff;
  --violet-bg: #1d1530;

  /* Stage palette */
  --st-landing:   #6c6a62;
  --st-scope-d:   #ffb454;
  --st-scope-r:   #ffd28a;
  --st-inv-r:     #c9a4ff;
  --st-cpo:       #f47174;
  --st-approved:  #6dd49b;
  --st-parked:    #4a4944;
  --st-rejected:  #8a2b2e;

  /* Fonts */
  --f-mono:    "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;
  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-text:    "Inter Tight", system-ui, -apple-system, sans-serif;
  --u: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { font-size: 13px; }
body {
  font-family: var(--f-text);
  font-feature-settings: "ss01", "cv11", "tnum";
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255,180,84,0.04), transparent 60%),
    radial-gradient(900px 500px at -10% 100%, rgba(109,212,155,0.025), transparent 60%),
    var(--ink-0);
  color: var(--type-1);
  letter-spacing: 0.005em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: ""; position: fixed; inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
  pointer-events: none; z-index: 1; mix-blend-mode: overlay;
}
::selection { background: var(--signal); color: var(--ink-0); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-3); border: 2px solid var(--ink-0); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app { position: relative; z-index: 2; display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }

/* Topbar */
.topbar {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: calc(var(--u) * 4);
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 60%), var(--ink-1);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark { font-family: var(--f-mono); font-weight: 700; font-size: 11px; letter-spacing: 0.18em; color: var(--signal); padding: 3px 7px; border: 1px solid var(--signal-dim); background: var(--signal-bg); }
.brand-title { font-family: var(--f-display); font-weight: 600; font-style: italic; font-size: 22px; letter-spacing: -0.01em; color: var(--type-1); line-height: 1; }
.brand-title em { font-style: normal; color: var(--type-3); font-weight: 400; font-size: 14px; margin-left: 8px; letter-spacing: 0; }
.brand-beta { font-family: var(--f-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.16em; padding: 2px 5px; background: var(--violet-bg); border: 1px solid var(--violet); color: var(--violet); margin-left: 8px; }

.ticker { display: flex; gap: 0; align-items: stretch; justify-content: center; border: 1px solid var(--rule); background: var(--ink-0); }
.ticker-cell { padding: 6px 14px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.ticker-cell:last-child { border-right: none; }
.ticker-label { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.14em; color: var(--type-3); text-transform: uppercase; }
.ticker-value { font-family: var(--f-mono); font-size: 15px; font-weight: 600; color: var(--type-1); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ticker-value.up   { color: var(--go); }
.ticker-value.warn { color: var(--signal); }
.ticker-value.hot  { color: var(--halt); }

.status-cluster { display: flex; align-items: center; gap: 14px; font-family: var(--f-mono); font-size: 11px; color: var(--type-2); }
.status-cluster .pulse { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 4px 9px; background: var(--go-bg); border: 1px solid var(--go-dim); color: var(--go); }
.pulse-dot { width: 7px; height: 7px; background: var(--go); display: inline-block; border-radius: 50%; box-shadow: 0 0 0 0 rgba(109,212,155,0.6); animation: pulse 2.2s infinite ease-out; }
.pulse.stale { background: var(--signal-bg); border-color: var(--signal-dim); color: var(--signal); }
.pulse.stale .pulse-dot { background: var(--signal); animation-name: pulseAmber; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(109,212,155,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(109,212,155,0); }
  100% { box-shadow: 0 0 0 0 rgba(109,212,155,0); }
}
@keyframes pulseAmber {
  0%   { box-shadow: 0 0 0 0 rgba(255,180,84,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(255,180,84,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,180,84,0); }
}
.iconbtn { font-family: var(--f-mono); font-size: 11px; color: var(--type-2); background: transparent; border: 1px solid var(--rule-2); padding: 4px 9px; cursor: pointer; letter-spacing: 0.06em; transition: all 0.12s ease; }
.iconbtn:hover, .iconbtn:focus-visible { color: var(--signal); border-color: var(--signal-dim); background: var(--signal-bg); outline: none; }
.mode-badge { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.16em; padding: 2px 6px; border: 1px solid var(--rule-2); color: var(--type-3); }
.mode-badge.mock { color: var(--violet); border-color: var(--violet); }
.mode-badge.live { color: var(--go); border-color: var(--go-dim); }

/* Banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 8px 20px; background: repeating-linear-gradient(135deg, rgba(255,180,84,0.06) 0 8px, transparent 8px 16px), var(--signal-bg); border-bottom: 1px solid var(--signal-dim); color: var(--signal); font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.03em; }
.banner[hidden] { display: none; }
.banner-tag { font-weight: 700; padding: 2px 6px; background: var(--signal); color: var(--ink-0); letter-spacing: 0.16em; font-size: 9.5px; }
.banner-msg { color: var(--type-1); }
.banner-time { margin-left: auto; color: var(--type-3); }

/* Workspace grid */
.workspace { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: 1fr 220px; gap: 0; min-height: 0; overflow: hidden; padding-bottom: 28px; }
.pane-pipeline { grid-column: 1; grid-row: 1; border-right: 1px solid var(--rule); }
.pane-side     { grid-column: 2; grid-row: 1 / span 2; border-left: 1px solid var(--rule); }
.pane-activity { grid-column: 1; grid-row: 2; border-top: 1px solid var(--rule); }
.pane { display: flex; flex-direction: column; background: var(--ink-1); min-height: 0; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 8px 20px; border-bottom: 1px solid var(--rule); background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent), var(--ink-1); flex-shrink: 0; gap: 16px; }
.pane-head h2 { margin: 0; font-family: var(--f-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--type-2); }
.pane-head h2::before { content: "▌"; color: var(--signal); margin-right: 8px; font-size: 12px; vertical-align: -1px; }
.pane-head .meta { font-family: var(--f-mono); font-size: 10.5px; color: var(--type-3); letter-spacing: 0.04em; }
.pane-head .meta b { color: var(--type-2); font-weight: 500; }
.pane-body { flex: 1; overflow: auto; min-height: 0; min-width: 0; }

/* Filter strip */
.filterbar { display: flex; align-items: center; gap: 0; padding: 0 20px; border-bottom: 1px solid var(--rule); background: var(--ink-0); flex-wrap: wrap; row-gap: 4px; }
.filterbar .group { display: flex; align-items: center; gap: 6px; padding: 6px 0; margin-right: 18px; border-right: 1px solid var(--rule); padding-right: 18px; }
.filterbar .group:last-of-type { border-right: 0; }
.filterbar .group-label { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.16em; color: var(--type-4); text-transform: uppercase; margin-right: 4px; }
.chip { font-family: var(--f-mono); font-size: 10.5px; color: var(--type-2); padding: 3px 8px; border: 1px solid var(--rule-2); background: transparent; cursor: pointer; letter-spacing: 0.04em; transition: all 0.1s ease; display: inline-flex; align-items: center; gap: 6px; }
.chip .count { font-size: 9.5px; color: var(--type-3); font-weight: 500; }
.chip:hover, .chip:focus-visible { color: var(--type-1); border-color: var(--ink-4); outline: none; }
.chip[aria-pressed="true"]    { color: var(--signal); border-color: var(--signal-dim); background: var(--signal-bg); }
.chip[aria-pressed="true"] .count { color: var(--signal-dim); }
.chip.go[aria-pressed="true"]   { color: var(--go);   border-color: var(--go-dim);   background: var(--go-bg); }
.chip.halt[aria-pressed="true"] { color: var(--halt); border-color: var(--halt-dim); background: var(--halt-bg); }

.searchbox { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; background: var(--ink-2); border: 1px solid var(--rule-2); padding: 3px 9px; }
.searchbox::before { content: "/"; font-family: var(--f-mono); font-size: 11px; color: var(--type-3); }
.searchbox input { border: 0; outline: 0; background: transparent; color: var(--type-1); font-family: var(--f-mono); font-size: 11px; width: 200px; }
.searchbox input::placeholder { color: var(--type-3); }
.searchbox kbd { font-family: var(--f-mono); font-size: 9px; color: var(--type-3); border: 1px solid var(--rule-2); padding: 1px 4px; background: var(--ink-1); }

/* Pipeline table — D3: no-ellipsis, panel-level horizontal overflow */
.tablewrap { width: 100%; overflow-x: auto; }
.table { width: max-content; min-width: 100%; border-collapse: collapse; table-layout: auto; font-family: var(--f-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.table thead th { position: sticky; top: 0; background: linear-gradient(180deg, var(--ink-1), var(--ink-0)); color: var(--type-3); font-weight: 500; text-align: left; font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; z-index: 3; user-select: none; }
.table thead th[data-sort-col] { cursor: pointer; }
.table thead th[data-sort-col]:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.table thead th .sort { margin-left: 4px; color: var(--type-4); font-size: 9px; }
.table thead th[aria-sort="ascending"], .table thead th[aria-sort="descending"] { color: var(--signal); }
.table thead th[aria-sort="ascending"] .sort, .table thead th[aria-sort="descending"] .sort { color: var(--signal); }

.table tbody td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; color: var(--type-1); }
.table tbody tr { transition: background 0.08s linear; }
.table tbody tr:hover { background: linear-gradient(90deg, rgba(255,180,84,0.04), transparent 30%), var(--ink-2); }
.table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--signal); }

@keyframes flashRow { 0% { background: rgba(255,180,84,0.18); } 100% { background: transparent; } }
.table tbody tr.flash > td { animation: flashRow 0.9s ease-out; }

/* SBR + Title cells are the GitHub-Issue launchers */
.col-id .openable, .col-title .openable { cursor: pointer; }
.col-id .openable:hover, .col-title .openable:hover { color: var(--signal); }

.col-id { width: 88px; color: var(--signal); font-weight: 600; font-size: 11.5px; letter-spacing: 0.02em; }
.col-id .child-indent { color: var(--type-4); margin-right: 4px; font-weight: 400; }
.col-id .parent-toggle { display: inline-block; width: 12px; color: var(--type-3); cursor: pointer; user-select: none; transition: transform 0.12s; }
.col-id .parent-toggle.open { transform: rotate(90deg); color: var(--signal); }

.col-title { font-family: var(--f-text); font-size: 13px; font-weight: 500; letter-spacing: -0.005em; color: var(--type-1); white-space: normal; max-width: 320px; word-break: break-word; }
.col-title small { display: block; font-family: var(--f-mono); font-size: 10px; color: var(--type-3); font-weight: 400; letter-spacing: 0.03em; margin-top: 1px; }

.stages { display: inline-flex; align-items: center; gap: 0; }
.stage-tick { width: 14px; height: 14px; position: relative; border-right: 1px solid var(--ink-0); display: inline-block; background: var(--ink-3); }
.stage-tick:last-child { border-right: 0; }
.stage-tick.done   { background: var(--go); }
.stage-tick.wip    { background: var(--signal); background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.18) 0 3px, transparent 3px 6px); }
.stage-tick.pending{ background: var(--ink-3); }
.stage-tick.terminal-parked   { background: var(--type-4); }
.stage-tick.terminal-rejected { background: var(--halt); }

.col-status { width: 132px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; padding: 3px 8px 3px 6px; background: var(--ink-2); border-left: 2px solid var(--type-4); color: var(--type-2); white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; background: currentColor; display: inline-block; }
.status.landing-zone   { color: var(--st-landing);   border-color: var(--st-landing); }
.status.scope-draft    { color: var(--st-scope-d);   border-color: var(--st-scope-d); background: var(--signal-bg); }
.status.scope-ready    { color: var(--st-scope-r);   border-color: var(--st-scope-r); background: var(--signal-bg); }
.status.investment-ready { color: var(--st-inv-r);   border-color: var(--st-inv-r);   background: var(--violet-bg); }
.status.cpo-review     { color: var(--st-cpo);       border-color: var(--st-cpo);     background: var(--halt-bg); }
.status.approved       { color: var(--st-approved);  border-color: var(--st-approved);background: var(--go-bg); }
.status.parked         { color: var(--st-parked);    border-color: var(--st-parked); }
.status.rejected       { color: var(--halt);         border-color: var(--halt);      background: var(--halt-bg); }

.col-score { width: 52px; text-align: center; }
.col-score-brd { width: 38px; text-align: center; }

.score { display: inline-block; min-width: 34px; padding: 2px 6px; font-family: var(--f-mono); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; border: 1px solid; background: var(--ink-0); line-height: 1.3; transition: all 0.1s; text-decoration: none; }
.score.linkable { cursor: pointer; }
.score.linkable:hover, .score.linkable:focus-visible { transform: translateY(-1px); outline: none; box-shadow: 0 0 0 1px var(--signal); }
.score.brd { min-width: 28px; font-size: 10px; padding: 1px 4px; }
.score.g   { color: var(--go);     border-color: var(--go-dim);     background: var(--go-bg); }
.score.a   { color: var(--signal); border-color: var(--signal-dim); background: var(--signal-bg); }
.score.r   { color: var(--halt);   border-color: var(--halt-dim);   background: var(--halt-bg); }
.score.dim { color: var(--type-4); border-color: var(--rule-2);     background: transparent; }
.score.empty { color: var(--type-4); border-color: var(--rule); background: transparent; }
.scorebar { display: inline-block; width: 34px; height: 3px; margin-left: 4px; background: var(--ink-3); vertical-align: middle; position: relative; }
.scorebar > i { position: absolute; left: 0; top: 0; bottom: 0; display: block; background: currentColor; }

.col-link { width: 56px; text-align: center; }
.linkchip { font-family: var(--f-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.06em; color: var(--info); text-decoration: none; padding: 2px 6px; border: 1px solid var(--info-dim); background: transparent; display: inline-block; transition: all 0.1s; }
.linkchip:hover, .linkchip:focus-visible { background: var(--info); color: var(--ink-0); border-color: var(--info); outline: none; }
.linkchip.disabled { color: var(--type-4); border-color: var(--rule); pointer-events: none; }

.col-contrib { width: 150px; }
.contrib { display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-mono); font-size: 11px; }
.contrib .who { color: var(--type-1); }
.contrib .n   { color: var(--type-3); font-size: 10px; }

.col-change { width: 240px; white-space: normal !important; }
.change { font-family: var(--f-mono); font-size: 10.5px; line-height: 1.4; color: var(--type-2); }
.change .actor { color: var(--type-1); font-weight: 500; }
.change .verb  { color: var(--signal); }
.change .what  { color: var(--type-2); }

.col-who { width: 96px; }
.avatars { display: inline-flex; align-items: center; }
.av { width: 22px; height: 22px; background: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; font-family: var(--f-mono); font-size: 9.5px; font-weight: 600; color: var(--type-1); border: 1px solid var(--ink-0); margin-left: -5px; letter-spacing: 0.02em; overflow: hidden; }
.av:first-child { margin-left: 0; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.a1 { background: linear-gradient(135deg, #ffb454, #b67a2c); color: #1a0d00; }
.av.a2 { background: linear-gradient(135deg, #6dd49b, #2f7a52); color: #051a10; }
.av.a3 { background: linear-gradient(135deg, #c9a4ff, #6a4ea3); color: #100a1d; }
.av.a4 { background: linear-gradient(135deg, #7fc8e8, #335f72); color: #001520; }
.av.a5 { background: linear-gradient(135deg, #f47174, #8a2b2e); color: #1a0606; }
.av.more { background: transparent; color: var(--type-3); border: 1px solid var(--rule-2); font-size: 9px; }

.col-upd { width: 86px; text-align: right; color: var(--type-2); }
.col-upd b { color: var(--type-1); font-weight: 600; }
.col-upd .ago { color: var(--type-3); }

tr.child td { background: rgba(255,180,84,0.025); }
tr.child .col-id { color: var(--type-2); font-weight: 500; }

tr.section td { background: var(--ink-0); padding: 6px 10px; color: var(--type-3); font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); }
tr.section td::before { content: "──"; color: var(--type-4); margin-right: 10px; }

/* Side rail */
.side-section { display: flex; flex-direction: column; flex: 1; min-height: 0; border-bottom: 1px solid var(--rule); }
.side-section:last-child { border-bottom: 0; }
.queue-item, .q-item { padding: 10px 14px; border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: start; }
.queue-item:hover, .q-item:hover { background: var(--ink-2); }
.queue-empty { padding: 20px; text-align: center; color: var(--type-3); font-family: var(--f-mono); font-size: 11px; font-style: italic; }
.pri { font-family: var(--f-mono); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; padding: 2px 5px; color: var(--ink-0); }
.pri.p0 { background: var(--halt); }
.pri.p1 { background: var(--signal); }
.pri.p2 { background: var(--type-3); }
.queue-id, .q-id { font-family: var(--f-mono); font-size: 9.5px; color: var(--signal); letter-spacing: 0.02em; align-self: center; font-weight: 600; }
.queue-body, .q-body { font-family: var(--f-text); font-size: 12px; line-height: 1.4; color: var(--type-1); grid-column: 2; }
.queue-meta, .q-meta { grid-column: 2; font-family: var(--f-mono); font-size: 9.5px; color: var(--type-3); letter-spacing: 0.02em; margin-top: 2px; }

/* Activity rail */
.activity-table { width: 100%; border-collapse: collapse; font-family: var(--f-mono); font-size: 11px; }
.activity-table thead th { text-align: left; padding: 6px 16px; color: var(--type-3); font-weight: 500; font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; border-bottom: 1px solid var(--rule); background: var(--ink-1); position: sticky; top: 0; z-index: 2; }
.activity-table tbody td { padding: 8px 16px; border-bottom: 1px solid var(--rule); color: var(--type-1); }
.activity-table tbody tr:hover { background: var(--ink-2); }
.liveness { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.live    { background: var(--go);  box-shadow: 0 0 0 0 rgba(109,212,155,0.6); animation: pulse 2.2s infinite ease-out; }
.dot.idle    { background: var(--signal); }
.dot.stale   { background: var(--halt-dim); }
.dot.offline { background: var(--type-4); }
.device-name { color: var(--type-1); }

.spark { display: inline-block; width: 80px; height: 18px; background: var(--ink-2); border: 1px solid var(--rule); vertical-align: middle; position: relative; margin-left: 8px; }
.spark i { position: absolute; bottom: 0; width: 4px; background: var(--signal); }

/* Footer status line */
.footer { border-top: 1px solid var(--rule); background: var(--ink-1); padding: 6px 20px; display: flex; align-items: center; gap: 22px; font-family: var(--f-mono); font-size: 10px; color: var(--type-3); letter-spacing: 0.08em; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; }
.footer kbd { background: var(--ink-2); border: 1px solid var(--rule-2); padding: 1px 5px; font-family: var(--f-mono); color: var(--type-2); font-size: 10px; }
.footer .sep { color: var(--rule-2); }
.footer-right { margin-left: auto; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 180px 220px; }
  .pane-side { grid-column: 1; grid-row: 2; border-left: 0; border-top: 1px solid var(--rule); }
  .pane-activity { grid-row: 3; }
}
