/* Org Atlas — light, no-build layout. Presentation only. */
:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #6b7688;
  --line: #dfe3ea;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column;
}
#topbar {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 1rem;
  padding: .6rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: .01em; }
/* Instance ⇄ Schema view toggle — a segmented control in the header */
.viewtoggle { display: inline-flex; border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; }
.viewtoggle button { border: 0; background: var(--panel); color: var(--muted);
  font: inherit; font-size: 12px; padding: .2rem .7rem; cursor: pointer; }
.viewtoggle button + button { border-left: 1px solid var(--line); }
.viewtoggle button.active { background: #4f7cff; color: #fff; }
.counts { color: var(--muted); font-size: 12px; }
/* large-org search box — focus/zoom a node by name */
.search { font: inherit; font-size: 12px; padding: .2rem .5rem; width: 12rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  color: var(--ink); }
.search:focus { outline: 2px solid #4f7cff; outline-offset: -1px; }
.legend { margin-left: auto; display: flex; align-items: center; gap: .6rem;
  font-size: 12px; color: var(--muted); }
.legend .chip { padding: .05rem .4rem; border-radius: 999px; color: #fff;
  font-size: 11px; }
.legend .chip.internal { background: #22a06b; }
.legend .chip.external { background: #e0952b; }
.marker-key { display: inline-flex; align-items: center; gap: .25rem; }
.marker { display: inline-flex; align-items: center; justify-content: center;
  width: 1.05em; height: 1.05em; border-radius: 3px; background: #eef1f6;
  color: #5566aa; font-style: italic; font-weight: 700; font-size: 11px; }
main { flex: 1 1 auto; position: relative; min-height: 0; }
#cy { position: absolute; inset: 0; }
/* global hover tooltip — name · kind peek, follows the cursor over a node */
.tooltip { position: absolute; z-index: 8; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.3;
  padding: .2rem .5rem; border-radius: 5px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.tooltip[hidden] { display: none; }

/* plane lenses + presets — top-left control panel; swatches are the legend */
#lens-panel {
  position: absolute; left: 1rem; top: 1rem; width: 14rem; max-height: 70%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08); display: flex; flex-direction: column;
  overflow: hidden;
}
#lens-toggle {
  flex: 0 0 auto; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: .5rem .8rem; cursor: pointer;
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
#lens-body { overflow: auto; padding: .5rem .8rem .8rem; }
#lens-panel.collapsed #lens-body { display: none; }
#lens-body h3 { margin: .8rem 0 .35rem; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }
.presets { display: flex; flex-wrap: wrap; gap: .3rem; }
.presets .preset { flex: 1 1 auto; border: 1px solid var(--line); border-radius: 6px;
  background: #f2f5fb; color: var(--ink); font-size: 11px; padding: .3rem .4rem;
  cursor: pointer; }
.presets .preset:hover { background: #e7edf8; }
/* the active preset reads highlighted; a lens toggle clears it (honest state) */
.presets .preset.active { background: #4f7cff; color: #fff; border-color: #4f7cff; }
/* Re-arrange: re-run the current view's layout and fit */
#rearrange { flex: 0 0 auto; border: 0; border-top: 1px solid var(--line);
  background: transparent; padding: .5rem .8rem; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #4f7cff; text-align: left; }
#rearrange:hover { background: #e7edf8; }
#lens-panel.collapsed #rearrange { display: none; }
label.lens { display: flex; align-items: center; gap: .4rem; font-size: 12px;
  padding: .15rem 0; cursor: pointer; }
label.lens .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
label.lens .swatch.nest { background: repeating-linear-gradient(45deg,
  #c9d3ea, #c9d3ea 3px, #eef1f6 3px, #eef1f6 6px); }

/* org-wide derived readouts — the always-on "derived, never stored" panel */
#derived-panel {
  position: absolute; left: 1rem; bottom: 1rem; width: 17rem; max-height: 60%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08); display: flex; flex-direction: column;
  overflow: hidden;
}
#derived-toggle {
  flex: 0 0 auto; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: .5rem .8rem; cursor: pointer;
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
#derived-body { overflow: auto; padding: .3rem .8rem .8rem; }
#derived-panel.collapsed #derived-body { display: none; }
#derived-body .hint { margin: .5rem 0; color: var(--muted); font-size: 12px;
  font-style: italic; }
#derived-body h3 { margin: .9rem 0 .4rem; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }

/* staffing gauge — meets vs below vs no-workforce are visually distinct */
.gauge { margin: .5rem 0; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; }
.gauge .status { font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  padding: .05rem .35rem; border-radius: 999px; }
.gauge .status.meets { background: #dff3e8; color: #1c7a4d; }
.gauge .status.below { background: #fbe0de; color: #b23b34; }
.gauge .status.no-workforce { background: #eef1f6; color: #6b7688; }
.track { position: relative; height: 10px; margin: .3rem 0; border-radius: 5px;
  background: #eef1f6; overflow: hidden; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.fill.meets { background: #22a06b; }
.fill.below { background: #c2453f; }
.track .target { position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: #1c2330; }
.track .empty { font-size: 10px; color: var(--muted); padding-left: .4rem; }
.gauge-foot { font-size: 11px; color: var(--muted); }
ul.over { margin: .3rem 0; padding-left: 1.1rem; font-size: 12px; }
ul.over .alloc { color: #c2453f; font-weight: 600; }
ul.roster { margin: .3rem 0; padding-left: 1.1rem; font-size: 12px; }
ul.roster li { margin: .15rem 0; color: var(--muted); }
ul.roster b { color: var(--ink); }
/* schema view — plane-matrix table, derived from meta */
#schema-panel {
  position: absolute; left: 1rem; top: 1rem; width: 24rem; max-height: 80%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08); display: flex; flex-direction: column;
  overflow: hidden;
}
#schema-panel[hidden] { display: none; }
#schema-toggle {
  flex: 0 0 auto; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: .5rem .8rem; cursor: pointer;
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
#schema-body { overflow: auto; padding: .3rem .8rem .8rem; }
#schema-panel.collapsed #schema-body { display: none; }
#schema-body .hint { margin: .5rem 0; color: var(--muted); font-size: 12px;
  font-style: italic; }
table.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
table.matrix th { text-align: left; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; font-size: 10px;
  border-bottom: 1px solid var(--line); padding: .25rem .3rem; }
table.matrix td { padding: .25rem .3rem; border-bottom: 1px solid var(--line);
  vertical-align: top; }
table.matrix td.plane { white-space: nowrap; font-weight: 600; }
table.matrix td.plane .swatch { display: inline-block; width: 10px; height: 10px;
  border-radius: 3px; margin-right: .35rem; vertical-align: middle; }
#inspector {
  position: absolute; top: 0; right: 0; bottom: 0; width: 22rem;
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 1rem 1.1rem; overflow: auto; box-shadow: -4px 0 18px rgba(0,0,0,.06);
}
#inspector[hidden] { display: none; }
#inspector-close {
  float: right; border: 0; background: transparent; font-size: 20px;
  line-height: 1; cursor: pointer; color: var(--muted);
}
#inspector h2 { margin: 0 0 .1rem; font-size: 16px; }
#inspector .kind { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; }
#inspector h3 { margin: 1rem 0 .3rem; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }
#inspector dl { margin: 0; display: grid; grid-template-columns: auto 1fr;
  gap: .15rem .6rem; }
#inspector dt { color: var(--muted); }
#inspector dd { margin: 0; word-break: break-word; }
/* the consistent derived marker: an italic ƒ before every computed field */
#inspector .derived dt::before { content: "ƒ "; color: #5566aa; font-style: italic;
  font-weight: 700; }
#inspector ul.rels { margin: 0; padding-left: 1.1rem; }
#inspector ul.rels li { margin: .1rem 0; }
#inspector ul.rels .plane { color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .03em; }
/* generic facet block — any extension's contents, keyed by namespace */
#inspector .facet { margin: .3rem 0 .5rem; }
#inspector .facet-ns { color: var(--muted); font-size: 11px; font-family: monospace;
  word-break: break-all; margin-bottom: .1rem; }
#inspector .facet p { margin: 0; }
/* collapse/expand a Unit's subtree from the inspector */
#inspector .collapse-btn { margin-top: 1rem; border: 1px solid var(--line);
  border-radius: 6px; background: #f2f5fb; color: var(--ink); font: inherit;
  font-size: 12px; padding: .35rem .6rem; cursor: pointer; }
#inspector .collapse-btn:hover { background: #e7edf8; }

/* lint badge in the header — opens the findings overlay, coloured by severity */
.lint-badge { border: 0; border-radius: 999px; font: inherit; font-size: 11px;
  font-weight: 600; padding: .1rem .55rem; cursor: pointer; color: #fff; }
.lint-badge[hidden] { display: none; }
.lint-badge.error { background: #c2453f; }
.lint-badge.warning { background: #e0952b; }
.lint-badge.info { background: #6b7688; }
/* lint overlay — the CLI's findings, bucketed; bottom-left floating panel */
#lint-panel {
  position: absolute; left: 1rem; bottom: 1rem; width: 24rem; max-height: 55%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: .8rem 1rem;
  overflow: auto; z-index: 5;
}
#lint-panel[hidden] { display: none; }
#lint-close { float: right; border: 0; background: transparent; font-size: 20px;
  line-height: 1; cursor: pointer; color: var(--muted); }
#lint-panel h2 { margin: 0 0 .1rem; font-size: 16px; }
#lint-panel .hint { margin: .3rem 0 .6rem; color: var(--muted); font-size: 12px; }
#lint-panel h3 { margin: .8rem 0 .3rem; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; }
#lint-panel h3.lint-error { color: #c2453f; }
#lint-panel h3.lint-warning { color: #e0952b; }
#lint-panel h3.lint-info { color: var(--muted); }
#lint-panel .clean { color: #22a06b; font-size: 13px; }
ul.findings { list-style: none; margin: 0; padding: 0; }
ul.findings .finding { margin: .2rem 0; padding: .3rem .5rem; border-radius: 6px;
  font-size: 12px; cursor: pointer; border-left: 3px solid var(--line);
  background: #f7f8fa; }
ul.findings .finding:hover { background: #eef1f6; }
ul.findings .finding.error { border-left-color: #c2453f; }
ul.findings .finding.warning { border-left-color: #e0952b; }
ul.findings .finding.info { border-left-color: #9aa4b5; }
ul.findings .check { font-weight: 700; font-family: monospace; margin-right: .3rem; }
ul.findings .src { display: block; color: var(--muted); font-size: 11px;
  font-family: monospace; word-break: break-all; margin-top: .1rem; }
