:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #eaf0ee;
  --ink: #16211d;
  --muted: #5b6a64;
  --border: #d7e0dc;
  --accent: #2e6e5e;
  --accent-soft: #e3efeb;
  --warn: #a9660d;
  --warn-bg: #fbeedc;
  /* pipeline stages: 5 distinct hues (not a single-color ramp) so adjacent
     stages are easy to tell apart at a glance; order is carried by the
     numbered stepper, not by color alone */
  --stage-1: #98a4a8; /* plan approved — neutral, not yet underway */
  --stage-2: #3e7cb1; /* admin structure named — blue, administrative */
  --stage-3: #1e9c8b; /* RFA issued — teal, an open opportunity */
  --stage-4: #3f8f46; /* subawards announced — green, money moving */
  --stage-5: #7b4fa6; /* funds obligated — purple, fully complete */
  --update: #c23b7a; /* "recently changed" marker — distinct from stage/warn hues */
  --update-bg: #fbe6f0;
  --personal: #3e7cb1; /* personally-sourced (by the site operator), not independently verifiable */
  --personal-bg: #e8f0f8;
  --federal: #a3392f; /* federal-level (CMS/statute) guidance — a warm brick red, distinct from every stage/accent/warn hue */
  --federal-bg: #f8e2df;
  --verified: #4a4fb0; /* cross-checked against a live federal API (USASpending.gov) — indigo, distinct from every other tag color */
  --verified-bg: #eaeaf7;
  --shadow: 0 1px 2px rgba(22, 33, 29, 0.06);
  /* Health Systems map markers, by ownership type. Deliberately NOT
     theme-swapped like the rest of the palette: these sit on top of OSM tile
     imagery, which stays light-colored regardless of the site's own
     light/dark theme, so the muted --accent/--warn/--federal hues (tuned to
     read against page chrome) washed out against map greens/tans/blues.
     Saturated and mutually distinct instead, so the circles pop in both
     themes. */
  --owner-nonprofit: #15803d;
  --owner-forprofit: #ea580c;
  --owner-government: #1d4ed8;
  --owner-unknown: #57606a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101513;
    --surface: #1a211e;
    --surface-2: #212a26;
    --ink: #e7eeec;
    --muted: #93a39c;
    --border: #2b3733;
    --accent: #6fbfa8;
    --accent-soft: #1e3a33;
    --warn: #e3a94c;
    --warn-bg: #3a2a12;
    --stage-1: #7c878c;
    --stage-2: #6fa8d8;
    --stage-3: #4fc4b3;
    --stage-4: #6fbf74;
    --stage-5: #b58ae0;
    --update: #ea6ba3;
    --update-bg: #3a1f2c;
    --personal: #6fa8d8;
    --personal-bg: #1c2b3a;
    --federal: #e0897c;
    --federal-bg: #3a221e;
    --verified: #9fa3e8;
    --verified-bg: #26284a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #101513;
  --surface: #1a211e;
  --surface-2: #212a26;
  --ink: #e7eeec;
  --muted: #93a39c;
  --border: #2b3733;
  --accent: #6fbfa8;
  --accent-soft: #1e3a33;
  --warn: #e3a94c;
  --warn-bg: #3a2a12;
  --stage-1: #7c878c;
  --stage-2: #6fa8d8;
  --stage-3: #4fc4b3;
  --stage-4: #6fbf74;
  --stage-5: #b58ae0;
  --update: #ea6ba3;
  --update-bg: #3a1f2c;
  --personal: #6fa8d8;
  --personal-bg: #1c2b3a;
  --federal: #e0897c;
  --federal-bg: #3a221e;
  --verified: #9fa3e8;
  --verified-bg: #26284a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 56px;
}

/* ---- masthead ---- */
header.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  padding: 40px 0 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  flex: none;
  width: 72px;
  height: auto;
}

.kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}

.intro-line {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 60ch;
  margin: 10px 0 0;
}

h1 {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-weight: 600;
  font-size: 30px;
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  letter-spacing: -0.01em;
}

.wordmark {
  height: 64px;
  width: auto;
  max-width: 100%;
  align-self: center;
}

@media (max-width: 480px) {
  .wordmark { height: 34px; }
  .brand-icon { width: 40px; }
}

/* Theme-swapped image pairs (the wordmark and the icon each ship a light-
   and a dark-background render): -dark hides by default, and either the
   system dark preference or an explicit toggle flips which one shows. */
.wordmark-dark, .brand-icon-dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark-light,
  :root:not([data-theme="light"]) .brand-icon-light { display: none; }
  :root:not([data-theme="light"]) .wordmark-dark,
  :root:not([data-theme="light"]) .brand-icon-dark { display: block; }
}

:root[data-theme="dark"] .wordmark-light,
:root[data-theme="dark"] .brand-icon-light { display: none; }
:root[data-theme="dark"] .wordmark-dark,
:root[data-theme="dark"] .brand-icon-dark { display: block; }

.last-updated {
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  cursor: pointer;
}

.last-updated:hover { border-color: var(--accent); }

.masthead-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px 20px;
}

nav.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

nav.tabs a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 6px;
  transition: background 120ms ease, color 120ms ease;
}

nav.tabs a:hover:not(.active) {
  background: var(--surface);
  color: var(--accent);
}

nav.tabs a.active {
  background: var(--accent);
  color: var(--surface);
  box-shadow: var(--shadow);
}

/* Deliberately its own button, not a fourth tab: the three tabs above are
   views of one dataset (the RHTP tracker) and read as a set; the Health
   Systems map is a different kind of thing — an exploratory tool that talks
   live to an outside federal API — so it gets its own shape and color
   rather than a decorated slot in that set. Reuses the --verified indigo
   already used elsewhere for "cross-checked against a live federal API," a
   real semantic match rather than an arbitrary new accent. */
.hs-launch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--verified);
  color: var(--verified);
  background: var(--verified-bg);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.hs-launch:hover:not(.active) { background: color-mix(in srgb, var(--verified) 22%, var(--verified-bg)); }

.hs-launch.active {
  background: var(--verified);
  color: var(--surface);
  box-shadow: var(--shadow);
}

.hs-launch-icon { flex: none; }

.stamp {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.6;
}

.stamp strong { color: var(--ink); font-weight: 500; }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  font-size: 15px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex: none;
}

.theme-toggle:hover { border-color: var(--accent); }

/* ---- summary ---- */
.summary {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 36px;
  align-items: end;
  padding: 4px 0 30px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 760px) {
  .summary { grid-template-columns: 1fr; }
}

.metric .value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.metric .label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.pipeline { min-width: 260px; }

.pipeline .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.segbar {
  display: flex;
  height: 11px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
}

.segbar span {
  display: block;
  height: 100%;
  cursor: pointer;
  transition: opacity 120ms ease;
}

.segbar span.dim { opacity: 0.32; }

.segbar-caption {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}

.legend .arrow {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  padding: 0 2px;
  user-select: none;
}

.legend .step {
  display: flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 13px 6px 8px;
  cursor: pointer;
  /* Each stage gets its own tinted background so the pipeline reads as 5
     distinct colors at a glance, not 5 gray rows with a small dot. */
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 15%, var(--surface-2));
  color: color-mix(in srgb, var(--stage-color, var(--muted)) 85%, var(--ink));
}

.legend .step:hover:not(:disabled) {
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 26%, var(--surface-2));
}

.legend .step:disabled {
  opacity: 0.5;
  cursor: default;
  background: var(--surface-2);
  color: var(--muted);
}

.legend .step.active {
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 42%, var(--surface-2));
  border-color: color-mix(in srgb, var(--stage-color, var(--muted)) 70%, var(--ink));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--stage-color, var(--muted)) 70%, var(--ink)) inset;
}

/* Same specificity as the plain :hover rule above — declared after it so an
   active button keeps its stronger fill on hover instead of fading back to
   the generic (and, for a selected button, weaker-looking) hover tint. */
.legend .step.active:hover {
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 50%, var(--surface-2));
}

.legend .step-num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  color: color-mix(in srgb, var(--stage-color, var(--muted)) 85%, var(--ink));
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.legend .step.active .step-num {
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 70%, var(--ink));
  color: var(--surface);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.filter-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink);
}

.filter-banner[hidden] { display: none; }

.filter-banner button {
  font: inherit;
  font-size: 11.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 9px;
  cursor: pointer;
}

.filter-banner button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- award map ---- */
.map-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.map-header .label { font-size: 12px; color: var(--muted); }

.map-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.map-toggle button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

.map-toggle button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

#us-map {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

#us-map svg { width: 100%; height: auto; display: block; }

#us-map path.state {
  stroke: var(--surface);
  stroke-width: 1px;
  cursor: pointer;
  transition: opacity 120ms ease;
}

#us-map path.state:hover { opacity: 0.78; }
#us-map path.state.untracked { cursor: default; }
#us-map path.state.untracked:hover { opacity: 1; }

.map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.map-legend-label { font-size: 11px; color: var(--muted); }

.map-legend-scale {
  display: flex;
  height: 8px;
  width: 180px;
  border-radius: 4px;
  overflow: hidden;
}

.map-legend-scale span { flex: 1; }

.map-caption {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 0;
  max-width: 60ch;
  margin-left: auto;
  margin-right: auto;
}

/* ---- health systems map ---- */
.hs-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

#hs-map {
  width: 100%;
  height: 520px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

@media (max-width: 640px) {
  #hs-map { height: 380px; }
}

/* Leaflet renders its own inline chrome (tiles, zoom control, attribution) —
   only the popup and marker layer need theme-matching; everything else is
   left at Leaflet's defaults. */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface);
  color: var(--ink);
}

.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.hs-popup { font-size: 12.5px; line-height: 1.5; }
.hs-popup-title { font-weight: 600; margin-bottom: 2px; }
.hs-popup-caution { color: var(--warn); }
.hs-popup a { color: var(--accent); }

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
}

.leaflet-control-attribution a { color: var(--muted); }

.hs-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}

.hs-legend-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hs-legend-title { font-size: 11px; color: var(--muted); }

.hs-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.hs-legend-item svg { flex-shrink: 0; }
.hs-legend-range { opacity: 0.75; }

.hs-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.hs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.hs-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hs-card-head h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  flex: 1 1 auto;
}

.hs-card-body {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.hs-notes {
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 0;
}

.hs-card .tl-source {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.hs-card .tl-source:hover { text-decoration: underline; }

.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
  max-width: 220px;
}

.map-tooltip .mt-state {
  font-weight: 600;
  font-family: "IBM Plex Serif", Georgia, serif;
  margin-bottom: 2px;
}

.map-tooltip .mt-value { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

.table-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.table-controls label {
  font-size: 11.5px;
  color: var(--muted);
}

.table-controls select {
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
}

.table-controls select:hover { border-color: var(--accent); }

/* ---- desktop table vs. mobile card list ----
   Genuinely different layouts, not one squeezed into the other: a dense
   comparison table reads fine on a desktop-width screen but turns into an
   unreadable horizontal-scroll strip on a phone, so narrow viewports get a
   stacked card list built for a thumb instead. */
.mobile-only { display: none; }

@media (max-width: 680px) {
  .desktop-only { display: none; }
  .mobile-only { display: flex; }

  /* The pipeline legend above the table wraps to multiple lines on a phone;
     the arrow separators only made sense in a single horizontal row, so drop
     them here and let the wrap gap alone carry the separation. */
  .legend { gap: 6px 8px; }
  .legend .arrow { display: none; }
  .legend .step { padding: 5px 10px 5px 7px; font-size: 11px; }
}

.cards-wrap {
  flex-direction: column;
  gap: 10px;
}

.state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.state-card .sc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.state-card .sc-name-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.state-card .sc-name {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
}

.state-card .sc-agency { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }

.state-card .sc-stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.state-card .sc-amounts { display: flex; flex-direction: column; margin-bottom: 10px; }

.state-card .sc-amount {
  font-family: "IBM Plex Mono", monospace;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.state-card .sc-amount-label { font-size: 11px; color: var(--muted); }

.state-card .sc-sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}

.state-card .sc-sub .sa-label { font-family: "IBM Plex Sans", sans-serif; color: var(--muted); }

.state-card .sc-notes {
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.state-card .sc-notes .flag-mark { color: var(--warn); font-weight: 600; margin-right: 4px; }

.state-card .sc-links {
  display: flex;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ---- states table ---- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table.states {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}

table.states thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.states th.num, table.states td.num { text-align: right; }

table.states tbody tr { border-bottom: 1px solid var(--border); }
table.states tbody tr:last-child { border-bottom: none; }
table.states tbody tr:hover { background: var(--surface-2); }

table.states td {
  padding: 12px 14px;
  vertical-align: middle;
}

.state-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.updated-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--update);
  background: var(--update-bg);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: default;
}

.updated-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--update);
}

.changelog-banner {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--update-bg);
  color: var(--update);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 16px;
}

.changelog-banner strong { font-weight: 600; white-space: nowrap; }

.cell-state .state-name {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}

.cell-state .state-name:hover, .cell-state .state-name:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.cell-state .state-agency {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  padding: 4px 11px 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--stage-color, var(--muted)) 16%, var(--surface));
  color: color-mix(in srgb, var(--stage-color, var(--muted)) 80%, var(--ink));
}

.stage-pill .dot {
  width: 9px;
  height: 9px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--stage-color, var(--muted)) 30%, transparent);
}

td.num.amount {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

td.num.sub {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.4;
}

td.num.sub.empty { color: var(--muted); font-family: "IBM Plex Sans", sans-serif; }

td.num.sub .sa-label {
  display: block;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}

/* Disbursement progress bar: subawards_amount as a share of the total award.
   Shared markup/styling across the table, cards, and detail page — one visual
   language for "how far along is this state, not just which gate did it
   clear." The percentage is exact; whether the subawards figure itself is a
   complete tally or just a first round is explained in the sa-label text
   right above it, not re-litigated here. */
.disb-bar {
  margin-top: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.disb-fill {
  height: 100%;
  background: var(--stage-4);
  border-radius: 2px;
}

.disb-pct {
  margin-top: 2px;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 400;
  font-size: 10px;
  color: var(--muted);
}

.cell-notes {
  max-width: 460px;
  min-width: 260px;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.5;
}

/* The line-clamp hack needs its own box (display:-webkit-box) — applied to
   this inner wrapper, not the <td> itself, since overriding a table cell's
   display away from table-cell pulls it out of the table's column grid
   entirely (rows then stack cells instead of laying them out side by side). */
.cell-notes-inner {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cell-notes .flag-mark {
  color: var(--warn);
  font-weight: 600;
  margin-right: 4px;
}

.cell-links {
  white-space: nowrap;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.official-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 7px;
  white-space: nowrap;
}

.official-badge:hover, .official-badge:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* usaspending-mark: a small inline seal icon next to a dollar figure in the
   table/cards. usaspending-badge: the fuller pill version used in the detail
   page. Both link out to the specific federal award record they verify. The
   seal glyph (not a checkmark) keeps this visually distinct from the
   confirmed/unverified sourcing-confidence dots used elsewhere. */
.usaspending-mark {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  color: var(--verified);
  text-decoration: none;
  vertical-align: middle;
}

.usaspending-mark:hover, .usaspending-mark:focus-visible { color: var(--ink); }

.usaspending-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--verified);
  background: var(--verified-bg);
  text-decoration: none;
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
}

.usaspending-badge:hover, .usaspending-badge:focus-visible { text-decoration: underline; }
.usaspending-badge .verified-icon, .usaspending-mark .verified-icon { flex-shrink: 0; }

.details-link { font-size: 12px; font-weight: 600; text-decoration: none; }
.details-link:hover { text-decoration: underline; }

/* ---- detail page ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 22px;
}

.back-link:hover { text-decoration: underline; }

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

.detail-head h1 {
  font-size: 28px;
  margin: 6px 0 2px;
}

.detail-head .official-badge { font-size: 11px; padding: 5px 9px; }
.detail-head .agency { font-size: 13px; color: var(--muted); }

.detail-amount { text-align: right; }
.detail-amount .amount {
  font-family: "IBM Plex Mono", monospace;
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.detail-amount .amount-label { font-size: 11px; color: var(--muted); margin: 2px 0; }
.detail-amount .sub {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--accent);
}
.detail-amount .sub .sa-label { color: var(--muted); font-family: "IBM Plex Sans", sans-serif; }

.overview-section {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.overview-section h2 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: 600;
}

.overview-caption {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 62ch;
  margin: 0 0 16px;
  line-height: 1.5;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
}

@media (max-width: 640px) { .overview-grid { grid-template-columns: 1fr; } }

.overview-field { margin-bottom: 18px; }
.overview-field:last-child { margin-bottom: 0; }

.overview-field h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}

.overview-field p {
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
  max-width: 60ch;
}

.pillar-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pillar-detail-item {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pillar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.pillar-desc {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.pillar-desc-empty { font-style: italic; }

.contact-block { font-size: 13px; line-height: 1.6; }
.contact-block .contact-name { font-weight: 600; }
.contact-block .contact-muted { color: var(--muted); font-size: 12px; }

.detail-body {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 40px;
}

@media (max-width: 640px) { .detail-body { grid-template-columns: 1fr; } }

.detail-main h2, .detail-side h2, .compare-head h2.section-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 600;
}

.detail-main p { font-size: 14.5px; line-height: 1.7; max-width: 62ch; margin: 0 0 4px; }

.flag {
  display: block;
  margin-top: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  padding: 7px 9px;
  border-radius: 5px;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 500;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}

.detail-side a { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 500; }
.detail-side a:hover { text-decoration: underline; }

/* ---- timeline ---- */
.timeline {
  grid-column: 1 / -1;
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  list-style: none;
  padding-left: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 96px 14px 1fr;
  gap: 4px 14px;
}

.timeline li:not(:last-child) { padding-bottom: 20px; }

.timeline .tl-date {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--muted);
  padding-top: 2px;
}

.timeline .tl-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline .tl-rail .tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 3px;
}

.timeline .tl-rail .tl-line {
  flex: 1;
  width: 1px;
  background: var(--border);
  margin-top: 4px;
}

.timeline .tl-status {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.timeline .tl-notes { font-size: 13px; line-height: 1.55; margin-bottom: 6px; }
.timeline .tl-source { font-size: 11.5px; text-decoration: none; color: var(--accent); }
.timeline .tl-source:hover { text-decoration: underline; }

/* ---- comparison / applicant notes ---- */
.compare {
  grid-column: 1 / -1;
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.compare-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.compare-head h2 {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.compare-caption {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 62ch;
  margin: 0 0 18px;
  line-height: 1.5;
}

.rank-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 22px;
}

.rank-line strong { font-weight: 600; }

.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 640px) { .pros-cons { grid-template-columns: 1fr; } }

.pros-cons h3 {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.pros-cons .pros h3 { color: var(--stage-4); }
.pros-cons .cons h3 { color: var(--warn); }

.pros-cons ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }

.pros-cons li { font-size: 13px; line-height: 1.55; padding-left: 18px; position: relative; }

.pros-cons li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pros-cons .pros li::before { background: var(--stage-4); }
.pros-cons .cons li::before { background: var(--warn); }

/* ---- calendar ---- */
.cal-caption {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 68ch;
  line-height: 1.55;
  margin: 0 0 26px;
}

.cal-list { display: flex; flex-direction: column; gap: 12px; }

.cal-item {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

@media (max-width: 600px) { .cal-item { grid-template-columns: 1fr; } }

.cal-when {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.4;
}

.cal-when .cal-days { display: block; font-size: 10.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.cal-body h3 {
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 3px;
}

.cal-body .cal-state { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.cal-body .cal-notes { font-size: 13px; line-height: 1.55; margin: 0 0 8px; }
.cal-body a { font-size: 12px; text-decoration: none; font-weight: 500; }
.cal-body a:hover { text-decoration: underline; }

.caution {
  display: block;
  margin-top: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  padding: 7px 9px;
  border-radius: 5px;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 500;
  border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent);
}

.caution::before { content: "⚠ NEEDS VERIFICATION — "; font-weight: 700; }

.cal-when.unverified, .cal-when .caution-tag {
  color: var(--warn);
}

.caution-tag {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 4px;
}

/* Personally-sourced (by the site operator) — distinct from an "unverified"
   public-source lead: this is disclosed as a first-hand claim, not a
   secondary source or a fetch failure, so it gets its own color rather than
   sharing the caution-amber. */
.caution.personal {
  background: var(--personal-bg);
  color: var(--personal);
  border-color: color-mix(in srgb, var(--personal) 55%, transparent);
}

.caution.personal::before { content: "PERSONAL SOURCE — "; }

.caution-tag.personal, .cal-when .caution-tag.personal {
  color: var(--personal);
  background: var(--personal-bg);
}

.angle-tag {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 7px;
  margin-left: 8px;
}

.cal-empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.site-footer {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
}

.disclaimer {
  max-width: 78ch;
  line-height: 1.55;
  margin: 0 0 16px;
}

.footer-legal {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.footer-legal p { margin: 0 0 6px; line-height: 1.55; }

@media (prefers-reduced-motion: no-preference) {
  table.states tbody tr { transition: background 120ms ease; }
}

/* ---- site search ---- */
.site-search {
  position: relative;
  margin: 18px 0 26px;
}

.site-search input {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.site-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.site-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
}

.search-group + .search-group { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 4px; }

.search-group-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px 2px;
}

.search-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.search-result:hover, .search-result:focus-visible { background: var(--surface-2); outline: none; }

.search-result .sr-label { font-weight: 500; font-size: 13px; }
.search-result .sr-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.search-empty { padding: 14px 10px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ---- federal guidelines info button + modal ---- */
.pipeline-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.info-btn {
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--federal);
  background: var(--federal-bg);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  white-space: nowrap;
}

.info-btn:hover { border-color: var(--federal); }

/* The sidebar column is a fixed 240px, too narrow for the label at the
   base .info-btn's nowrap/full-pill styling — override both so long text
   wraps inside a rounded rect instead of spilling past the pill's curve. */
.info-btn-block {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 4px;
  white-space: normal;
  line-height: 1.4;
  border-radius: 10px;
}

.cal-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.cal-toolbar .cal-caption { margin-bottom: 0; flex: 1 1 320px; }

.cal-filter-row { margin: 0 0 18px; }

.cal-filter-row input {
  font: inherit;
  font-size: 13px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  max-width: 320px;
}

.cal-filter-row input:focus { outline: none; border-color: var(--accent); }

a.cal-state {
  display: inline-block;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 8px;
  font-weight: 500;
}

a.cal-state:hover { text-decoration: underline; }

.federal-category {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--federal) !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 16, 14, 0.5);
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px;
  overflow-y: auto;
}

/* Higher specificity than the bare .modal-overlay display below, so the
   [hidden] attribute (toggled from JS via .hidden = true/false) always wins
   over the flex layout needed to center the modal when it's shown. */
.modal-overlay:not([hidden]) { display: flex; }

body.modal-open { overflow: hidden; }

.modal {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal h2 { font-family: "IBM Plex Serif", Georgia, serif; font-size: 20px; margin: 0 0 10px; padding-right: 30px; }

.modal-caption { font-size: 12.5px; color: var(--muted); line-height: 1.55; max-width: 62ch; margin: 0 0 20px; }

.modal .cal-list { max-height: 55vh; overflow-y: auto; padding-right: 4px; }

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { color: var(--ink); border-color: var(--accent); }

/* ---- state-detail deadlines sidebar ---- */
.deadlines-heading { margin-top: 8px; }

.side-empty { font-size: 12px; color: var(--muted); margin: 0; }

.side-deadline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.side-deadline-list li { font-size: 12.5px; line-height: 1.4; }

.side-deadline-list .sd-when {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.side-deadline-list .sd-title { color: var(--ink); }
