/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  --c-primary:    #0d6e6e;
  --c-primary-d:  #095454;
  --c-primary-l:  #1a9090;
  --c-accent:     #d4a017;
  --c-bg:         #fafaf7;
  --c-bg-alt:     #f3f1ec;
  --c-surface:    #ffffff;
  --c-border:     #d9e2df;
  --c-border-d:   #b9c9c4;
  --c-text:       #0f172a;
  --c-text-soft:  #334155;
  --c-muted:      #57727a;
  --c-chip-bg:    rgba(13,110,110,0.08);
  --c-chip-bg-d:  rgba(13,110,110,0.16);
  --radius:       8px;
  --radius-sm:    4px;
  --shadow-sm:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md:    0 2px 6px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.05);
  --topbar-h:     52px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Top nav bar ────────────────────────────────────────────────── */
#topbar {
  background: linear-gradient(135deg, var(--c-primary-d) 0%, var(--c-primary) 55%, var(--c-primary-l) 100%);
  border-bottom: 3px solid var(--c-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--topbar-h);
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-sub {
  font-weight: 400;
  font-size: 0.82rem;
  opacity: .82;
}
.tabs {
  display: flex;
  gap: 2px;
}
.tabs a {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  padding: 8px 16px;
  font-size: 0.92rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  position: relative;
  top: 3px;
}
.tabs a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs a.active {
  color: #fff;
  border-bottom-color: var(--c-accent);
  background: rgba(255,255,255,.12);
}

/* ── App shell ──────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: 320px 1fr;
  /* The implicit single grid row defaults to `auto` (= tallest child's
   * content height). Without an explicit `1fr` row template, child views
   * with `height: 100%` resolve against an under-sized row and the map,
   * Browse table, Network canvas, etc. stop short of the viewport edge,
   * leaving wasted white space below. Pin the row to fill #app's flex-
   * assigned height. */
  grid-template-rows: 1fr;
  flex: 1;
  min-height: 0;
  /* min-width: 0 lets a long facility name in the bottom panel ellipsize
   * instead of pushing the grid wider than the viewport. */
  min-width: 0;
}

/* ── View sections ──────────────────────────────────────────────── */
#viewport {
  position: relative;
  min-height: 0;
  min-width: 0;
  /* Viewport is a grid item in #app; height: 100% pins it to the row
   * track (which is now 1fr per the rule above). */
  height: 100%;
  width: 100%;
  overflow: hidden;
}
.view { display: none; height: 100%; width: 100%; overflow: auto; min-height: 0; min-width: 0; }
.view.active { display: block; }

/* Each <section id="view-*"> wraps a single <div id="*"> that the
 * corresponding view's JS renders into. Make those inner containers
 * fill their parent so flex / grid layouts inside them have a real
 * height to resolve `100%` against. Without this, views that use
 * inner flex columns (Browse table, Network canvas, SQL editor)
 * collapse to content height and won't scroll. */
#view-browse > #browse,
#view-network > #network,
#view-people  > #people,
#view-sql     > #sql,
#view-stats   > #stats,
#view-docs    > #docs {
  height: 100%;
  width: 100%;
  min-height: 0;
  min-width: 0;
}

/* Map view takes the full area and stacks the map canvas + a collapsible
 * list panel pinned to the bottom. The list shows only facilities whose
 * coordinates fall inside the current map viewport. */
#view-map {
  display: none;
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}
#view-map.active { display: grid; grid-template-rows: 1fr auto; }
#view-map #map { width: 100%; height: 100%; min-height: 0; }

.map-browse {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -2px 6px rgba(15, 23, 42, .05);
  display: grid;
  grid-template-rows: auto 1fr;
  max-height: 38vh;
  min-height: 40px;
  transition: max-height .18s ease;
}
.map-browse.collapsed { max-height: 40px; }
.map-browse.collapsed .map-browse-body { display: none; }

.map-browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--c-bg-alt);
  border-bottom: 1px solid var(--c-border);
  user-select: none;
}
.map-browse-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--c-text-soft);
  letter-spacing: .02em;
}
.map-browse-count {
  display: inline-block;
  min-width: 28px;
  margin-left: 8px;
  padding: 1px 8px;
  background: var(--c-chip-bg);
  color: var(--c-primary-d);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.map-browse-toggle {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 6px;
}
.map-browse.collapsed .map-browse-toggle { transform: rotate(180deg); }

.map-browse-body {
  overflow: auto;
  padding: 0;
  background: var(--c-surface);
}
.map-browse-list { width: 100%; }

.map-browse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.map-browse-table th,
.map-browse-table td {
  text-align: left;
  padding: 4px 10px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-browse-table th {
  position: sticky;
  top: 0;
  background: var(--c-bg-alt);
  color: var(--c-text-soft);
  font-weight: 600;
  z-index: 1;
}
.map-browse-table tbody tr { cursor: pointer; transition: background .1s; }
.map-browse-table tbody tr:hover { background: var(--c-chip-bg); }
.map-browse-table tbody tr.is-hovered { background: var(--c-chip-bg-d); }
.map-browse-table td.col-type { text-transform: capitalize; }
.map-browse-table td.col-name { max-width: 340px; }
.map-browse-empty {
  padding: 16px 18px;
  color: var(--c-muted);
  font-style: italic;
  font-size: 13px;
}
.map-browse-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
  margin-right: 6px;
  vertical-align: -1px;
}

body.no-sidebar #sidebar { display: none; }
body.no-sidebar #app { grid-template-columns: 1fr; }

/* ── Sidebar ────────────────────────────────────────────────────── */
#sidebar {
  background: var(--c-bg);
  border-right: 1px solid var(--c-border);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  min-height: 0;
}

#sidebar-scroll {
  overflow-y: auto;
  padding: 6px 12px 12px;
  scrollbar-gutter: stable;
}
#sidebar-scroll::-webkit-scrollbar { width: 8px; }
#sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--c-border-d);
  border-radius: 4px;
}

/* Section headers inside sidebar */
.sidebar-section { padding-top: 6px; }
.sidebar-section + .sidebar-section { margin-top: 14px; }
.sidebar-section-title {
  margin: 0 0 8px;
  padding: 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-muted);
}

/* Search bar */
#search {
  padding: 12px 12px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.search-wrap { position: relative; display: flex; align-items: center; }
#q {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--c-border-d);
  border-radius: var(--radius);
  font-size: 0.92rem;
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#q::placeholder { color: var(--c-muted); }
#q:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(13,110,110,.12); }
#q-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
  display: none;
  border-radius: 50%;
}
#q-clear:hover { background: var(--c-chip-bg); color: var(--c-primary); }
#q-clear.visible { display: block; }

/* Clear-all link */
#clear-all {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--c-primary);
  text-decoration: none;
  padding: 2px 6px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s;
}
#clear-all:hover { background: var(--c-chip-bg); text-decoration: underline; }

/* ── Facet sections (filter checkboxes) ─────────────────────────── */
.facet-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.facet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(180deg, var(--c-chip-bg) 0%, transparent 100%);
  border-bottom: 1px solid var(--c-border);
  transition: background .15s;
}
.facet-section.collapsed .facet-header { border-bottom-color: transparent; }
.facet-header:hover { background: var(--c-chip-bg-d); }
.facet-header h2 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-primary-d);
  font-weight: 700;
}
.facet-toggle { font-size: .65rem; color: var(--c-muted); }
.facet-body { padding: 8px 12px 10px; max-height: 300px; overflow-y: auto; }
.facet-section.collapsed .facet-body { display: none; }

.facet-body label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  padding: 3px 4px;
  cursor: pointer;
  color: var(--c-text-soft);
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.facet-body label:hover { color: var(--c-primary-d); background: var(--c-chip-bg); }
.facet-body input[type=checkbox] { accent-color: var(--c-primary); flex-shrink: 0; }

.facet-body .child-item { padding-left: 18px; }

/* ── Overlay panel ──────────────────────────────────────────────── */
.overlay-section { margin-bottom: 0; }
.overlay-body { padding: 10px 12px 12px; }
.overlay-group + .overlay-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--c-border); }
.overlay-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-muted);
  margin-bottom: 6px;
}
.overlay-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.86rem;
  padding: 4px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
  transition: background .12s;
}
.overlay-row:hover { background: var(--c-chip-bg); }
.overlay-row input[type=checkbox] { accent-color: var(--c-primary); margin: 0; }
.overlay-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}
.overlay-label { line-height: 1.3; }

/* ── Status bar (sticky bottom) ─────────────────────────────────── */
#status {
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--c-muted);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  min-height: 2.4em;
  display: flex;
  align-items: center;
}
#status strong { color: var(--c-primary-d); font-weight: 700; margin-right: 4px; }

footer {
  padding: 6px 14px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
footer a { color: var(--c-muted); font-size: 0.74rem; text-decoration: none; }
footer a:hover { color: var(--c-primary); }

/* ── Map ────────────────────────────────────────────────────────── */
#map { height: 100%; width: 100%; background: #eef2f4; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ── Popups ─────────────────────────────────────────────────────── */
.maplibregl-popup-content {
  border-radius: var(--radius) !important;
  padding: 14px 16px !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--c-border);
}
.popup { max-width: 300px; font-size: 13px; line-height: 1.5; }
.popup-name { font-weight: 700; font-size: 14px; color: var(--c-text); line-height: 1.35; }
.popup-name a { color: var(--c-primary); text-decoration: none; }
.popup-name a:hover { text-decoration: underline; }
.popup-acr { color: var(--c-muted); font-size: 12px; font-weight: 500; }
.popup-meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.type-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .02em;
}
.popup-country {
  font-size: 11px;
  color: var(--c-muted);
  font-weight: 600;
  background: var(--c-bg-alt);
  padding: 2px 8px;
  border-radius: 12px;
}
.popup-row { margin-top: 5px; font-size: 12.5px; color: var(--c-text-soft); }
.popup-row em { color: var(--c-muted); font-style: normal; font-weight: 600; margin-right: 2px; }
.popup-desc {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--c-text-soft);
  border-top: 1px solid var(--c-border);
  padding-top: 6px;
}
.popup-source {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 14px;
  background: var(--c-primary);
  color: #fff;
  border-radius: 16px;
  font-size: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: background .15s;
}
.popup-source:hover { background: var(--c-primary-d); }

/* ── Legend control (bottom-left) ───────────────────────────────── */
.legend-control {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  max-width: 230px;
  font-size: 12px;
  overflow: hidden;
}
.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  background: linear-gradient(180deg, var(--c-chip-bg) 0%, transparent 100%);
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-primary-d);
}
.legend-toggle { font-size: .65rem; color: var(--c-muted); }
.legend-body { padding: 8px 12px 10px; max-height: 50vh; overflow-y: auto; }
.legend-control.collapsed .legend-body { display: none; }
.legend-control.collapsed .legend-header { border-bottom-color: transparent; }
.legend-section + .legend-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--c-border); }
.legend-section-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-muted);
  margin-bottom: 4px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 11.5px;
  color: var(--c-text-soft);
}
.legend-chip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.1);
}
.legend-chip-square { border-radius: 3px; }

/* ── Top-right toolbar (Fit/Nav/Scale) ──────────────────────────── */
.fit-control a {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--c-primary-d);
  white-space: nowrap;
  transition: background .15s;
}
.fit-control a:hover { background: var(--c-chip-bg); }

/* MapLibre's nav control polished */
.maplibregl-ctrl-group {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}

/* ── Browse view ────────────────────────────────────────────────── */
/* display defaults to none (from .view) and flips to flex when .active.
 * Previously the base rule was `display: flex`, which won the specificity
 * fight against `.view { display: none }` — so the facilities table leaked
 * through on every other tab (Network, Stats, Docs). */
#view-browse { overflow: hidden; flex-direction: column; }
#view-browse.active { display: flex; }
/* The list-view module renders its content into the #browse container
 * (header + .browse-scroll). Without these rules #browse is a plain
 * block element and the inner .browse-scroll's `flex: 1` has no flex
 * parent — so the table grows taller than its container and the page
 * 'doesn't scroll'. Make #browse a flex column that fills #view-browse. */
#view-browse > #browse {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.browse-scroll { min-height: 0; }   /* allow flex shrink below content height */
.browse-header {
  padding: 12px 20px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  gap: 18px;
  align-items: baseline;
  flex-shrink: 0;
}
.browse-count { font-weight: 700; color: var(--c-primary-d); font-size: 1.05rem; }
.browse-hint  { font-size: 0.78rem; color: var(--c-muted); }
.browse-scroll { overflow: auto; flex: 1; }
.browse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.browse-table thead {
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 1;
  box-shadow: 0 1px 0 var(--c-border);
}
.browse-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  background: var(--c-bg-alt);
}
.browse-table th:hover { color: var(--c-primary); }
.browse-table th.sort-active { color: var(--c-primary-d); background: var(--c-chip-bg); }
.browse-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.browse-table tr:hover td { background: var(--c-chip-bg); }
.col-acronym code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  background: var(--c-bg-alt);
  color: var(--c-primary-d);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.col-url a {
  color: var(--c-primary);
  font-size: 11.5px;
  text-decoration: none;
  max-width: 220px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.col-url a:hover { text-decoration: underline; }

/* ── Stats view ─────────────────────────────────────────────────── */
#view-stats { overflow: auto; }
.stats-summary {
  padding: 22px 28px 8px;
  font-size: 1rem;
  color: var(--c-muted);
}
.stats-summary strong { color: var(--c-primary-d); font-weight: 700; }
.stats-charts {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 28px 32px;
}
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card h3 {
  margin: 0 0 14px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-primary-d);
  font-weight: 700;
}
.bar-svg { display: block; }
.no-data { color: var(--c-muted); font-size: 0.85rem; padding: 8px 0; }
.no-data-note { color: var(--c-muted); font-size: 0.8rem; max-width: 240px; }

/* ── Docs view ──────────────────────────────────────────────────── */
#view-docs {
  overflow: hidden;             /* let the inner panes own scroll */
  display: flex;
  flex-direction: column;
}
#view-docs > #docs {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Tab bar — one tab per docs/*.md page */
.docs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 10px 14px 0;
  background: var(--c-bg-alt);
  border-bottom: 1px solid var(--c-border);
  flex: 0 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.docs-tab {
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--c-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  white-space: nowrap;
  background: transparent;
  transition: background .12s, color .12s;
}
.docs-tab:hover {
  background: rgba(13,110,110,0.06);
  color: var(--c-primary-d);
}
.docs-tab.active {
  background: var(--c-surface);
  color: var(--c-primary-d);
  border-color: var(--c-border);
  border-bottom-color: var(--c-surface);
  margin-bottom: -1px;          /* visually merge with the body border */
  font-weight: 600;
}

/* Body + TOC two-column layout.
 *
 * The article column flexes (1fr); the TOC stays a fixed 280 px. We cap
 * the entire grid at 1700 px and centre it so very wide displays don't
 * end up with a left-aligned 820 px column floating in a sea of white.
 * Up to ~1700 px the layout fills the viewport; beyond that the gutters
 * absorb the extra width and the content stays readable.
 *
 * Inside the article column, we DON'T cap .docs-body itself — that lets
 * wide tables and code blocks use the room. Prose elements (p / ul /
 * li / blockquote) carry their own per-element max-width so reading
 * line lengths stay around 75 ch even when the column is wider.
 */
.docs-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0;
  min-height: 0;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;            /* centre the layout when viewport > max */
  background: var(--c-surface);
}
.docs-toc-wrap {
  border-left: 1px solid var(--c-border);
  background: var(--c-bg);
  overflow: auto;
}
.docs-toc {
  position: sticky;
  top: 0;
  padding: 24px 18px 24px 22px;
}
.docs-toc h4 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.docs-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
}
.docs-toc li { margin-bottom: 4px; line-height: 1.4; }
.docs-toc-l1 { font-weight: 600; }
.docs-toc-l2 { padding-left: 10px; }
.docs-toc-l3 { padding-left: 22px; color: var(--c-muted); }
.docs-toc a {
  color: var(--c-text-soft);
  text-decoration: none;
  display: block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.docs-toc a:hover {
  background: var(--c-chip-bg);
  color: var(--c-primary-d);
}
.docs-toc-empty {
  font-size: 12px;
  color: var(--c-muted);
  margin: 0;
}

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;       /* TOC drops below the article */
  }
  .docs-toc-wrap {
    border-left: none;
    border-top: 1px solid var(--c-border);
  }
  .docs-toc { position: static; padding: 18px 18px 24px; }
}

.docs-page-head {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--c-border);
}
.docs-page-source {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--c-muted);
}
.docs-page-source code {
  font-size: 11.5px;
  padding: 1px 4px;
}
.docs-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #991b1b;
}
.docs-loading {
  margin: 0;
  padding: 12px 0;
  font-size: 13px;
}

.docs-body {
  /* Fill the article column. Reading-width caps live on individual
     prose elements below so tables / pre / images can use the full
     width while paragraphs stay around 75 ch.
   */
  margin: 0;
  padding: 40px 56px 72px;
  overflow: auto;
  /* Ensure inner block elements that we DO cap stay left-aligned. */
  text-align: left;
}
.docs-body h1 {
  font-size: 1.85rem;
  color: var(--c-primary-d);
  margin: 0 0 18px;
  font-weight: 700;
}
.docs-body h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  color: var(--c-primary-d);
  margin: 32px 0 12px;
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 6px;
}
.docs-body h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  color: var(--c-text);
  margin: 20px 0 8px;
}
.docs-body p {
  margin: 0 0 12px;
  line-height: 1.65;
  color: var(--c-text-soft);
  max-width: 78ch;        /* keep reading lines comfortable on wide displays */
}
.docs-body ul, .docs-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
  max-width: 78ch;
}
.docs-body li { margin-bottom: 4px; line-height: 1.55; color: var(--c-text-soft); }
.docs-body blockquote {
  margin: 0 0 14px;
  padding: 8px 14px;
  border-left: 3px solid var(--c-border-d);
  background: var(--c-bg-alt);
  color: var(--c-text-soft);
  max-width: 78ch;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
/* Headings, tables, code blocks, images — let them use the full
 * column width so big tables don't get squashed by the 78 ch cap. */
.docs-body h1, .docs-body h2, .docs-body h3, .docs-body h4,
.docs-body table, .docs-body pre, .docs-body img,
.docs-body .md-table {
  max-width: none;
}
.docs-body img { max-width: 100%; height: auto; }
.docs-body pre {
  background: #f1f5f4;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12px;
  margin: 0 0 18px;
}
.docs-body code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
  background: var(--c-chip-bg);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}
.docs-body pre code { background: none; padding: 0; font-size: inherit; }
.docs-body hr { border: none; border-top: 1px solid var(--c-border); margin: 28px 0; }
.docs-body a { color: var(--c-primary); }
.docs-body a:hover { color: var(--c-primary-d); }
.md-table {
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 13px;
  width: 100%;
}
.md-table th, .md-table td {
  border: 1px solid var(--c-border);
  padding: 7px 11px;
  text-align: left;
}
.md-table thead { background: var(--c-bg-alt); font-weight: 600; }
.md-table tbody tr:nth-child(even) td { background: var(--c-bg); }

/* ── Hamburger button ───────────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  padding: 10px 12px;
  margin-right: 4px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); }
.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
.hamburger-icon { position: relative; }
.hamburger-icon::before,
.hamburger-icon::after { content: ''; position: absolute; left: 0; }
.hamburger-icon::before { top: -6px; }
.hamburger-icon::after  { top:  6px; }

/* ── Backdrop (mobile drawer) ───────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(15,23,42,.45);
  z-index: 900;
}

/* ── Stats cards: SVG scales down ──────────────────────────────── */
#view-stats .card { min-width: 0; }
#view-stats .card svg { max-width: 100%; height: auto; display: block; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ── Mobile breakpoints ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; align-items: center; }
  .brand-sub { display: none; }

  #sidebar {
    position: fixed;
    top: var(--topbar-h); bottom: 0; left: 0;
    width: 88vw; max-width: 360px;
    transform: translateX(-100%);
    transition: transform .2s ease-out;
    z-index: 1000;
    box-shadow: 4px 0 16px rgba(0,0,0,.18);
    overflow-y: auto;
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  #app { grid-template-columns: 1fr; }

  body.no-sidebar .sidebar-toggle { display: none; }
  body.no-sidebar .sidebar-backdrop { display: none !important; }

  .stats-charts { flex-direction: column; }
  #view-stats .card { flex: 1 1 100% !important; }
  .tabs a { padding: 7px 10px; font-size: 0.86rem; }
  .maplibregl-ctrl-top-right { top: 8px; }
}

/* ── Network view ──────────────────────────────────────────────────── */
/*
 * Force-directed graph view. The stage is a full-bleed SVG container
 * that fills the viewport; a floating legend sits top-right with
 * per-kind checkboxes, and a tooltip follows the mouse.
 */
#view-network { background: var(--c-bg); }
.network-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
}
.network-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px 8px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.network-header h2 {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-primary-d);
}
.network-sub {
  margin: 0;
  font-size: 0.84rem;
  color: var(--c-muted);
  max-width: 720px;
}
.network-actions { display: flex; gap: 8px; }
.network-actions .btn-ghost {
  background: #fff;
  border: 1px solid var(--c-border-d);
  color: var(--c-text);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.network-actions .btn-ghost:hover {
  background: var(--c-chip-bg);
  border-color: var(--c-primary);
}
.network-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  flex-wrap: wrap;
}
.network-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.net-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--c-text-soft);
  user-select: none;
}
.net-toggle input { margin: 0; }
.net-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(15,23,42,.15);
}
.network-status {
  font-size: 0.82rem;
  color: var(--c-muted);
}
.network-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, #fff 0%, #f3f1ec 60%, #e8e4dc 100%);
}
/* Two-column shell: TOC on the left, map stage on the right */
.mvg-shell {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 220px 1fr; gap: 12px;
}
.mvg-toc {
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
}
.mvg-toc h3 {
  margin: 0 4px 4px; font-size: .82rem; color: #1f2937;
}
.mvg-toc-list {
  list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0;
  overflow-y: auto; font-size: .82rem;
}
.mvg-toc-list li { margin: 0; padding: 0; }
.mvg-toc-row {
  display: grid; grid-template-columns: 14px 1fr auto;
  gap: 6px; align-items: center; width: 100%;
  background: transparent; border: none;
  padding: 4px 6px; border-radius: 4px;
  font: inherit; color: #1e293b; cursor: pointer; text-align: left;
}
.mvg-toc-row:hover { background: #e0f2fe; }
.mvg-toc-swatch {
  width: 11px; height: 11px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,.15);
}
.mvg-toc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvg-toc-count { color: #64748b; font-size: .76rem; tabular-nums: true; }
.mvg-toc-empty { color: #94a3b8; font-style: italic; padding: 6px; font-size: .82rem; }
#net-toc-reset { font-size: .78rem; padding: 5px 8px; }
@media (max-width: 760px) {
  .mvg-shell { grid-template-columns: 1fr; }
  .mvg-toc { max-height: 200px; }
}
.network-svg, .mvg-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.network-svg:active, .mvg-svg:active { cursor: grabbing; }
/* MVG / KMap polygon view: subtle styling so polygon fills don't fight node legibility. */
.mvg-polys path { transition: fill-opacity 120ms ease; }
.mvg-nodes circle { transition: r 100ms ease; }
.mvg-nodes circle:hover { r: 6; }
.mvg-edges line { stroke-linecap: round; }
.mvg-labels text { user-select: none; }

/* Per-element styling set by d3 on attributes, so we only decorate the
 * wrapper types here (selection highlight comes from d3 opacity changes). */
.net-links line { pointer-events: none; }

.network-tooltip {
  position: absolute;
  z-index: 10;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--c-border-d);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  min-width: 180px;
  max-width: 320px;
  pointer-events: none;
  font-size: 0.82rem;
  color: var(--c-text);
}
.network-tooltip .tt-kind {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.network-tooltip .tt-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--c-text);
}
.network-tooltip .tt-sub {
  color: var(--c-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.network-tooltip .tt-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--c-primary);
}
.network-tooltip .tt-url {
  margin-top: 4px;
  font-size: 0.78rem;
}
.network-tooltip .tt-url a {
  color: var(--c-primary);
  text-decoration: none;
}
.network-tooltip .tt-url a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .network-header {
    flex-direction: column;
    gap: 8px;
  }
  .network-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .network-legend { gap: 8px 12px; }
}

/* ── SQL console ───────────────────────────────────────────────────── */
#view-sql { background: var(--c-bg); }
.sql-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.sql-header {
  padding: 14px 20px 8px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.sql-header h2 {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-primary-d);
}
.sql-sub {
  margin: 0;
  color: var(--c-muted);
  font-size: 0.86rem;
  max-width: 860px;
}
.sql-sub code {
  background: var(--c-chip-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
}
.sql-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 14px;
  padding: 14px 20px 20px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.sql-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sql-examples-title,
.sql-schema-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  margin: 6px 0 4px;
}
.sql-schema-title { margin-top: 18px; }
.sql-example {
  text-align: left;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--c-text);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.sql-example:hover {
  background: var(--c-chip-bg);
  border-color: var(--c-primary);
}
.sql-example.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.sql-schema {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--c-text-soft);
}
.sql-schema li {
  padding: 2px 0;
  border-bottom: 1px dashed var(--c-border);
}
.sql-schema li:last-child { border-bottom: none; }
.sql-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.sql-description {
  margin: 0;
  padding: 8px 12px;
  background: var(--c-chip-bg);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--c-text-soft);
}
.sql-editor {
  width: 100%;
  min-height: 180px;
  max-height: 360px;
  padding: 12px 14px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  tab-size: 2;
  resize: vertical;
  outline: none;
}
.sql-editor:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.18);
}
.sql-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn-primary {
  background: var(--c-primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.btn-primary:hover { background: var(--c-primary-d); }
.sql-status { font-size: 0.82rem; color: var(--c-muted); }
.sql-status .sql-err { color: #b91c1c; font-weight: 600; }
.sql-results {
  min-height: 120px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 55vh;
}
.sql-results:empty { display: none; }
.sql-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.sql-table th,
.sql-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.sql-table th {
  position: sticky;
  top: 0;
  background: var(--c-bg-alt);
  font-weight: 700;
  color: var(--c-primary-d);
  z-index: 1;
}
.sql-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sql-table tbody tr:hover { background: var(--c-chip-bg); }
.sql-empty,
.sql-trunc {
  padding: 12px 16px;
  margin: 0;
  color: var(--c-muted);
  font-size: 0.85rem;
  font-style: italic;
}
.sql-error {
  margin: 0;
  padding: 12px 16px;
  background: #fef2f2;
  color: #991b1b;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  border-radius: var(--radius);
}
@media (max-width: 820px) {
  .sql-layout { grid-template-columns: 1fr; }
}

/* ── People: researcher directory ──────────────────────────────────── */
.ppl-page { padding: 22px clamp(16px, 3vw, 36px); max-width: 1400px; margin: 0 auto; }
.ppl-header h1 { margin: 0 0 6px; font-size: clamp(1.1rem, 1.6vw, 1.4rem); color: #0f172a; }
.ppl-summary { color: #1f2937; font-size: .96rem; margin: 4px 0 8px; max-width: 920px; }
.ppl-controls {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 14px;
}
.ppl-controls input[type=search] {
  flex: 0 0 320px; padding: 6px 10px;
  border: 1px solid var(--c-border); border-radius: 4px; font-size: .92rem;
}
.ppl-controls label { font-size: .85rem; color: #475569; }
.ppl-controls select {
  margin-left: 6px; padding: 4px 6px;
  border: 1px solid var(--c-border); border-radius: 4px;
  font-size: .85rem; background: #fff;
}
.ppl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.ppl-card {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 14px 14px;
  background: #fff;
  scroll-margin-top: 14px;
}
.ppl-card-active {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .25);
}
.ppl-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-bottom: 6px;
}
.ppl-card-head h3 { margin: 0; font-size: 1.02rem; color: #0f172a; }
.ppl-pchip {
  font-size: .72rem; padding: 2px 8px;
  background: #e0f2fe; color: #0369a1;
  border-radius: 999px; white-space: nowrap;
}
.ppl-metrics {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px; padding: 8px 0; border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9; margin-bottom: 8px;
}
.ppl-metric { font-size: .7rem; color: #64748b; text-align: center; }
.ppl-metric strong { font-size: .98rem; color: #0f172a; }

.ppl-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.ppl-cols h4 {
  margin: 0 0 4px; font-size: .76rem;
  color: #475569; text-transform: uppercase; letter-spacing: .03em;
}
.ppl-aff, .ppl-areas {
  list-style: none; margin: 0; padding: 0;
  font-size: .82rem;
}
.ppl-aff li, .ppl-areas li { padding: 3px 0; border-bottom: 1px dotted #e2e8f0; }
.ppl-aff li:last-child, .ppl-areas li:last-child { border-bottom: none; }
.ppl-aff strong { font-size: .82rem; color: #1e293b; }
.ppl-aff small { color: #475569; }
.ppl-flag {
  font-size: .68rem; padding: 1px 6px;
  background: #f1f5f9; border-radius: 3px; color: #475569;
}
.ppl-area-label { display: block; font-weight: 500; color: #1e293b; }
.ppl-areas small { color: #64748b; }
.ppl-more { font-size: .76rem; color: #94a3b8; font-style: italic; }
.ppl-none { font-size: .82rem; color: #94a3b8; font-style: italic; }
.ppl-bio, .ppl-interests {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
}
.ppl-bio h4, .ppl-interests h4 {
  margin: 0 0 4px; font-size: .76rem;
  color: #475569; text-transform: uppercase; letter-spacing: .03em;
}
.ppl-bio p, .ppl-interests p { margin: 0; font-size: .82rem; color: #1e293b; }
.ppl-links {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  font-size: .82rem; color: #475569;
}
.ppl-links a { color: #0369a1; }
@media (max-width: 600px) {
  .ppl-grid { grid-template-columns: 1fr; }
  .ppl-metrics { grid-template-columns: repeat(3, 1fr); }
  .ppl-cols { grid-template-columns: 1fr; }
}

/* ── Stats: per-research-area dashboard ────────────────────────────── */
.dash-page {
  padding: 22px clamp(16px, 3vw, 36px);
  max-width: 1400px;
  margin: 0 auto;
}
.dash-header h1 {
  margin: 0 0 6px 0;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  color: #0f172a;
}
.dash-summary { color: #1f2937; margin: 4px 0 6px; font-size: .98rem; }
.dash-help { color: #475569; font-size: .85rem; margin: 4px 0 16px; max-width: 920px; }
.dash-status { font-size: .8rem; }
.dash-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; }
.dash-toc {
  position: sticky; top: 14px; align-self: start;
  background: #f8fafc; border: 1px solid var(--c-border);
  border-radius: 6px; padding: 12px 8px; max-height: calc(100vh - 60px);
  overflow-y: auto;
}
.dash-toc h3 { margin: 0 6px 8px; font-size: .82rem; color: #1f2937; }
.dash-toc-list {
  list-style: none; margin: 0; padding: 0;
  font-size: .82rem; counter-reset: toc;
}
.dash-toc-list li a {
  display: grid; grid-template-columns: 16px 1fr auto;
  gap: 8px; align-items: center;
  padding: 5px 6px; border-radius: 4px;
  color: #1e293b; text-decoration: none;
}
.dash-toc-list li a:hover { background: #e0f2fe; }
.dash-toc .toc-swatch {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,.15);
}
.dash-toc .toc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-toc .toc-count { color: #64748b; font-size: .76rem; tabular-nums: true; }
.toc-foot { font-size: .72rem; color: #94a3b8; padding: 8px 6px 0; margin: 0; }

.dash-sections { display: flex; flex-direction: column; gap: 22px; }
.area-card {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 14px 16px 18px;
  background: #fff;
  scroll-margin-top: 14px;
}
.area-card-header {
  display: grid; grid-template-columns: 6px 1fr auto;
  gap: 14px; align-items: center;
  margin-bottom: 12px;
}
.area-bar { width: 6px; height: 38px; border-radius: 3px; align-self: stretch; }
.area-title h2 { margin: 0; font-size: 1.05rem; color: #0f172a; }
.area-slug { color: #64748b; font-size: .72rem; font-family: ui-monospace, monospace; }
.area-totals { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.t-pill {
  display: inline-block;
  padding: 3px 9px; border-radius: 999px;
  background: #f1f5f9; border: 1px solid #e2e8f0;
  font-size: .76rem; color: #1e293b;
}

.area-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-card {
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 10px 12px 12px;
  background: #fafbfc;
  min-width: 0;
}
.dash-card-coverage { grid-column: 1 / -1; }
.dash-card h4 {
  margin: 0 0 6px;
  font-size: .9rem;
  color: #1f2937;
}
.dash-sub { font-size: .75rem; color: #64748b; margin: 0 0 8px; }
.no-data { color: #94a3b8; font-style: italic; font-size: .85rem; padding: 6px 0; }

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.dash-table th {
  text-align: left; padding: 6px 6px 4px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 600; color: #475569;
  font-size: .76rem;
}
.dash-table th.num, .dash-table td.num {
  text-align: right; tabular-nums: true; white-space: nowrap;
}
.dash-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover { background: #f0f9ff; }

.cov-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.cov-block h5 { margin: 0 0 4px; font-size: .78rem; color: #475569; }
.cov-list { list-style: none; margin: 0; padding: 0; font-size: .78rem; }
.cov-row {
  display: grid; grid-template-columns: 1fr 1fr 30px; gap: 6px;
  align-items: center; padding: 2px 0;
}
.cov-label { color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cov-bar {
  height: 8px; background: #94a3b8; border-radius: 2px;
  min-width: 4px;
}
.cov-count { text-align: right; tabular-nums: true; color: #64748b; }

.gap-callout {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fff7ed;
  border-left: 3px solid #ea580c;
  border-radius: 4px;
  font-size: .82rem;
}
.gap-callout header {
  font-weight: 600; color: #9a3412; font-size: .8rem; margin-bottom: 4px;
}
.gap-callout ul { margin: 0; padding-left: 18px; color: #1c1917; }

@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-toc { position: static; max-height: none; }
  .area-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tabs a { padding: 6px 8px; font-size: 0.8rem; white-space: nowrap; }
  #topbar { padding: 0 8px; }
  .brand { font-size: 0.95rem; }
  #view-browse table { font-size: 0.82rem; }
  #view-browse th, #view-browse td { padding: 6px 8px !important; }
  #view-docs .docs-body { padding: 16px !important; font-size: 15px; line-height: 1.55; }
  .facet-body input[type=checkbox] { transform: scale(1.15); margin-right: 4px; }
  .facet-body label { padding: 5px 0; }
  .overlay-row { padding: 6px 4px; }
  #q { padding: 11px 36px 11px 12px; font-size: 1rem; }
  #q-clear { right: 10px; font-size: 1.2rem; padding: 6px; }
  .legend-control { max-width: 200px; }
}
