:root {
  --ink: #122033;
  --muted: #5a6d82;
  --bg: #e8eef3;
  --panel: rgba(244, 249, 252, 0.96);
  --line: #8fa3b8;
  --accent: #087a8c;
  --owns: #1f7a4c;
  --uses: #2f5d8c;
  --creates: #b06a12;
  --depends_on: #7a3e8c;
  --font: "Trebuchet MS", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(8, 122, 140, 0.16), transparent 55%),
    radial-gradient(700px 420px at 95% 0%, rgba(31, 78, 121, 0.12), transparent 50%),
    linear-gradient(165deg, #edf3f7, #dce6ef);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(18, 32, 51, 0.12);
  background: var(--panel);
}

.brand h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.badge {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--accent);
  font-family: var(--mono);
}

.badge a { color: var(--accent); }

.atlas-status {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.25rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid rgba(18, 32, 51, 0.15);
  background: #fff;
}

.STATUS-READY { color: #1f7a4c; border-color: #1f7a4c; }
.STATUS-BUILDING { color: #2f5d8c; border-color: #2f5d8c; }
.STATUS-OUT_OF_SYNC { color: #c9a227; border-color: #c9a227; }
.STATUS-ERROR { color: #8a3a3a; border-color: #8a3a3a; }

.institutional-header {
  grid-template-columns: 1fr 1.4fr 1fr;
}

.inst-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-content: start;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.header-actions button {
  border: 1px solid #8fa3b8;
  background: #f7fbfe;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.header-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}


.selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.6rem;
  align-items: center;
}

.selectors label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.selectors select {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #8fa3b8;
  background: #f7fbfe;
  font: inherit;
  font-size: 0.82rem;
}

.link-label {
  font-size: 9px;
  fill: var(--muted);
  pointer-events: none;
  text-anchor: middle;
}

.node-circle.scene-node {
  stroke: #087a8c;
  stroke-width: 3px;
}

.node-link.scene-hit {
  background: rgba(8, 122, 140, 0.14);
}


.brand h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.badge {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--accent);
  font-family: var(--mono);
}

.search-wrap {
  position: relative;
}

.search-wrap label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

#search {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #8fa3b8;
  background: #f7fbfe;
  font: inherit;
}

.search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid #8fa3b8;
  max-height: 240px;
  overflow: auto;
}

.search-results li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.5rem 0.65rem;
  font: inherit;
  cursor: pointer;
}

.search-results li button:hover,
.search-results li button.active {
  background: rgba(8, 122, 140, 0.12);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.stat {
  background: #fff;
  border: 1px solid rgba(18, 32, 51, 0.12);
  padding: 0.35rem 0.5rem;
}

.stat b { color: var(--accent); }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  height: calc(100vh - 7.2rem);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid rgba(18, 32, 51, 0.1);
  padding: 0.85rem;
  overflow: auto;
}

.inspector-panel {
  border-right: 0;
  border-left: 1px solid rgba(18, 32, 51, 0.1);
}

.sidebar h2 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.domain-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.domain-tree details {
  margin-bottom: 0.35rem;
}

.domain-tree summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}

.domain-tree button.node-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.28rem 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}

.domain-tree button.node-link:hover,
.domain-tree button.node-link.selected {
  background: rgba(8, 122, 140, 0.12);
}

.legend {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(18, 32, 51, 0.1);
}

.legend h3 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.28rem 0;
}

.swatch {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.swatch.owns { background: var(--owns); }
.swatch.uses { background: var(--uses); }
.swatch.creates { background: var(--creates); }
.swatch.depends_on { background: var(--depends_on); }
.swatch.mapped { background: #087a8c; height: 10px; width: 10px; border-radius: 50%; }
.swatch.pending { background: #c9a227; height: 10px; width: 10px; border-radius: 50%; border: 2px dashed #6b5b2f; }

.badge a { color: var(--accent); }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  font-family: var(--mono);
  font-size: 0.68rem;
  max-width: 520px;
}

.stat.pending b { color: #a67c00; }
.stat.coverage b { color: #1f7a4c; }

.node-circle.pending-node {
  stroke: #c9a227;
  stroke-width: 3px;
  stroke-dasharray: 4 3;
}

.canvas-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(18, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 32, 51, 0.04) 1px, transparent 1px),
    #f4f8fb;
  background-size: 40px 40px, 40px 40px, auto;
}

#graph {
  width: 100%;
  height: 100%;
  display: block;
}

.load-error {
  position: absolute;
  inset: 1rem;
  background: #fff5f5;
  border: 1px solid #c45c5c;
  color: #6b1f1f;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.inspector.empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.inspector dl {
  margin: 0;
}

.inspector dt {
  margin-top: 0.7rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.inspector dd {
  margin: 0.2rem 0 0;
  word-break: break-word;
}

.inspector .path {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.rel-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}

.rel-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

.rel-list button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid rgba(18, 32, 51, 0.1);
  background: var(--panel);
}

.foot code { font-family: var(--mono); }

.node-circle {
  stroke: #fff;
  stroke-width: 2px;
  cursor: grab;
}

.node-circle.selected {
  stroke: var(--ink);
  stroke-width: 3px;
}

.node-label {
  font-size: 11px;
  fill: var(--ink);
  pointer-events: none;
  text-anchor: middle;
}

.link {
  fill: none;
  stroke-opacity: 0.85;
}

.health-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  background: rgba(244, 249, 252, 0.9);
  border-bottom: 1px solid rgba(18, 32, 51, 0.1);
}

.health-chip {
  background: #fff;
  border: 1px solid rgba(18, 32, 51, 0.12);
  padding: 0.3rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.health-chip .k {
  color: var(--muted);
  margin-right: 0.35rem;
}

.health-chip.coverage b { color: #1f7a4c; }
.health-chip.known b { color: #1f7a4c; }
.health-chip.partial b { color: #2f5d8c; }
.health-chip.pending b { color: #c9a227; }
.health-chip.unknown b { color: #8a3a3a; }
.health-chip.debt b { color: #8a3a3a; }
.health-chip.discovery b { color: #5c3d6b; }
.health-chip.questions b { color: #b06a12; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 1.1rem;
  border-bottom: 1px solid rgba(18, 32, 51, 0.08);
}

.filter-btn, .tab-btn {
  border: 1px solid #8fa3b8;
  background: #f7fbfe;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.filter-btn.active, .tab-btn.active {
  background: rgba(8, 122, 140, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

.twin-layout {
  height: calc(100vh - 11.5rem);
}

.side-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.backlog-card {
  border: 1px solid rgba(18, 32, 51, 0.12);
  background: #fff;
  padding: 0.55rem 0.6rem;
  margin: 0.45rem 0;
  font-size: 0.82rem;
}

.backlog-card.fq {
  border-left: 3px solid #b06a12;
}

.backlog-card.rd {
  border-left: 3px solid #5c3d6b;
}

.backlog-card button {
  margin-top: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.ks-badge {
  font-size: 12px;
  fill: var(--ink);
  pointer-events: none;
}

.ks-icon { font-weight: 700; margin-right: 0.2rem; }

.health-panel,
.maturity-panel {
  display: grid;
  gap: 0.25rem;
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.6rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(18, 32, 51, 0.1);
  font-size: 0.78rem;
}

.health-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
}

.health-row.overall {
  padding-bottom: 0.25rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid rgba(18, 32, 51, 0.12);
  font-weight: 700;
}

.domains-panel h2 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.domains-panel h2:first-child {
  margin-top: 0;
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .canvas-panel {
    min-height: 420px;
  }
  .twin-layout {
    height: auto;
  }
}

/* /atlas/status diagnostic */
.status-page .status-topbar {
  grid-template-columns: 1fr auto;
}

.status-link {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(18, 32, 51, 0.18);
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.status-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.1rem 2.5rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.status-card {
  margin: 0;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid rgba(18, 32, 51, 0.12);
}

.status-card h2 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.status-card p {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.05rem;
  word-break: break-word;
}

.status-raw {
  margin-top: 1.25rem;
  padding: 1rem;
  overflow: auto;
  max-height: 420px;
  background: rgba(18, 32, 51, 0.04);
  border: 1px solid rgba(18, 32, 51, 0.1);
  font-size: 0.75rem;
}

/* WO-ATLAS-008 — institutional twin chrome */
.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.btn-primary, .btn-secondary {
  border: 1px solid rgba(18, 32, 51, 0.2);
  padding: 0.65rem 0.95rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-secondary { background: #fff; color: var(--ink); }

.atlas-app[hidden] { display: none !important; }

.atlas-toolbar {
  position: relative;
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid rgba(18, 32, 51, 0.1);
  background: rgba(255, 255, 255, 0.55);
}

.search-wrap {
  display: grid;
  gap: 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

#inst-search {
  width: 100%;
  max-width: 720px;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(18, 32, 51, 0.18);
  font: inherit;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--ink);
}

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% - 0.2rem);
  left: 1.1rem;
  right: 1.1rem;
  max-width: 720px;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(18, 32, 51, 0.15);
  box-shadow: 0 10px 28px rgba(18, 32, 51, 0.12);
}

.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(18, 32, 51, 0.06);
  background: transparent;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font: inherit;
}

.search-hit .kind {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 0.35rem;
}

.tour-card, .playback-card {
  margin-top: 0.65rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(8, 122, 140, 0.28);
}

.tour-card h3, .playback-card h3 { margin: 0.2rem 0 0.45rem; }
.tour-progress { font-family: var(--mono); font-size: 0.72rem; color: var(--accent); }
.tour-nav { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.tour-nav button, .playback-card button {
  border: 1px solid rgba(18, 32, 51, 0.18);
  background: #fff;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}

.timeline-panel { display: flex; gap: 0.35rem; margin-bottom: 0.35rem; }
.tl-btn {
  flex: 1;
  border: 1px solid rgba(18, 32, 51, 0.15);
  background: #fff;
  padding: 0.35rem 0.25rem;
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}
.tl-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.timeline-copy { margin: 0 0 0.8rem; font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.tests-panel .test-row.pass b { color: #1f7a4c; }
.tests-panel .test-row.fail b { color: #8a3a3a; }

/* WO-ATLAS-009 — playback clarity + synchronized tree projection */
.view-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}

.view-switch .view-btn.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.visualization-view {
  width: 100%;
  height: 100%;
}

.visualization-view[hidden] {
  display: none !important;
}

#graph-view #graph {
  width: 100%;
  height: 100%;
}

.tree-view {
  overflow: auto;
  padding: 1rem 1.25rem 2rem;
  background:
    linear-gradient(rgba(18, 32, 51, 0.035) 1px, transparent 1px),
    #f4f8fb;
  background-size: 100% 36px, auto;
}

.tree-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(18, 32, 51, 0.12);
  font-weight: 700;
}

.tree-heading small {
  color: var(--muted);
  font-weight: 400;
}

.institution-tree-root,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-children {
  margin-left: 1.2rem;
  border-left: 1px solid rgba(18, 32, 51, 0.16);
}

.tree-node {
  transition: opacity 150ms ease;
}

.tree-node-button {
  display: grid;
  grid-template-columns: 1.6rem 1.2rem minmax(120px, 1fr) auto;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  min-height: 34px;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.3rem 0.5rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.tree-node-button:hover {
  background: rgba(8, 122, 140, 0.08);
}

.tree-node-button small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.tree-connector {
  color: var(--line);
  font-family: var(--mono);
}

.tree-node.selected > .tree-node-button {
  border-color: var(--ink);
  background: rgba(18, 32, 51, 0.08);
}

.tree-node.active > .tree-node-button {
  border-color: var(--accent);
  background: rgba(8, 122, 140, 0.12);
  box-shadow: 0 0 0 2px rgba(8, 122, 140, 0.08);
}

.tree-node.inactive {
  opacity: 0.16;
}

.node.inactive-node {
  opacity: 0.18;
}

.node.active-node .node-circle {
  stroke: var(--accent);
  stroke-width: 4px;
  filter: drop-shadow(0 0 6px rgba(8, 122, 140, 0.8));
}

.node.current-node .node-circle {
  animation: atlas-node-pulse 900ms ease-in-out infinite alternate;
}

.link.active-relation {
  stroke-dasharray: 8 5;
  animation: atlas-link-flow 520ms linear infinite;
  filter: drop-shadow(0 0 3px rgba(8, 122, 140, 0.55));
}

@keyframes atlas-node-pulse {
  from { filter: drop-shadow(0 0 3px rgba(8, 122, 140, 0.55)); }
  to { filter: drop-shadow(0 0 10px rgba(8, 122, 140, 1)); }
}

@keyframes atlas-link-flow {
  to { stroke-dashoffset: -13; }
}

.playback-card {
  border-left: 4px solid var(--accent);
}

.playback-card.playback-error {
  border-color: #8a3a3a;
  background: #fff5f5;
}

.playback-card p {
  margin: 0.35rem 0;
  line-height: 1.4;
}

.playback-progress {
  height: 4px;
  margin: 0.75rem 0;
  overflow: hidden;
  background: rgba(18, 32, 51, 0.1);
}

.playback-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .node.current-node .node-circle,
  .link.active-relation {
    animation: none;
  }
}

