:root {
  --ink: #14231c;
  --ink-soft: #3d5248;
  --paper: #f4f0e8;
  --paper-2: #e7efe9;
  --teal: #0d5c4d;
  --teal-deep: #094539;
  --gold: #b8892d;
  --rise: #1f7a4d;
  --rise-soft: rgba(31, 122, 77, 0.16);
  --fall: #b23a2c;
  --fall-soft: rgba(178, 58, 44, 0.14);
  --line: rgba(20, 35, 28, 0.12);
  --shadow: 0 18px 40px rgba(20, 35, 28, 0.08);
  --radius: 14px;
  --max: 1120px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--paper);
  line-height: 1.5;
  min-height: 100vh;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(184, 137, 45, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(13, 92, 77, 0.16), transparent 50%),
    linear-gradient(165deg, #f7f3eb 0%, #eef4ef 42%, #f3eee4 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 1.1rem;
  background: rgba(13, 92, 77, 0.96);
  box-shadow: 0 10px 28px rgba(13, 92, 77, 0.18);
}

.site-nav-logo {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f7f3eb !important;
  text-decoration: none !important;
  white-space: nowrap;
  padding: 0.15rem 0.2rem;
}

.site-nav-logo:hover {
  color: #fff !important;
}

.site-nav-scroll {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 243, 235, 0.35) transparent;
  padding: 0.1rem 0;
}

.site-nav-scroll a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: rgba(247, 243, 235, 0.82) !important;
  text-decoration: none !important;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.52rem 0.82rem;
  border-radius: 999px;
  background: rgba(247, 243, 235, 0.1);
  border: 1px solid rgba(247, 243, 235, 0.12);
  white-space: nowrap;
}

.site-nav-scroll a:hover {
  color: #fff !important;
  background: rgba(247, 243, 235, 0.2);
}

.site-nav-scroll a[aria-current="page"] {
  color: var(--teal-deep) !important;
  background: #f7f3eb;
  border-color: #f7f3eb;
}

.site-nav-scroll .nav-split {
  flex: 0 0 auto;
  width: 1px;
  height: 1.15rem;
  margin: 0 0.25rem;
  background: rgba(247, 243, 235, 0.28);
}

@media (max-width: 640px) {
  .site-nav {
    padding: 0.55rem 0.7rem;
    gap: 0.55rem;
  }

  .site-nav-logo {
    font-size: 0.95rem;
  }

  .site-nav-scroll a {
    font-size: 0.8rem;
    padding: 0.45rem 0.7rem;
  }
}

.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) 1.25rem 1.5rem;
  animation: rise-in 0.8s ease both;
}

.hero.compact {
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
}

.brand {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--teal-deep);
}

.hero h1 {
  margin: 0;
  max-width: 16ch;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3.4vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lede {
  margin: 1rem 0 0;
  max-width: 48ch;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--teal);
  color: #f7f3eb;
}

.btn.primary:hover {
  background: var(--teal-deep);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
}

.snapshot {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0.5rem 0 1.75rem;
  animation: rise-in 0.9s ease 0.1s both;
}

.snap {
  padding: 1rem 1.05rem 0.95rem;
  border-top: 2px solid var(--teal);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.2));
}

.snap-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.snap strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.snap strong.up {
  color: var(--rise);
}

.snap strong.down {
  color: var(--fall);
}

.panel {
  padding: 1.35rem 0 0.5rem;
  animation: rise-in 1s ease 0.15s both;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  align-items: end;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  max-width: 52ch;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  min-width: min(100%, 420px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.field.grow {
  flex: 1;
  min-width: 160px;
}

.field select,
.field input {
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.leg::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: -0.05rem;
}

.leg.rise::before {
  background: var(--rise);
}

.leg.fall::before {
  background: var(--fall);
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 14rem) 1fr minmax(5.5rem, 7rem);
  gap: 0.65rem;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.row:hover,
.row:focus-visible {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--line);
  outline: none;
}

.row.active {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(13, 92, 77, 0.35);
  box-shadow: var(--shadow);
}

.row-name {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.row-name strong {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-name span {
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track {
  position: relative;
  height: 1.55rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--fall-soft) 0%,
    var(--fall-soft) 50%,
    var(--rise-soft) 50%,
    var(--rise-soft) 100%
  );
  overflow: hidden;
}

.track::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(20, 35, 28, 0.28);
}

.bar {
  position: absolute;
  top: 0.28rem;
  bottom: 0.28rem;
  border-radius: 3px;
  transform-origin: center;
  animation: bar-grow 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.bar.rise {
  left: 50%;
  background: linear-gradient(90deg, #2a9460, var(--rise));
}

.bar.fall {
  right: 50%;
  background: linear-gradient(90deg, var(--fall), #d46555);
}

/* Absolute levels (not Δ) — fill left → right */
.track.level {
  background: rgba(20, 35, 28, 0.08);
}

.track.level::before {
  display: none;
}

.bar.level {
  left: 0;
  background: linear-gradient(90deg, #1f6f5c, #2a9460);
  transform-origin: left center;
  /* Avoid scaleX grow animation — can leave bars invisible if interrupted */
  animation: none;
  transform: none;
}

.bar.level.ps {
  background: #1f6f5c;
}

.bar.level.mooe {
  background: #3d8a6a;
}

.bar.level.co {
  background: #b8892d;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
  color: var(--ink, #14231c);
}

.delta {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
}

.delta.up {
  color: var(--rise);
}

.delta.down {
  color: var(--fall);
}

.detail {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.pill {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.pill.up {
  color: var(--rise);
}

.pill.down {
  color: var(--fall);
}

.years {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.85rem 0 1.1rem;
}

.years div {
  padding: 0.85rem 0.95rem;
  border-left: 3px solid var(--gold);
  background: rgba(255, 255, 255, 0.45);
}

.years span {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.years strong {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.up {
  color: var(--rise);
  font-weight: 600;
}

td.down {
  color: var(--fall);
  font-weight: 600;
}

.empty {
  color: var(--ink-soft);
  margin: 0.5rem 0 0;
}

.hint {
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.panel-head.tight {
  margin-top: 1.4rem;
  margin-bottom: 0.65rem;
  align-items: start;
}

.panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.pill.muted {
  color: var(--ink-soft);
  font-size: 1.1rem;
}

#agency-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

#agency-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.55);
}

#agency-table tbody tr.active-agency {
  background: rgba(13, 92, 77, 0.08);
}

#agency-table tbody tr.active-agency td:first-child {
  box-shadow: inset 3px 0 0 var(--teal);
}

.funding {
  margin-top: 0.5rem;
  animation: rise-in 0.45s ease both;
}

.funding-overview {
  margin-bottom: 0.5rem;
}

.fund-stack {
  display: flex;
  width: 100%;
  height: 1.35rem;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(20, 35, 28, 0.06);
  margin-bottom: 0.75rem;
}

.fund-stack.tall {
  height: 1.85rem;
  margin-bottom: 1rem;
}

.fund-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}

.fund-group {
  padding: 0.75rem 0.85rem;
  border-top: 3px solid var(--teal);
  background: rgba(255, 255, 255, 0.45);
}

button.fund-group,
button.sector-tile {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-left: none;
  border-right: none;
  border-bottom: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

button.sector-tile:hover,
button.sector-tile.active {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.fund-group .fg-label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.fund-group strong {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.fund-group .fg-share {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.fund-seg {
  height: 100%;
  min-width: 2px;
  transition: flex-grow 0.4s ease;
}

button.fund-seg {
  display: block;
  flex-shrink: 0;
  margin: 0;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

button.fund-seg:hover {
  filter: brightness(1.08);
}

button.fund-seg:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  z-index: 1;
}

.fund-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  margin-bottom: 0.85rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.fund-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fund-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

.dept-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.dept-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(7rem, 0.7fr);
  gap: 0.35rem 1rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.4);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dept-row:hover,
.dept-row.active {
  border-color: var(--teal);
  background: rgba(13, 92, 77, 0.06);
}

.dept-row.static {
  cursor: default;
}

.dept-row.static:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.4);
}

#fund-overview-table tbody tr.fund-row {
  cursor: pointer;
}

#fund-overview-table tbody tr.fund-row:hover,
#fund-overview-table tbody tr.fund-row.active {
  background: rgba(13, 92, 77, 0.08);
}

.fund-group.active {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(12rem, 0.7fr);
  gap: 1rem;
  align-items: start;
}

.flood-map {
  width: 100%;
  height: min(62vh, 560px);
  min-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #eef4ef;
  z-index: 0;
}

.map-side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.map-legend {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.82rem;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0;
  color: var(--ink-soft);
}

.legend-row i {
  width: 1rem;
  height: 0.7rem;
  border-radius: 2px;
  flex: 0 0 auto;
  border: 1px solid rgba(20, 35, 28, 0.12);
}

.map-selected {
  padding: 0.85rem;
  border-top: 3px solid var(--teal);
  background: rgba(255, 255, 255, 0.45);
}

.map-selected strong {
  display: block;
  font-size: 0.95rem;
}

.map-amt {
  margin: 0.35rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--teal-deep);
}

@media (max-width: 820px) {
  .map-layout {
    grid-template-columns: 1fr;
  }

  .flood-map {
    height: 420px;
  }
}

.dept-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.65rem;
  min-width: 0;
}

.dept-name {
  font-weight: 600;
  line-height: 1.25;
}

.dept-acr {
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.dept-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.dept-row-meta strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
}

.dept-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(20, 35, 28, 0.08);
  overflow: hidden;
}

.dept-bar i {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: inherit;
}

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

  .dept-row-meta {
    align-items: flex-start;
  }
}

.foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.bar.rise {
  transform-origin: left center;
}

.bar.fall {
  transform-origin: right center;
}

.summary-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
  color: var(--ink, #14231c);
  line-height: 1.45;
}

.yoy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.yoy-card {
  padding: 0.9rem 1rem 1rem;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(20, 35, 28, 0.08);
}

.yoy-card h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.yoy-bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  align-items: end;
  min-height: 120px;
  margin-top: 0.75rem;
}

.yoy-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
  justify-content: flex-end;
}

.yoy-bar {
  width: 100%;
  max-width: 42px;
  background: linear-gradient(180deg, #1f6f8b, #0d5c4d);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}

.yoy-year {
  font-size: 0.72rem;
  opacity: 0.7;
}

.yoy-val {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

@media (max-width: 980px) {
  .snapshot {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .snapshot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .delta,
  .amount {
    text-align: left;
  }

  .years {
    grid-template-columns: 1fr;
  }
}

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

  .brand {
    font-size: 2.3rem;
  }
}
