/* ============================================================
   NEXUS  -  UI chrome
   ============================================================ */
:root {
  /* aligned to the platform's LIGHT theme (warm editorial paper) + blue accent */
  --bg: #f3f0e8;
  --accent: #2456cc;
  --cyan: #2563eb;     /* brand highlight (legible blue on paper) */
  --teal: #0d9669;     /* organisations */
  --pink: #e11d48;     /* events */
  --purple: #7c3aed;   /* initiatives */
  --amber: #d97706;    /* locations / warn */
  --green: #16a34a;    /* funding / good */
  --blue: #2563eb;     /* partnership / info */
  --ink: #1c2230;
  --dim: #5d6473;
  --panel: rgba(255, 253, 249, 0.86);
  --panel-solid: #fffdf9;
  --border: #e6e0d2;
  --border-bright: #d6cfbd;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg);
  font-family: var(--ui); color: var(--ink);
  overflow: hidden; user-select: none;
  -webkit-font-smoothing: antialiased;
}
/* tabular / code bits keep the platform's mono face */
.brand .ver, .sync .clock, .pill b, #conncount, .statusbar b, #zoomval,
.rk-i, .rk-v, .stat .v, .dossier .dcode, kbd, .score-v,
.fund-cell .fv, .pri-ring span, .res-item .rt, .conn-item .ck, #datestamp {
  font-family: var(--mono);
}
#stage { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#scene.dragging { cursor: grabbing; }

/* ---- atmospheric overlays ---- */
.fx-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(120% 120% at 50% 42%, transparent 62%, rgba(60,52,34,0.08) 100%);
}
.fx-scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0;
  background: repeating-linear-gradient(0deg, rgba(40,36,28,0.035) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}
.fx-grain { position: fixed; inset: 0; pointer-events: none; z-index: 6; opacity: 0;
  background-image: radial-gradient(rgba(255,255,255,0.5) 0.5px, transparent 0.5px);
  background-size: 3px 3px; }

/* ---- generic glass panel ---- */
.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 6px -3px rgba(40,33,20,0.12),
    0 22px 50px -26px rgba(40,33,20,0.28);
}
.corner { position: relative; }
.corner::before, .corner::after {
  content: ""; position: absolute; width: 9px; height: 9px; border: 1px solid var(--border-bright);
}
.corner::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.corner::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }

/* ================= TOP BAR ================= */
.topbar {
  position: fixed; top: 14px; left: 14px; right: 14px; height: 46px; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 14px 0 16px;
  border-radius: 4px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .dot { width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #cfe0ff, var(--cyan));
  box-shadow: 0 0 12px var(--cyan), 0 0 4px #fff; animation: corepulse 2.4s infinite; }
@keyframes corepulse { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.6;transform:scale(.82);} }
.brand .name { font-size: 15px; font-weight: 700; letter-spacing: 1.5px; }
.brand .name b { color: var(--cyan); }
.brand .ver { color: var(--dim); font-size: 11px; letter-spacing: 1px; }
.bar-sep { width: 1px; height: 22px; background: var(--border); }
.sync { font-size: 11.5px; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.sync .label { color: var(--dim); }
.sync .clock { color: var(--green); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--border); background: rgba(40,36,28,0.05); font-size: 11px; letter-spacing: .8px; }
.pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill b { color: var(--cyan); }
.spacer { flex: 1; }
.feed { display: flex; align-items: center; gap: 9px; max-width: 360px; overflow: hidden; }
.feed .tag { color: var(--dim); font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; }
.feed .ticker { color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.feed .ticker em { color: var(--amber); font-style: normal; }
.iconbtn { width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border);
  background: rgba(40,36,28,0.04); color: var(--dim); display: grid; place-items: center;
  cursor: pointer; transition: .15s; }
.iconbtn:hover { color: var(--cyan); border-color: var(--border-bright); background: rgba(96,165,250,0.08); }
.iconbtn svg { width: 15px; height: 15px; }

/* ================= LEFT RAIL (matches the cluster-map Filters card) ================= */
.rail { position: fixed; left: 16px; top: 74px; width: 222px; z-index: 18;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 18px;
  padding: 14px; backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: 0 2px 6px -3px rgba(40,33,20,0.12), 0 18px 44px -24px rgba(40,33,20,0.24); }
.rail-head { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.rail-ic { width: 15px; height: 15px; color: var(--accent); flex: none; }
.rail-title { font-size: 13px; font-weight: 650; color: var(--ink); letter-spacing: -0.005em; }
.rail-sp { flex: 1; }
.rail-chev { width: 15px; height: 15px; color: var(--dim); transition: transform .18s; }
.rail.collapsed .rail-chev { transform: rotate(-90deg); }
.rail.collapsed .rail-body { display: none; }
.rail-body { margin-top: 13px; }
.grp-label { font-size: 11px; font-weight: 650; color: var(--dim); margin-bottom: 8px; }
.grp-label.sub { margin-top: 15px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-row { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 9px;
  border-radius: 999px; border: 1px solid var(--border); background: rgba(40,36,28,0.04);
  cursor: pointer; transition: .14s; font-size: 11.5px; font-weight: 550; color: var(--ink); }
.legend-row:hover { border-color: var(--accent); background: rgba(96,165,250,0.10); }
.legend-row.off { opacity: 0.42; }
.legend-row.off:hover { opacity: 0.7; }
.legend-row .sw, .legend-row .glyph { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend-row .glyph { display: block; font-size: 0; }
.legend-row .nm { font-size: 11.5px; letter-spacing: 0; }
.legend-row .ct { font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.subhead { display: none; }
.conn-row { display: flex; align-items: center; gap: 9px; padding: 4px 2px; font-size: 11.5px; letter-spacing: 0; color: var(--dim); }
.conn-row .line { width: 18px; height: 3px; border-radius: 2px; flex: none; }

/* ================= SEARCH ================= */
.search { position: fixed; left: 262px; top: 74px; width: 300px; z-index: 19; }
.search-box { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 4px; }
.search-box svg { width: 15px; height: 15px; color: var(--dim); flex: none; }
.search-box input { flex: 1; background: none; border: 0; outline: 0; color: var(--ink);
  font-family: var(--ui); font-size: 12.5px; letter-spacing: .6px; }
.search-box input::placeholder { color: var(--dim); }
.search-box kbd { font-size: 10px; color: var(--dim); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.results { margin-top: 6px; border-radius: 4px; overflow: hidden; max-height: 320px; overflow-y: auto; display: none; }
.results.open { display: block; }
.res-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid rgba(190,182,160,0.1); transition: .12s; }
.res-item:hover, .res-item.active { background: rgba(96,165,250,0.1); }
.res-item .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; box-shadow: 0 0 8px currentColor; }
.res-item .info { flex: 1; min-width: 0; }
.res-item .rn { font-size: 12px; letter-spacing: .4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-item .rt { font-size: 10px; color: var(--dim); letter-spacing: 1px; }
.res-empty { padding: 14px; text-align: center; color: var(--dim); font-size: 11px; }

/* ================= DETAIL DOSSIER ================= */
.dossier { position: fixed; right: 14px; top: 74px; bottom: 64px; width: 332px; z-index: 19;
  border-radius: 4px; padding: 0; display: flex; flex-direction: column;
  transform: translateX(calc(100% + 24px)); transition: transform .42s cubic-bezier(.2,.8,.2,1);
  overflow: hidden; }
.dossier.open { transform: translateX(0); }
.dossier .dhead { padding: 14px 15px 13px; border-bottom: 1px solid var(--border); position: relative; }
.dossier .dhead .typetag { display: inline-flex; align-items: center; gap: 7px; font-size: 10px; letter-spacing: 2px;
  padding: 4px 9px; border-radius: 20px; border: 1px solid currentColor; }
.dossier .dhead .typetag .sw { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 7px currentColor; }
.dossier .close { position: absolute; right: 12px; top: 13px; width: 26px; height: 26px; }
.dossier .dname { margin: 12px 0 3px; font-size: 19px; font-weight: 700; letter-spacing: .4px; line-height: 1.15; }
.dossier .dcode { font-size: 11px; color: var(--dim); letter-spacing: 1.5px; }
.dbody { flex: 1; overflow-y: auto; padding: 14px 15px 18px; }
.dbody::-webkit-scrollbar, .results::-webkit-scrollbar { width: 7px; }
.dbody::-webkit-scrollbar-thumb, .results::-webkit-scrollbar-thumb { background: rgba(190,182,160,0.3); border-radius: 4px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 15px; }
.stat { border: 1px solid var(--border); border-radius: 4px; padding: 9px 10px; background: rgba(40,36,28,0.03); }
.stat .k { font-size: 9.5px; letter-spacing: 1.4px; color: var(--dim); margin-bottom: 4px; }
.stat .v { font-size: 13px; font-weight: 600; letter-spacing: .5px; }
.stat .v.ok { color: var(--green); } .stat .v.warn { color: var(--amber); } .stat .v.bad { color: var(--pink); }
.meter { height: 5px; border-radius: 3px; background: rgba(40,36,28,0.12); overflow: hidden; margin-top: 6px; }
.meter > i { display: block; height: 100%; border-radius: 3px; }
.sectlabel { font-size: 9.5px; letter-spacing: 2px; color: var(--dim); margin: 4px 0 9px; display: flex; align-items: center; gap: 8px; }
.sectlabel::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.summary { font-size: 12px; line-height: 1.65; color: #5d6473; margin-bottom: 16px; text-wrap: pretty; }
.conn-list { display: flex; flex-direction: column; gap: 4px; }
.conn-item { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 4px; cursor: pointer;
  border: 1px solid transparent; transition: .14s; }
.conn-item:hover { background: rgba(96,165,250,0.08); border-color: var(--border); }
.conn-item .sw { width: 8px; height: 8px; border-radius: 2px; flex: none; box-shadow: 0 0 7px currentColor; }
.conn-item .ci { flex: 1; min-width: 0; }
.conn-item .cn { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-item .ck { font-size: 9px; letter-spacing: 1px; color: var(--dim); }
.conn-item .arr { color: var(--dim); font-size: 13px; }
.conn-item.nohov { cursor: default; }
.conn-item.nohov:hover { background: none; border-color: transparent; }

.hint-line { font-size: 10px; letter-spacing: .4px; color: var(--dim); margin: -2px 0 9px; opacity: .85; }

.how-connect { border: 1px solid var(--border); border-radius: 5px; padding: 11px 12px; margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(96,165,250,0.07), rgba(96,165,250,0.02)); font-size: 12px; letter-spacing: .4px; color: #5d6473; }
.how-connect b { color: #1c2230; font-weight: 700; }
.how-connect .dot { color: var(--dim); margin: 0 8px; }
.how-connect .warn { color: var(--amber); font-size: 10.5px; letter-spacing: .5px; margin-top: 6px; }

/* ===== relationship breakdown (multi-select) ===== */
.rel-break { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.rel-pair { border: 1px solid var(--border); border-radius: 6px; padding: 11px 12px;
  background: rgba(40,36,28,0.03); position: relative; }
.rel-title { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; font-weight: 600;
  letter-spacing: .3px; color: #1c2230; line-height: 1.5; padding-right: 58px; }
.rel-title .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 7px currentColor; }
.rel-title .rel-vs { color: var(--dim); margin: 0 1px; }
.rel-badge { position: absolute; top: 10px; right: 11px; font-size: 8.5px; letter-spacing: 1.5px; font-weight: 700;
  padding: 3px 7px; border-radius: 20px; }
.rel-badge.direct { color: #0a1a10; background: var(--green); }
.rel-badge.indirect { color: var(--amber); border: 1px solid var(--amber); }
.rel-exp { font-size: 11.5px; line-height: 1.6; color: #5d6473; margin: 9px 0 2px; text-wrap: pretty; }
.rel-exp.warn { color: var(--amber); }
.rel-exp b { color: #1c2230; font-weight: 600; }
.rel-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; margin-top: 9px;
  padding-top: 9px; border-top: 1px solid rgba(190,182,160,0.13); }
.chain-node { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; letter-spacing: .2px;
  padding: 3px 8px; border-radius: 14px; border: 1px solid var(--border); background: rgba(255,253,249,0.6);
  transition: .14s; white-space: nowrap; }
.chain-node:hover { background: rgba(96,165,250,0.12); }
.chain-node .cd { width: 7px; height: 7px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.chain-node.end { color: #1c2230; font-weight: 600; }
.chain-node.mid { color: #5d6473; }
.chain-rel { display: inline-flex; align-items: center; gap: 4px; font-size: 8.5px; letter-spacing: 1px; font-weight: 600; }
.chain-rel .rl { width: 12px; height: 2px; border-radius: 2px; box-shadow: 0 0 5px currentColor; }

/* selected-entity chips (comparison panel) */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ent-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 4px;
  border: 1px solid var(--border); background: rgba(40,36,28,0.05); font-size: 11px; letter-spacing: .3px;
  cursor: pointer; transition: .14s; max-width: 100%; }
.ent-chip:hover { background: rgba(251,113,133,0.12); border-color: var(--pink) !important; }
.ent-chip .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 7px currentColor; }
.ent-chip .cn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.ent-chip .x { color: var(--dim); font-size: 13px; margin-left: 2px; }
.ent-chip:hover .x { color: var(--pink); }

/* ================= STATUS BAR ================= */
.statusbar { position: fixed; left: 14px; right: 14px; bottom: 14px; height: 40px; z-index: 18;
  border-radius: 4px; display: flex; align-items: center; gap: 18px; padding: 0 16px; font-size: 11px; letter-spacing: .8px; }
.statusbar .item { display: flex; align-items: center; gap: 8px; color: var(--dim); }
.statusbar .item b { color: var(--ink); font-weight: 600; }
.statusbar .depthbar { width: 130px; height: 4px; border-radius: 3px; background: rgba(40,36,28,0.12); overflow: hidden; }
.statusbar .depthbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--purple)); }
.statusbar .hint { color: var(--dim); }
.statusbar .hint b { color: var(--cyan); }

/* ================= TOOLTIP ================= */
#tooltip { position: fixed; z-index: 30; pointer-events: none; padding: 7px 11px; border-radius: 4px;
  font-size: 11px; letter-spacing: .5px; white-space: nowrap; opacity: 0; transform: translateY(4px);
  transition: opacity .12s; border: 1px solid var(--border-bright); background: rgba(255,253,249,0.92); }
#tooltip.show { opacity: 1; transform: translateY(0); }
#tooltip .tt { font-size: 9px; letter-spacing: 1.5px; }

.fadein { animation: fadein .6s both; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ===== 4D / 2D view toggle ===== */
.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.viewtoggle button { background: rgba(40,36,28,0.04); color: var(--dim); border: 0; padding: 6px 13px;
  font-family: var(--ui); font-size: 11px; font-weight: 650; letter-spacing: .08em; cursor: pointer; transition: .15s; }
.viewtoggle button + button { border-left: 1px solid var(--border); }
.viewtoggle button:hover { color: var(--cyan); }
.viewtoggle button.active { background: linear-gradient(180deg, rgba(96,165,250,0.22), rgba(96,165,250,0.1));
  color: #1c2230; box-shadow: inset 0 0 12px rgba(96,165,250,0.25); }

/* ===== Link Map (dossier inline) ===== */
.link-block { border: 1px solid var(--border); border-radius: 5px; background: rgba(255,253,249,0.5); margin-bottom: 15px; overflow: hidden; }
.link-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px;
  font-size: 9.5px; letter-spacing: 2px; color: var(--dim); border-bottom: 1px solid var(--border); }
.link-expand { background: rgba(96,165,250,0.08); border: 1px solid var(--border); color: var(--cyan);
  font-family: var(--ui); font-size: 9.5px; letter-spacing: 1px; padding: 3px 8px; border-radius: 3px; cursor: pointer; transition: .14s; }
.link-expand:hover { background: rgba(96,165,250,0.18); border-color: var(--border-bright); }
.mini-link { position: relative; height: 200px; display: grid; place-items: center; }
.mini-link .lv-svg { width: 100%; height: 100%; }
.lv-note { position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-size: 11px; color: var(--dim); padding: 18px; letter-spacing: .3px; }

/* shared SVG node styles */
.lv-label { font-family: var(--mono); font-size: 12px; letter-spacing: .3px; fill: #5d6473; }
.lv-edgelabel { font-family: var(--mono); font-size: 10px; letter-spacing: .5px; }
.lv-node .lv-label, .lv-node circle { transition: .14s; }
.lv-node:hover circle[stroke] { stroke-width: 3.5; }
.lv-node.lv-focus .lv-label { fill: #1c2230; font-weight: 600; }

/* ===== Link Map fullscreen overlay ===== */
#lv-overlay { position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  background: rgba(2,5,12,0.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#lv-overlay.open { display: grid; animation: fadein .25s both; }
.lv-card { width: min(1100px, 92vw); height: min(760px, 88vh); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-bright); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 30px 100px rgba(0,0,0,0.6); overflow: hidden; }
.lv-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.lv-title { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: #1c2230; }
.lv-hint { font-size: 10.5px; letter-spacing: 1px; color: var(--dim); }
.lv-close { margin-left: auto; width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border);
  background: rgba(40,36,28,0.04); color: var(--dim); font-size: 13px; cursor: pointer; transition: .15s; }
.lv-close:hover { color: var(--pink); border-color: var(--pink); }
.lv-stage { flex: 1; min-height: 0; padding: 8px 16px; }
.lv-stage .lv-svg { width: 100%; height: 100%; }
.lv-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--border); }
.lv-leg { display: inline-flex; align-items: center; gap: 7px; font-size: 10.5px; letter-spacing: 1px; color: var(--dim); }
.lv-leg i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; box-shadow: 0 0 6px currentColor; }

/* ===== heatmap control + buttons ===== */
.heatctl { display: inline-flex; align-items: center; gap: 8px; }
.hc-lab { font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
.heatctl select, .mx-axes select { background: rgba(40,36,28,0.06); color: var(--ink); border: 1px solid var(--border);
  border-radius: 4px; font-family: var(--ui); font-size: 11px; letter-spacing: .4px; padding: 5px 7px; cursor: pointer; outline: none; }
.heatctl select:hover, .mx-axes select:hover { border-color: var(--border-bright); }
.heatctl select option, .mx-axes select option { background: #f8f5ed; }
.txtbtn { background: rgba(40,36,28,0.04); color: var(--dim); border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--ui); font-size: 11px; font-weight: 650; letter-spacing: .08em; padding: 7px 11px; cursor: pointer; transition: .15s; }
.txtbtn:hover { color: var(--cyan); border-color: var(--border-bright); background: rgba(96,165,250,0.08); }
.txtbtn.on { color: #1c2230; background: linear-gradient(180deg, rgba(96,165,250,0.22), rgba(96,165,250,0.08)); box-shadow: inset 0 0 12px rgba(96,165,250,0.25); }

/* ===== heat legend ===== */
.heatlegend { position: fixed; left: 14px; bottom: 64px; z-index: 17; width: 234px; padding: 12px 13px; border-radius: 5px;
  display: none; }
.heatlegend.show { display: block; animation: fadein .25s both; }
.heatlegend .hl-title { font-size: 10.5px; letter-spacing: 1.5px; color: #1c2230; font-weight: 600; margin-bottom: 9px; }
.heatlegend .hl-bar { height: 10px; border-radius: 3px; margin-bottom: 6px;
  background: linear-gradient(90deg, #1f3a5c, #1996c8 28%, #19c896 50%, #f0c846 72%, #ff465a); }
.heatlegend .hl-scale { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: .5px; color: var(--dim); }
.heatlegend .hl-note { font-size: 9px; letter-spacing: .4px; color: var(--dim); margin-top: 8px; opacity: .8; }

/* ===== ranked priority panel ===== */
.rankpanel { position: fixed; left: 14px; top: 74px; bottom: 64px; width: 318px; z-index: 21; border-radius: 5px;
  display: flex; flex-direction: column; transform: translateX(calc(-100% - 24px)); transition: transform .4s cubic-bezier(.2,.8,.2,1); overflow: hidden; }
.rankpanel.open { transform: translateX(0); }
.rank-head { display: flex; align-items: center; gap: 9px; padding: 13px 13px; border-bottom: 1px solid var(--border); }
.rank-head > span:first-child { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: #1c2230; }
.rank-by { font-size: 10px; letter-spacing: .8px; color: var(--dim); }
.rank-by b { color: var(--cyan); }
.rank-head .iconbtn { margin-left: auto; width: 26px; height: 26px; }
.rank-body { flex: 1; overflow-y: auto; padding: 6px; }
.rank-body::-webkit-scrollbar { width: 7px; }
.rank-body::-webkit-scrollbar-thumb { background: rgba(190,182,160,0.3); border-radius: 4px; }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 4px; cursor: pointer; transition: .12s; }
.rank-row:hover { background: rgba(96,165,250,0.08); }
.rk-i { width: 22px; font-size: 11px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.rk-sw { width: 8px; height: 8px; border-radius: 2px; flex: none; box-shadow: 0 0 6px currentColor; }
.rk-name { flex: 1; font-size: 11.5px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-type { font-size: 9px; color: var(--dim); border: 1px solid var(--border); border-radius: 3px; width: 15px; text-align: center; }
.rk-bar { width: 56px; height: 5px; border-radius: 3px; background: rgba(40,36,28,0.12); overflow: hidden; flex: none; }
.rk-bar i { display: block; height: 100%; border-radius: 3px; }
.rk-v { width: 22px; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ===== priority matrix overlay ===== */
#mx-overlay { position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  background: rgba(2,5,12,0.8); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#mx-overlay.open { display: grid; animation: fadein .25s both; }
.mx-card { width: min(1180px, 94vw); height: min(820px, 90vh); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-bright); border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 30px 100px rgba(0,0,0,0.6); overflow: hidden; }
.mx-head { display: flex; align-items: center; gap: 16px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.mx-title { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: #1c2230; }
.mx-axes { font-size: 10.5px; letter-spacing: 1px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.mx-close { margin-left: auto; width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border);
  background: rgba(40,36,28,0.04); color: var(--dim); font-size: 13px; cursor: pointer; transition: .15s; }
.mx-close:hover { color: var(--pink); border-color: var(--pink); }
.mx-stage { flex: 1; min-height: 0; padding: 8px 14px; }
.mx-svg { width: 100%; height: 100%; }
.mx-foot { padding: 10px 16px; border-top: 1px solid var(--border); }
.mx-hint { font-size: 10.5px; letter-spacing: .8px; color: var(--dim); }
.mx-axislabel { font-family: var(--mono); font-size: 12px; letter-spacing: 1.5px; fill: #5d6473; }
.mx-quad { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 2px; opacity: .8; }
.mx-blabel { font-family: var(--mono); font-size: 10px; fill: #5d6473; }
.mx-bub circle:first-child { transition: fill-opacity .14s; }
.mx-bub:hover circle:first-child { fill-opacity: 0.6; }

/* ===== dossier: funding / prioritisation profile ===== */
.pri-headline { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; padding: 12px;
  border: 1px solid var(--border); border-radius: 6px; background: rgba(40,36,28,0.03); }
.pri-ring { width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative; }
.pri-ring::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #f8f5ed; }
.pri-ring span { position: relative; z-index: 1; font-size: 18px; font-weight: 700; color: #1c2230; }
.pri-meta { flex: 1; min-width: 0; }
.pri-lab { font-size: 9.5px; letter-spacing: 1.5px; color: var(--dim); }
.pri-rank { font-size: 12px; color: var(--ink); margin: 3px 0 6px; }
.pri-rank b { color: var(--cyan); }
.pri-next { font-size: 11.5px; color: var(--green); letter-spacing: .2px; line-height: 1.4; }

.score-bars { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.score-row { display: flex; align-items: center; gap: 9px; }
.score-k { width: 132px; font-size: 10.5px; letter-spacing: .3px; color: #5d6473; flex: none; }
.score-k .inv { color: var(--dim); font-size: 9px; }
.score-track { flex: 1; height: 7px; border-radius: 4px; background: rgba(40,36,28,0.1); overflow: hidden; }
.score-track i { display: block; height: 100%; border-radius: 4px; }
.score-v { width: 22px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink); }

.prof-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
.prof { border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; background: rgba(40,36,28,0.03); }
.prof .pk { font-size: 9px; letter-spacing: 1.3px; color: var(--dim); margin-bottom: 4px; }
.prof .pv { font-size: 12px; letter-spacing: .3px; color: var(--ink); }
.aim-box { font-size: 12px; line-height: 1.6; color: #5d6473; border-left: 2px solid var(--teal); padding: 4px 0 4px 11px; margin-bottom: 16px; text-wrap: pretty; }

.fund-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 8px; }
.fund-cell { border: 1px solid var(--border); border-radius: 4px; padding: 9px 10px; background: rgba(40,36,28,0.03); text-align: center; }
.fund-cell .fk { font-size: 9px; letter-spacing: 1.3px; color: var(--dim); margin-bottom: 4px; }
.fund-cell .fv { font-size: 15px; font-weight: 700; color: var(--ink); }
.fund-cell .fv.warn { color: var(--amber); }
.fund-bar { height: 6px; border-radius: 3px; background: rgba(251,191,36,0.16); overflow: hidden; margin-bottom: 12px; }
.fund-bar i { display: block; height: 100%; border-radius: 3px; background: var(--teal); }
.enable-box { font-size: 11.5px; line-height: 1.55; color: #5d6473; padding: 10px 11px; border: 1px solid var(--border);
  border-radius: 5px; background: rgba(52,211,153,0.04); margin-bottom: 16px; }
.enable-box .pk { font-size: 9px; letter-spacing: 1.3px; color: var(--teal); margin-bottom: 5px; }

.chip-row2 { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.need-chip { font-size: 10.5px; letter-spacing: .3px; padding: 5px 9px; border-radius: 14px; border: 1px solid var(--border);
  background: rgba(40,36,28,0.05); color: #5d6473; }
.people-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.person-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; transition: .14s; }
.person-chip:hover { background: rgba(96,165,250,0.08); border-color: var(--border); }
.person-chip img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--border-bright); }
.person-chip .pcname { font-size: 12px; color: var(--ink); }
.person-chip .pcrole { font-size: 10px; color: var(--dim); letter-spacing: .4px; }
.risk-box { font-size: 12px; line-height: 1.6; color: #a85a16; border-left: 2px solid var(--amber); padding: 4px 0 4px 11px; margin-bottom: 6px; }

@media (max-width: 920px) {
  .search { left: 14px; top: 128px; width: 234px; }
  .feed { display: none; }
}
