/* CDOP Atlas. Colours are tokens; the chart and map palettes were checked for colour-vision
   separation and contrast in both schemes (lifecycle groups: all pairs, for the map; unit
   statuses: adjacent pairs, so Active and Buffer never touch in a stack). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --link: #1c5cab;
  --focus: #2a78d6;

  /* Project lifecycle groups (map, chart, chips). */
  --pipeline: #2a78d6;
  --crediting: #1baf7a;
  --closed: #898781;
  /* Unit statuses, stacked in this order. */
  --u-active: #eb6834;
  --u-retired: #4a3aa7;
  --u-buffer: #eda100;
  --u-cancelled: #898781;
  /* Single-series bars, and registry accounts on the map. */
  --series-1: #2a78d6;
  --account: #52514e;
  --account-ring: #fcfcfb;
  --flow: rgba(11, 11, 11, 0.55);

  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;

  --radius: 8px;
  --panel-w: 460px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --link: #86b6ef;
    --focus: #3987e5;
    --pipeline: #3987e5;
    --crediting: #199e70;
    --u-active: #d95926;
    --u-retired: #9085e9;
    --u-buffer: #c98500;
    --series-1: #3987e5;
    --account: #c3c2b7;
    --account-ring: #1a1a19;
    --flow: rgba(255, 255, 255, 0.6);
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --link: #86b6ef;
  --focus: #3987e5;
  --pipeline: #3987e5;
  --crediting: #199e70;
  --u-active: #d95926;
  --u-retired: #9085e9;
  --u-buffer: #c98500;
  --series-1: #3987e5;
  --account: #c3c2b7;
  --account-ring: #1a1a19;
  --flow: rgba(255, 255, 255, 0.6);
  --good-text: #0ca30c;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
code,
.mono {
  font-family: var(--mono);
  font-size: 12px;
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 18px;
  line-height: 1.3;
}
h2 {
  font-size: 15px;
}
h3 {
  font-size: 13px;
  color: var(--ink-2);
}

/* Top bar and filter row */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}
.brand:hover {
  text-decoration: none;
}
.brand img {
  display: block;
}
.brand .logo-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light {
    display: none;
  }
  :root:not([data-theme="light"]) .brand .logo-dark {
    display: block;
  }
}
:root[data-theme="dark"] .brand .logo-light {
  display: none;
}
:root[data-theme="dark"] .brand .logo-dark {
  display: block;
}
.brand-name {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  line-height: 20px;
}
.badge {
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.toplinks {
  margin-left: auto;
  display: flex;
  gap: 16px;
  font-size: 13px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}
.filters label.grow {
  flex: 1 1 200px;
  max-width: 360px;
}
select,
input[type="search"],
button {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  min-height: 32px;
}
select {
  max-width: 220px;
}
button {
  cursor: pointer;
}
button.ghost {
  border-color: transparent;
  color: var(--ink-2);
}
button.ghost:hover {
  background: var(--surface-2);
}

/* Map and panel */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}
.map-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.map {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}
.map-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  color: var(--ink-2);
}
.map-off strong {
  color: var(--ink);
}
.map-legend {
  position: absolute;
  left: 12px;
  bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  max-width: 260px;
}
.map-legend:empty {
  display: none;
}
.map-legend .title {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 4px;
}
.panel {
  width: var(--panel-w);
  flex: none;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 0 16px 24px;
}
.loading,
.empty {
  color: var(--muted);
  padding: 16px 0;
}
.error {
  color: var(--critical);
  padding: 16px 0;
}

/* Panel chrome */
.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 4px;
  margin: 0 -16px 12px;
  padding: 10px 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: 6px 10px 8px;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover {
  color: var(--ink);
  text-decoration: none;
}
.tabs a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 600;
}
.tabs .count {
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 14px 0 10px;
}
.subtabs a {
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--ink-2);
  border: 1px solid var(--border);
  font-size: 13px;
}
.subtabs a:hover {
  text-decoration: none;
  background: var(--surface-2);
}
.subtabs a[aria-current="page"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.back {
  display: inline-block;
  margin: 2px 0 8px;
  font-size: 13px;
}
.sub {
  color: var(--ink-2);
  font-size: 12px;
  margin: 0 0 10px;
}
.section {
  margin: 18px 0;
}
.draft-highlight {
  margin: 14px 0;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--link);
  border-radius: var(--radius);
}
.draft-highlight h2 {
  margin: 0 0 6px;
}
.draft-highlight p {
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 13px;
}
.draft-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.section > h2 {
  margin-bottom: 4px;
}
.section > .sub {
  color: var(--ink-2);
  font-size: 12px;
  margin: 0 0 10px;
}
.detail-head {
  margin: 4px 0 8px;
}
.detail-head .ids {
  color: var(--ink-2);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--ink-2);
  white-space: nowrap;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.kpi {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.kpi .label {
  font-size: 12px;
  color: var(--ink-2);
}
.kpi .value {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}
.kpi .note {
  font-size: 11px;
  color: var(--muted);
}
dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 8px 0;
  font-size: 13px;
}
dl.facts dt {
  color: var(--ink-2);
}
dl.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  margin: 6px 0;
}

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li + li {
  border-top: 1px solid var(--grid);
}
.list a.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 8px 6px;
  margin: 0 -6px;
  border-radius: 6px;
  color: var(--ink);
}
.list a.row:hover,
.list a.row.hot {
  background: var(--surface-2);
  text-decoration: none;
}
.list .name {
  font-weight: 500;
  min-width: 0;
}
.list .meta {
  grid-column: 1;
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.list .num {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  font-size: 12px;
}
.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 8px;
  font-size: 12px;
  color: var(--ink-2);
}
.list-tools select {
  min-height: 28px;
  padding: 2px 6px;
  font-size: 12px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th,
td {
  text-align: left;
  padding: 5px 4px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
th {
  color: var(--ink-2);
  font-weight: 500;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.nowrap {
  white-space: nowrap;
}

/* Timeline (status histories) */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--axis);
}
.timeline li {
  position: relative;
  padding: 0 0 12px 8px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--muted);
}
.timeline li.current::before {
  background: var(--ink);
  border-color: var(--ink);
}
.timeline .when {
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.timeline .what {
  font-weight: 500;
}
.timeline .how {
  font-size: 12px;
  color: var(--ink-2);
}

/* Charts */
.chart-card {
  margin: 10px 0 18px;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.chart-head button {
  min-height: 24px;
  padding: 1px 8px;
  font-size: 12px;
}
.chart {
  position: relative;
  width: 100%;
}
.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}
.chart svg text {
  fill: var(--ink-2);
  font: 11px var(--font);
}
.chart svg .tick {
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart svg .grid {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart svg .baseline {
  stroke: var(--axis);
  stroke-width: 1;
}
.chart svg .mark {
  transition: opacity 120ms;
}
.chart svg .hit {
  fill: transparent;
  cursor: pointer;
}
.chart svg .hit:focus {
  outline: none;
}
.chart svg g.hot .mark {
  opacity: 0.8;
}
.chart svg .hit:focus-visible + .focus-ring,
.chart svg .focus-ring {
  fill: none;
  stroke: none;
}
.chart svg g:has(> .hit:focus-visible) .focus-ring {
  stroke: var(--focus);
  stroke-width: 2;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 2px;
  font-size: 12px;
  color: var(--ink-2);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend .value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.chart-note {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 0;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 6px 8px;
  font-size: 12px;
  max-width: 280px;
}
.tooltip .tt-title {
  color: var(--ink-2);
  margin-bottom: 3px;
}
.tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tooltip .tt-row .key {
  width: 10px;
  height: 2px;
  flex: none;
}
.tooltip .tt-row strong {
  font-variant-numeric: tabular-nums;
}
.tooltip .tt-row span {
  color: var(--ink-2);
}

/* Source footer: which API calls built the view */
.sources {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.sources ul {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.sources li {
  overflow-wrap: anywhere;
}
.sources a {
  font-family: var(--mono);
  font-size: 11px;
}

/* Conformance */
.ok {
  color: var(--good-text);
}
.bad {
  color: var(--critical);
}

/* Mapbox popups follow the page theme. */
.mapboxgl-popup-content {
  background: var(--surface);
  color: var(--ink);
  font: 12px/1.4 var(--font);
  border-radius: 6px;
  padding: 6px 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}
.mapboxgl-popup-tip {
  display: none;
}
.mapboxgl-popup-content .muted {
  color: var(--ink-2);
}

@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100%;
  }
  .toplinks {
    display: flex;
    flex-basis: 100%;
    margin-left: 0;
  }
  .toplinks a:not(.additionality-nav) {
    display: none;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .layout {
    flex-direction: column;
  }
  .map-wrap {
    height: 46vh;
    flex: none;
  }
  .panel {
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--border);
    overflow: visible;
  }
  .filters select {
    max-width: 150px;
  }
  .map-legend {
    left: 8px;
    bottom: 24px;
    padding: 5px 8px;
    font-size: 11px;
  }
  .map-legend .chart-note {
    display: none;
  }
}

@media (forced-colors: active) {
  .dot,
  .swatch {
    border: 1px solid CanvasText;
  }
}

/* Keep navigation and filter context visible while exploring long lists and documents. */
:root {
  --panel-w: clamp(460px, 38vw, 640px);
  --muted: #686760;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --muted: #aaa89f;
  }
}
:root[data-theme="dark"] {
  --muted: #aaa89f;
}
[hidden] {
  display: none !important;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 30;
  padding: 10px 16px;
  background: var(--surface);
}
.skip-link:focus {
  top: 8px;
}
.topbar,
.filters,
.workspace-bar,
.filter-summary {
  flex-shrink: 0;
}
.filters label {
  color: var(--ink-2);
  font-size: 12px;
  gap: 4px;
}
.filters select,
.filters input {
  font-size: 13px;
  min-height: 38px;
}
.filters label.grow {
  max-width: 480px;
}
button:disabled,
select:disabled {
  opacity: 0.55;
  cursor: default;
}
.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.workspace-bar .tabs {
  position: static;
  margin: 0;
  padding: 0;
  border: 0;
}
.workspace-bar .tabs a {
  padding: 12px 14px;
  white-space: nowrap;
}
.view-controls {
  display: flex;
  gap: 8px;
}
.view-controls button {
  font-size: 12px;
}
.filter-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 20px;
  background: var(--page);
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 12px;
}
#result-count {
  font-variant-numeric: tabular-nums;
}
#active-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.filter-chip {
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  overflow-wrap: anywhere;
  text-align: left;
}
.filter-chip:hover {
  background: var(--surface-2);
  border-color: var(--axis);
}
.panel {
  padding-top: 18px;
  scrollbar-gutter: stable;
  min-width: 0;
}
.overview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 16px 0;
  font-size: 13px;
}
.primary-link {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--link);
  color: var(--surface);
  font-weight: 600;
}
.kpi {
  padding: 12px;
}
.list a.row {
  padding-top: 12px;
  padding-bottom: 12px;
}
.list .meta {
  flex-wrap: wrap;
}
.list-tools {
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.list-tools select {
  min-height: 36px;
}
.empty-state {
  padding: 28px 18px;
  margin: 16px 0;
  text-align: center;
  border: 1px dashed var(--axis);
  border-radius: var(--radius);
}
.empty-state p {
  color: var(--ink-2);
}
.details-only .map-wrap {
  display: none;
}
.details-only .panel {
  width: 100%;
  border-left: 0;
  padding-left: max(24px, calc((100% - 1080px) / 2));
  padding-right: max(24px, calc((100% - 1080px) / 2));
}
.details-only .kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 860px) {
  body {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .topbar {
    padding: 10px 12px;
  }
  .filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px 12px;
    gap: 8px;
  }
  .filters select {
    max-width: none;
    width: 100%;
  }
  .filters label {
    min-width: 0;
  }
  .filters label.grow {
    grid-column: span 2;
    max-width: none;
  }
  .filters input {
    width: 100%;
  }
  .filters button {
    font-size: 12px;
    min-height: 38px;
  }
  .workspace-bar {
    flex-wrap: wrap;
    padding: 0 12px 8px;
  }
  #view-nav {
    width: 100%;
  }
  .workspace-bar .tabs {
    justify-content: space-between;
  }
  .workspace-bar .tabs a {
    padding: 10px 8px;
  }
  .view-controls {
    width: 100%;
  }
  .view-controls button {
    flex: 1;
    min-height: 36px;
  }
  .filter-summary {
    padding: 8px 12px;
    max-height: 112px;
    overflow: auto;
  }
  .map-wrap,
  .details-only .map-wrap {
    display: none;
  }
  .panel,
  .details-only .panel {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    padding: 16px 14px 24px;
    border: 0;
  }
  .mobile-map .map-wrap {
    display: block;
    height: auto;
    flex: 1;
  }
  .mobile-map .panel {
    display: none;
  }
  .details-only .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .map-legend {
    max-width: 240px;
  }
  dl.facts {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  }
}
