/* ============================================================
   PRODUCT MANAGER SIM — sim/ui.css
   Dark, monospace, terminal-adjacent. Same visual language as
   RoleSims/DayTrader and RoleSims/MLResearcher — one family.
   Palette fixed by SPEC §3.
   ============================================================ */

:root {
  --bg:      #0d1117;
  --panel:   #161b22;
  --panel2:  #1c222b;
  --panel3:  #11161d;
  --border:  #30363d;
  --border2: #21262d;
  --text:    #c9d1d9;
  --dim:     #8b949e;
  --green:   #3fb950;
  --red:     #f85149;
  --amber:   #d29922;
  --cyan:    #39c5cf;
  --violet:  #a371f7;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "DejaVu Sans Mono", "Liberation Mono", monospace;

  --gap: 8px;
  --pad: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "calt" 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#pms-root { height: 100%; width: 100%; position: relative; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b333d; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3d4753; }

/* ---------- primitives ---------- */
.hidden { display: none !important; }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.flat { color: var(--text); }
.amber { color: var(--amber); }
.cyan { color: var(--cyan); }
.violet { color: var(--violet); }
.r { text-align: right; }
.c { text-align: center; }
.nowrap { white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
b, strong { font-weight: 600; color: #e6edf3; }

.lbl {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 500;
}

/* ---------- screens ---------- */
.screen { display: none; height: 100%; width: 100%; }
.screen.active { display: flex; flex-direction: column; }
.center-screen { align-items: center; }
.scrollwrap { flex: 1 1 auto; min-height: 0; width: 100%; overflow-y: auto; overflow-x: hidden; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.panel-hd {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1b2129, #171c24);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
}
.panel-hd b { font-size: 11px; letter-spacing: 0.06em; }
.panel-bd {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
}
.panel-bd.nopad { padding: 0; }
.panel-bd.tight { padding: 6px 8px; }
.panel-ft {
  flex: 0 0 auto;
  border-top: 1px solid var(--border2);
  padding: 7px 10px;
  background: #141920;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text);
  background: #1f262e;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: #29313b; border-color: #4a545f; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn:focus-visible { outline: 1px solid var(--cyan); outline-offset: 1px; }
.btn.primary { background: #12331d; border-color: #2b6c39; color: #7ee495; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #174526; border-color: var(--green); }
.btn.danger { background: #331616; border-color: #6b2b2b; color: #ff9d97; }
.btn.danger:hover:not(:disabled) { background: #451c1c; border-color: var(--red); }
.btn.warn { background: #332a10; border-color: #6b5518; color: #e3b341; }
.btn.warn:hover:not(:disabled) { background: #45380f; border-color: var(--amber); }
.btn.ghost { background: transparent; border-color: var(--border2); color: var(--dim); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border); background: #1a1f27; }
.btn.big { font-size: 13px; padding: 10px 20px; letter-spacing: 0.1em; }
.btn.wide { width: 100%; display: block; }
.btn.tiny { font-size: 9.5px; padding: 2px 5px; letter-spacing: .04em; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg-b {
  font-family: var(--mono); font-size: 10.5px;
  background: #1a1f27; color: var(--dim);
  border: 0; border-right: 1px solid var(--border);
  padding: 4px 8px; cursor: pointer;
}
.seg-b:last-child { border-right: 0; }
.seg-b:hover { color: var(--text); background: #232a34; }
.seg-b.is-on { background: #223b44; color: var(--cyan); font-weight: 600; }

/* inputs */
input[type="text"], input[type="number"], textarea, select {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: #0b0f14;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 7px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
select { cursor: pointer; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(57,197,207,.25);
}
input:disabled, select:disabled { opacity: .4; }
textarea { resize: none; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #5b636d; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================================================
   SCREEN 1 — BRIEF
   ============================================================ */
.brief-wrap { width: 100%; max-width: 1340px; margin: 0 auto; padding: 22px 22px 34px; }
.brand { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .22em; font-weight: 600; color: #e6edf3; }
.brand .sub { color: var(--dim); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.rule { height: 1px; background: var(--border); margin: 14px 0 18px; }

.brief-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brief-hd h2 { margin: 0; font-size: 18px; letter-spacing: .12em; color: #e6edf3; font-weight: 600; }
.brief-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); gap: 14px; margin-top: 16px; }

.blk { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.blk + .blk { margin-top: 12px; }
.blk h3 {
  margin: 0 0 7px; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
}
.blk p { margin: 0; font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; }
.blk.headline p { font-size: 14px; line-height: 1.6; color: #e6edf3; }
.blk.ask { border-left: 2px solid var(--cyan); background: #12222a; }
.blk.ask p { color: #d6f2f5; }
.blk.warnblk { border-left: 2px solid var(--amber); background: #1c1a12; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.stat .lbl { display: block; }
.stat .v { font-size: 15px; font-weight: 600; color: #e6edf3; }

.acct-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; margin-bottom: 18px;
}
.acct-cell { background: var(--panel); padding: 10px 12px; }
.acct-cell .lbl { display: block; margin-bottom: 3px; }
.acct-cell .v { font-size: 19px; font-weight: 600; color: #e6edf3; }

.foot-row { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; gap: 12px; }
.note { color: var(--dim); font-size: 11px; line-height: 1.6; }

/* instrument table on the brief — the caveats are the point */
.inst-brief { display: flex; flex-direction: column; gap: 7px; }
.inst-brief-row {
  border: 1px solid var(--border2); border-left: 2px solid var(--border);
  border-radius: 0 4px 4px 0; padding: 7px 9px; background: var(--panel2);
}
.inst-brief-row .ib-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.inst-brief-row .ib-nm { font-weight: 600; color: #e6edf3; font-size: 12.5px; }
.inst-brief-row .ib-cost { font-size: 10.5px; color: var(--dim); white-space: nowrap; }
.inst-brief-row .ib-cav {
  margin-top: 4px; font-size: 11.5px; line-height: 1.55; color: #e3b341;
}
.inst-brief-row .ib-cav::before { content: "⚠ BLIND SPOT — "; font-size: 9.5px; letter-spacing: .1em; color: var(--amber); }

/* ============================================================
   SCREEN 2 — DESK
   ============================================================ */
#scr-desk { padding: 8px 10px 10px; }

.hdr {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 166px minmax(0, 1fr) 172px 360px;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  margin-bottom: var(--gap);
}
.hdr-l { min-width: 0; }
.clock { font-size: 26px; font-weight: 600; letter-spacing: .04em; color: #e6edf3; line-height: 1.05; }
.clock-sub { font-size: 10.5px; color: var(--dim); letter-spacing: .1em; }
.clock-sub b { color: var(--cyan); font-weight: 600; }

/* capacity — committed vs remaining, alarming when committed > remaining */
.cap { min-width: 0; }
.cap-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; white-space: nowrap; }
.cap-top .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cap-top .v { font-size: 12.5px; font-weight: 600; color: #e6edf3; flex: 0 0 auto; }
.cap-bar {
  height: 12px; margin-top: 4px; border-radius: 3px; overflow: hidden;
  background: #0b0f14; border: 1px solid var(--border2); display: flex;
}
.cap-seg { height: 100%; transition: width .25s linear; }
.cap-seg.spent { background: #2f6f3c; }
.cap-seg.committed { background: var(--cyan); }
.cap-seg.over { background: var(--red); }
.cap-legend {
  display: flex; gap: 12px; margin-top: 3px; font-size: 10px; color: var(--dim);
  white-space: nowrap; overflow: hidden;
}
.cap-legend > span { flex: 0 0 auto; }
.cap-legend > #h-capwarn { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.cap-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; font-style: normal; }
.cap-legend i.spent { background: #2f6f3c; }
.cap-legend i.committed { background: var(--cyan); }
.cap-legend i.free { background: #0b0f14; border: 1px solid var(--border); }
.cap.is-over .cap-top .v { color: var(--red); }
.cap.is-over .cap-bar { border-color: var(--red); animation: capPulse 1.5s ease-in-out infinite; }
@keyframes capPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,0); }
  50%      { box-shadow: 0 0 0 2px rgba(248,81,73,.55); }
}
#h-capwarn { color: var(--red); font-weight: 700; letter-spacing: .06em; }

.hdr-kv { display: flex; flex-direction: column; gap: 1px; text-align: right; min-width: 0; }
.hdr-kv > div { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; align-items: baseline; }
.hdr-kv .big { font-size: 17px; font-weight: 700; color: #e6edf3; line-height: 1.15; }
.hdr-ctl { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; min-width: 0; }
.ctl-row { display: flex; align-items: center; gap: 6px; }
#h-status {
  font-size: 10.5px; letter-spacing: .04em; text-align: right; line-height: 1.35;
  max-height: 29px; overflow: hidden;
}
#h-status.is-warn { color: var(--amber); }
#h-status.is-alarm { color: var(--red); }

/* --- the grid --- */
.desk-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 316px 330px;
  grid-template-rows: minmax(0, 1fr) 412px;
  grid-template-areas:
    "board viz      roadmap feed"
    "board research roadmap feed";
  gap: var(--gap);
}
.p-board    { grid-area: board; }
.p-viz      { grid-area: viz; }
.p-research { grid-area: research; }
.p-roadmap  { grid-area: roadmap; display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.p-feed     { grid-area: feed; }

/* --- feature board --- */
.board-bd { padding: 7px 8px; display: flex; flex-direction: column; gap: 6px; }
.fcard {
  background: var(--panel2);
  border: 1px solid var(--border2);
  border-left: 2px solid #39414c;
  border-radius: 0 4px 4px 0;
  padding: 6px 8px 7px;
}
.fcard.is-queued   { border-left-color: var(--cyan); }
.fcard.is-building { border-left-color: var(--amber); background: #1e1f19; }
.fcard.is-shipped  { border-left-color: var(--green); background: #16211a; }
.fcard.is-dropped  { border-left-color: #4a545f; opacity: .55; }
.fcard.is-slipped  { border-left-color: var(--red); background: #221819; }
.fc-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.fc-nm { font-size: 12.5px; font-weight: 600; color: #e6edf3; letter-spacing: .02em; }
.pill {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--dim);
  white-space: nowrap;
}
.pill.queued   { border-color: #24606b; color: var(--cyan); }
.pill.building { border-color: #6b5518; color: var(--amber); }
.pill.shipped  { border-color: #2b6c39; color: var(--green); }
.pill.dropped  { border-color: var(--border); color: var(--dim); }
.pill.slipped  { border-color: #6b2b2b; color: var(--red); }
.fc-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 3px; font-size: 10.5px; color: var(--dim); }
.tag {
  font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
  background: #232b35; border-radius: 2px; padding: 1px 4px; color: #9fb0c0;
}
.fc-sep { color: #4a545f; }
.fc-dots { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; min-height: 15px; align-items: center; }
.rd { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; }
.rd i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; font-style: normal; flex: 0 0 auto; }
.rd.pending { opacity: .5; }
.rd.pending i { border-radius: 2px; }
.fc-none { font-size: 10.5px; color: #5b636d; font-style: italic; }
.fc-act { display: flex; gap: 5px; align-items: center; margin-top: 5px; }
.fc-act .spacer { flex: 1 1 auto; }
.fc-pred { font-size: 10.5px; color: var(--cyan); }
.fc-prog { height: 3px; background: #0b0f14; border-radius: 2px; margin-top: 5px; overflow: hidden; }
.fc-prog i { display: block; height: 100%; background: var(--amber); }
.fcard.is-shipped .fc-prog i { background: var(--green); }

/* --- viz panel --- */
.viz-host { position: relative; background: var(--panel3); flex: 1 1 auto; min-height: 0; overflow: hidden; }
.viz-host canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.viz-err {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 20px; color: var(--red); font-size: 11.5px;
  background: rgba(13,17,23,.9); line-height: 1.6;
}
.legend { display: flex; flex-wrap: wrap; gap: 3px 10px; padding: 5px 9px; border-top: 1px solid var(--border2); background: #131820; }
.lg { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; color: var(--dim); letter-spacing: .04em; }
.lg i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; font-style: normal; }

/* --- research panel --- */
.rs-fld { margin-bottom: 5px; }
.rs-fld > .lbl { display: block; margin-bottom: 2px; }
.p-research .panel-bd select { padding: 3px 6px; }
.inst-list { display: flex; flex-direction: column; gap: 2px; }
.inst-row {
  display: grid; grid-template-columns: 10px minmax(0,1fr) auto;
  gap: 6px; align-items: center;
  background: #131820; border: 1px solid var(--border2); border-radius: 3px;
  padding: 2px 7px; cursor: pointer; text-align: left;
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
}
.inst-row:hover { background: #1b222c; border-color: #3d4753; }
.inst-row.is-on { background: #14262c; border-color: var(--cyan); }
.inst-row.is-off { opacity: .45; }
.inst-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; font-style: normal; }
.inst-row .in-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-row.is-on .in-nm { color: #e6edf3; font-weight: 600; }
.inst-row .in-cost { font-size: 10px; color: var(--dim); white-space: nowrap; }

.act-row { border-top: 1px solid var(--border2); padding: 5px 0 4px; }
.act-hd { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; }
.act-bar { height: 4px; background: #0b0f14; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.act-bar i { display: block; height: 100%; background: var(--cyan); transition: width .2s linear; }

/* THE CAVEAT — pinned in the panel footer so it is never scrolled away,
   and always read BEFORE the instrument is run. SPEC §6. */
.caveat {
  border: 1px solid #6b5518;
  border-left: 3px solid var(--amber);
  background: #1d1a10;
  border-radius: 0 4px 4px 0;
  padding: 6px 9px 7px;
}
.caveat.empty { border-color: var(--border2); border-left-color: #3d4753; background: #131820; }
.cav-kick {
  font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--amber);
  display: flex; justify-content: space-between; gap: 8px;
}
.caveat.empty .cav-kick { color: var(--dim); }
.cav-tx { font-size: 11.5px; line-height: 1.45; color: #f0d38a; margin-top: 3px; }
.caveat.empty .cav-tx { color: var(--dim); font-style: italic; }
.cav-ack {
  display: flex; align-items: center; gap: 6px; margin-top: 5px;
  font-size: 10.5px; color: #e3b341; cursor: pointer; user-select: none;
}
.cav-ack input { width: auto; accent-color: var(--amber); cursor: pointer; margin: 0; flex: 0 0 auto; }
.cav-ack.is-done { color: var(--green); }
#rs-run { margin-top: 5px; padding: 5px 10px; font-size: 10.5px; }
#rs-msg { margin-top: 4px; }
#rs-msg .ok-note, #rs-msg .err-note, #rs-msg .warn-note { font-size: 11px; padding: 4px 7px; }
.p-research .panel-ft { padding: 6px 9px; }

.ok-note {
  padding: 5px 8px; border-radius: 4px; background: #12281a; border: 1px solid #2b6c39;
  color: #8ff0a4; font-size: 11.5px; line-height: 1.45; white-space: normal;
}
.err-note {
  padding: 5px 8px; border-radius: 4px; background: #3a1717; border: 1px solid #6b2b2b;
  color: #ffb3ad; font-size: 11.5px; line-height: 1.45; white-space: normal;
}
.warn-note {
  padding: 5px 8px; border-radius: 4px; background: #2a2210; border: 1px solid #6b5518;
  color: #e3b341; font-size: 11.5px; line-height: 1.45; white-space: normal;
}

/* --- roadmap + gantt --- */
.p-gantt { flex: 0 0 268px; }
.p-order { flex: 1 1 auto; }
.rm-row {
  display: grid; grid-template-columns: 16px minmax(0,1fr) auto;
  gap: 5px; align-items: center;
  background: var(--panel2); border: 1px solid var(--border2);
  border-left: 2px solid var(--cyan);
  border-radius: 0 3px 3px 0; padding: 4px 6px; margin-bottom: 4px;
}
.rm-row.is-building { border-left-color: var(--amber); }
.rm-row.is-shipped  { border-left-color: var(--green); opacity: .85; }
.rm-row.is-dropped  { border-left-color: #4a545f; opacity: .45; }
.rm-n { font-size: 11px; color: var(--dim); text-align: center; }
.rm-nm { font-size: 11.5px; color: #e6edf3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-sub { font-size: 10px; color: var(--dim); }
.rm-sub .slip { color: var(--red); font-weight: 600; }
.rm-btns { display: flex; gap: 3px; }
.rm-btns .btn { padding: 1px 5px; font-size: 10px; }

/* --- org feed --- */
.p-feed .panel-hd { background: linear-gradient(180deg, #1d2530, #171c24); }
.stk-strip {
  flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--border2); border-bottom: 1px solid var(--border);
}
.stk { background: #131820; padding: 3px 4px; text-align: center; }
.stk .n { font-size: 9px; letter-spacing: .06em; color: var(--dim); display: block; }
.stk .v { font-size: 13px; font-weight: 700; display: block; line-height: 1.15; }
.stk .d { font-size: 8.5px; display: block; line-height: 1.1; }
.feed-bd { padding: 6px 8px; }
.msg {
  border-left: 2px solid var(--border);
  background: var(--panel2);
  border-radius: 0 4px 4px 0;
  padding: 6px 9px;
  margin-bottom: 6px;
  animation: msgIn .28s ease-out;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-who { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.msg-role { font-size: 9px; color: var(--dim); letter-spacing: .1em; }
.msg-tm { font-size: 10px; color: #6b737d; white-space: nowrap; }
.msg-tx { font-size: 12px; line-height: 1.5; color: #d6dde5; white-space: pre-wrap; word-break: break-word; }

.msg.from-CEO      { border-left-color: var(--violet); }
.msg.from-CEO      .msg-who { color: #b98bff; }
.msg.from-SALES    { border-left-color: #e69f00; }
.msg.from-SALES    .msg-who { color: #e69f00; }
.msg.from-ENG      { border-left-color: var(--cyan); }
.msg.from-ENG      .msg-who { color: var(--cyan); }
.msg.from-DESIGN   { border-left-color: #cc79a7; }
.msg.from-DESIGN   .msg-who { color: #cc79a7; }
.msg.from-SUPPORT  { border-left-color: #34c98b; }
.msg.from-SUPPORT  .msg-who { color: #34c98b; }
.msg.from-CUSTOMER { border-left-color: #f0e442; }
.msg.from-CUSTOMER .msg-who { color: #f0e442; }
.msg.from-SYS      { border-left-color: #3d4753; background: #10151b; }
.msg.from-SYS      .msg-who { color: #6b737d; }
.msg.from-SYS      .msg-tx { color: var(--dim); font-size: 11px; }

.msg.tone-pressure { background: #1f2129; }
.msg.tone-warn  { background: #241f11; border-left-color: var(--amber); }
.msg.tone-alarm { background: #2c1414; border-left-color: var(--red); }
.msg.tone-alarm .msg-who { color: var(--red); }
.msg.tone-praise { background: #14231a; }

.reply-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; padding-top: 5px; border-top: 1px dashed #3d4753; }
.reply-lbl { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); width: 100%; }
.msg.needs-reply { box-shadow: inset 0 0 0 1px rgba(210,153,34,.35); }

.esc-pin {
  border: 1px dashed var(--amber); background: #251f10; color: var(--amber);
  border-radius: 4px; padding: 5px 8px; margin-bottom: 7px; font-size: 11px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer;
}
.esc-pin:hover { background: #2f2712; }
.feed-gate {
  border: 1px dashed var(--cyan); background: #0f1f26; color: var(--cyan);
  border-radius: 4px; padding: 5px 8px; margin-bottom: 6px; font-size: 11px;
}
.empty-note { color: #5b636d; font-size: 11px; padding: 10px 4px; text-align: center; }

/* ---------- toasts ----------
   Top-centre, NOT bottom-centre: the bottom-centre of the desk is the
   research panel's caveat + run button, and nothing may ever cover that. */
.toasts {
  position: absolute; right: 16px; top: 92px;
  display: flex; flex-direction: column; gap: 6px; z-index: 60;
  pointer-events: none; align-items: flex-end; max-width: 380px;
}
.toast {
  background: #1c222b; border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 4px; padding: 6px 14px; font-size: 11.5px; color: var(--text);
  box-shadow: 0 6px 20px rgba(0,0,0,.55);
  animation: toastIn .2s ease-out; max-width: 380px; line-height: 1.4;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.ok   { border-left-color: var(--green); }
.toast.err  { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast.info { border-left-color: var(--cyan); }

/* ============================================================
   MODALS (gate / commit / drop / confirm)
   ============================================================ */
#modal-layer { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-layer.active { display: block; }
.modal-bg {
  position: absolute; inset: 0; background: rgba(4,7,10,.78);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: 100%; max-width: 640px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0,0,0,.7);
  animation: modalIn .18s ease-out;
  max-height: 86vh; display: flex; flex-direction: column;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-hd {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-hd h3 { margin: 0; font-size: 15px; letter-spacing: .1em; color: #e6edf3; font-weight: 600; }
.modal-bd { padding: 16px 18px; overflow: auto; }
.modal-ft { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal.gate { border-color: var(--cyan); }
.modal.gate .modal-hd { background: #10222a; }
.modal.gate .modal-hd h3 { color: var(--cyan); }
.modal.danger { border-color: #6b2b2b; }
.modal.danger .modal-hd h3 { color: var(--red); }
.gate-kicker { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); }
.gate-prompt { font-size: 15px; line-height: 1.6; color: #e6edf3; margin: 0 0 14px; }
.gate-clock { font-size: 11px; color: var(--dim); }
.gate-list { margin: 0; padding-left: 18px; color: var(--dim); font-size: 12px; line-height: 1.7; }
.gate-paused {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--amber);
  border: 1px solid #6b5518; border-radius: 3px; padding: 2px 7px;
}

/* commit dialog */
.cm-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.cm-nm { font-size: 16px; font-weight: 600; color: #e6edf3; }
.cm-desc { font-size: 12px; line-height: 1.6; color: var(--dim); margin: 0 0 12px; }
.cm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.cm-grid .lbl { display: block; }
.cm-grid .v { font-size: 15px; font-weight: 600; color: #e6edf3; }
.cm-fld { margin-bottom: 11px; }
.cm-fld > .lbl { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.cm-fld .req { color: var(--amber); }
.cm-fld .okc { color: var(--green); }
#cm-impact { font-size: 17px; font-weight: 600; text-align: right; padding: 7px 9px; max-width: 170px; }
#cm-rat, #rp-rat { height: 74px; font-size: 12px; }
#cm-rat.needed { border-color: #6b5518; background: #14120b; }
.cm-ev { border: 1px solid var(--border2); border-radius: 4px; padding: 7px 9px; background: #131820; margin-bottom: 12px; }
.cm-ev .rdrow { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }

/* ============================================================
   SCREEN 3 — QBR
   ============================================================ */
.qbr-wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 22px 34px; }
.qbr-grid { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 14px; margin-top: 16px; }
#qb-narr { height: 250px; font-size: 12.5px; }
#qb-claim { font-size: 20px; font-weight: 700; text-align: right; padding: 8px 10px; max-width: 200px; }
.qbr-hint { font-size: 11.5px; color: var(--dim); line-height: 1.65; }

/* ============================================================
   SCREEN 4 — DEBRIEF
   ============================================================ */
.db-wrap { width: 100%; max-width: 1340px; margin: 0 auto; padding: 22px 22px 40px; }
.db-hero {
  display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  padding: 16px 20px; margin: 14px 0 14px;
}
.grade-big { font-size: 64px; font-weight: 700; line-height: .95; letter-spacing: -.02em; text-align: center; }
.grade-sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); text-align: center; margin-top: 4px; }
.grade-A { color: var(--green); } .grade-B { color: #8ff0a4; }
.grade-C { color: var(--amber); } .grade-D { color: #ff9d97; } .grade-F { color: var(--red); }
.db-kv { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 14px; }
.db-kv .lbl { display: block; }
.db-kv .v { font-size: 16px; font-weight: 600; color: #e6edf3; }
.db-cap { margin-top: 10px; }
.db-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 14px; }
.truth-host { position: relative; height: 480px; background: var(--panel3); border-radius: 4px; overflow: hidden; }
.truth-host canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tbl-wrap { max-height: 330px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.tbl-wrap table.tbl th { background: var(--panel2); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel); color: var(--dim); font-weight: 500;
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
  text-align: left; padding: 4px 7px; border-bottom: 1px solid var(--border);
}
table.tbl td { padding: 3px 7px; border-bottom: 1px solid #1b2028; white-space: nowrap; }
table.tbl td.r, table.tbl th.r { text-align: right; }
table.tbl td.wrap { white-space: normal; line-height: 1.45; }
table.tbl tr:hover td { background: #1b212a; }
.verdict { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }

.trust-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid #1b2028; }
.trust-bar { height: 7px; background: #0b0f14; border: 1px solid var(--border2); border-radius: 3px; overflow: hidden; }
.trust-bar i { display: block; height: 100%; background: var(--green); }
.trust-bar i.mid { background: var(--amber); }
.trust-bar i.low { background: var(--red); }

/* the reveal notes — the per-feature truth, in words */
.note-row {
  border-left: 2px solid var(--border);
  background: var(--panel2);
  border-radius: 0 4px 4px 0;
  padding: 7px 10px 8px;
  margin-bottom: 7px;
}
.note-row.is-shipped { border-left-color: var(--green); background: #16211a; }
.nr-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.nr-nm { font-size: 12.5px; font-weight: 600; color: #e6edf3; }
.nr-v { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.nr-tx { font-size: 12px; line-height: 1.6; color: #d6dde5; margin-top: 3px; }

#db-copyarea { margin-top: 10px; }
#db-copyarea textarea { height: 200px; font-size: 10.5px; }

/* ============================================================
   DIAGNOSTICS (defensive boot)
   ============================================================ */
.diag-wrap { padding: 40px 32px; max-width: 940px; margin: 0 auto; overflow: auto; height: 100%; }
.diag-wrap h1 { font-size: 18px; letter-spacing: .12em; color: var(--red); margin: 0 0 6px; }
.diag-tbl { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 12px; }
.diag-tbl th, .diag-tbl td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.diag-tbl th { color: var(--dim); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; }
.diag-ok { color: var(--green); }
.diag-bad { color: var(--red); font-weight: 700; }
.diag-box {
  background: var(--panel); border: 1px solid var(--border); border-left: 2px solid var(--amber);
  border-radius: 4px; padding: 12px 14px; margin-top: 16px; font-size: 12px; line-height: 1.7;
}
.errbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: #3a1717; border-top: 1px solid var(--red); color: #ffb3ad;
  font-size: 11px; padding: 6px 12px; display: flex; justify-content: space-between; gap: 12px;
}

/* ---------- narrow / short safety ---------- */
@media (max-width: 1400px) {
  .desk-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr) 268px 308px; }
  .clock { font-size: 22px; }
}
@media (max-width: 1240px) {
  .desk-grid {
    grid-template-columns: minmax(0,1fr) minmax(0,1fr) 300px;
    grid-template-rows: minmax(0,1fr) 380px;
    grid-template-areas:
      "board viz      feed"
      "board research feed";
  }
  .p-roadmap { display: none; }
}
@media (max-height: 860px) {
  .desk-grid { grid-template-rows: minmax(0,1fr) 380px; }
  .p-gantt { flex: 0 0 236px; }
  .clock { font-size: 22px; }
  .truth-host { height: 430px; }
}
