@font-face {
  font-family: "Figtree";
  src: url("./fonts/figtree-var.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #001740; --bg2: #002c77; --ink: #ffffff; --muted: rgba(255,255,255,0.6);
  --accent: #2ea3f2; --accent-strong: #1683d8; --line: rgba(255,255,255,0.12);
  --ext: #3ecf8e; --int: #f47c7c; --conf: #b48df2;
  --ok: #3ecf8e; --warn: #f2b544; --bad: #f47c7c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: radial-gradient(1200px 800px at 50% 45%, var(--bg2), var(--bg)); color: var(--ink); font: 14px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
#brainCanvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#brandBar {
  position: fixed; top: 0; left: 0; right: 0; height: 58px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  background: linear-gradient(to bottom, rgba(0,23,64,0.75), rgba(0,23,64,0));
  letter-spacing: 0.5px; z-index: 5; pointer-events: none;
  white-space: nowrap; overflow: hidden;
  font-size: clamp(13px, 3.8vw, 16px);
}
#brandLogo { width: 26px; height: 26px; flex: none; align-self: center; }
.brand-lockup {
  display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: baseline;
}
.brand-ms { grid-column: 1; grid-row: 1; font-weight: 800; color: #fff; }
.brand-word { grid-column: 2; grid-row: 1; font-weight: 800; color: #fff; }
.brand-sub {
  grid-column: 2; grid-row: 2;
  font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase;
}
#snapshotStamp { position: fixed; bottom: 12px; left: 22px; color: var(--muted); font-size: 11px; z-index: 5; }
.panel { position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 90vw; background: rgba(0,23,64,0.92); backdrop-filter: blur(8px); border-left: 1px solid var(--line); padding: 24px; overflow-y: auto; z-index: 10; transform: translateX(100%); transition: transform .28s ease; }
.panel.open { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
.panel h2 { margin: 0 0 2px; font-size: 20px; }
.panel .ring-tag { text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-size: 10px; margin: 0 0 12px; }
.panel-close { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.section { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.section h3 { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.section h4 { font-size: 11px; color: var(--muted); margin: 10px 0 4px; }
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.sys { display: inline-block; min-width: 62px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.badge { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 10px; margin-left: 6px; background: rgba(255,255,255,0.08); }
.vis-ext { background: rgba(62,207,142,0.2); color: var(--ext); }
.vis-int { background: rgba(244,124,124,0.2); color: var(--int); }
.vis-conf { background: rgba(180,141,242,0.22); color: var(--conf); }
.stale { background: rgba(242,181,68,0.2); color: var(--warn); }
.sow-out { background: rgba(242,181,68,0.2); color: var(--warn); }
.sow-ok { background: rgba(62,207,142,0.2); color: var(--ext); }
.acc-ok { color: var(--ok); } .acc-warn { color: var(--warn); } .acc-bad { color: var(--bad); }
.due.overdue { color: var(--bad); font-weight: 700; }
.missing { color: var(--muted); font-style: italic; }
.chip { background: rgba(255,255,255,0.06); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 3px 10px; font-size: 12px; margin: 2px; cursor: pointer; }
.chip:hover { background: rgba(46,163,242,0.2); }

/* SB-59: hideable vertical left sidebar replaces the old top-right control
   bar. The detail panel opens on the right (z-10), so the sidebar (left,
   z-6) never competes with it for space — both can be open at once. */
#sidebarToggle {
  position: fixed; top: 70px; left: 14px; z-index: 7;
  background: rgba(0,23,64,0.55); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 14px; line-height: 1; cursor: pointer;
}
#sidebarToggle:hover { border-color: var(--accent); }

#sidebar {
  position: fixed; left: 0; top: 58px; bottom: 0; width: 240px;
  padding: 52px 14px 14px; background: rgba(0,23,64,0.88); backdrop-filter: blur(8px);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; z-index: 6; transform: translateX(0);
  transition: transform .25s var(--ease, ease);
}
body.sidebar-hidden #sidebar { transform: translateX(-100%); }

#sidebar input, #sidebar select, #sidebar button { width: 100%; background: rgba(0,23,64,0.55); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 12px; }
#sidebar button { cursor: pointer; }
#sidebar button:hover { border-color: var(--accent); }

#searchWrap { position: relative; }
#searchResults { position: static; margin-top: 6px; width: 100%; max-height: 40vh; overflow-y: auto; background: rgba(0,23,64,0.97); border: 1px solid var(--line); border-radius: 8px; }
.sr { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--ink); padding: 8px 10px; cursor: pointer; font-size: 12px; }
.sr:hover { background: rgba(46,163,242,0.16); }
.sr-kind { color: var(--muted); font-size: 10px; text-transform: uppercase; margin-right: 6px; }

#legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.leg { color: var(--muted); font-size: 10px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 5px; }
.leg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

@media (prefers-reduced-motion: reduce) { #sidebar { transition: none; } }

.sysicon { vertical-align: -2px; margin-right: 4px; opacity: 0.85; }

/* Urgency pulse: a DOM overlay of beacons tracking urgent nodes (SB-56).
   Positioned via graph.getScreenPos() on every draw(); never animated on
   the canvas itself. Node radii are 6px (13px for app chips) — the beacon
   ring sits around the node, not on top of it. */
#pulseLayer { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.pulse { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; }
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--bad);
  box-shadow: 0 0 10px 1px rgba(244,124,124,0.55);
  animation: sb-pulse 2s ease-out infinite;
}
.pulse-soon::after {
  border-color: var(--warn);
  box-shadow: 0 0 10px 1px rgba(242,181,68,0.5);
  animation-duration: 3s;
}
@keyframes sb-pulse {
  0% { transform: scale(.55); opacity: .85; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse::after { animation: none; opacity: .5; transform: scale(.8); }
}

.lock-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(800px 600px at 50% 40%, var(--bg2), var(--bg)); }
.lock-card { display: flex; flex-direction: column; gap: 12px; width: 300px; padding: 32px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 14px; text-align: center; box-shadow: 0 16px 40px rgba(0,23,64,0.13); }
.lock-logo { width: 48px; height: 48px; margin: 0 auto; }
.lock-title { margin: 0; font-size: 20px; font-weight: 800; color: #fff; }
.lock-subtitle { margin: 0 0 6px; color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.lock-card input { background: rgba(0,23,64,0.55); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 10px; }
.lock-button { background: var(--accent-strong); border: none; color: #fff; font-weight: 700; padding: 10px; border-radius: 10px; cursor: pointer; transition: background .2s cubic-bezier(0.22,1,0.36,1); }
.lock-button:hover { background: var(--accent); }
.lock-error { color: var(--bad); font-size: 12px; margin: 0; }

@media (max-width: 640px) {
  .panel { width: 100vw; max-width: 100vw; }
  /* Sidebar overlays the canvas on mobile rather than reserving layout
     space (graph inset stays 0 — see setInset call in brain-app.js). */
  #sidebar { width: min(78vw, 300px); }
}
