:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5c6672;
  --line: #d8dee6;
  --paper: #f7f8f7;
  --surface: #ffffff;
  --green: #24745a;
  --teal: #16808c;
  --blue: #315f9e;
  --red: #b4473f;
  --gold: #a56e1f;
  --plum: #7a4e78;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}

.top-nav a {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 760;
}

.top-nav a[aria-current="page"] {
  border-color: var(--green);
  background: #e8f0ed;
  color: #174838;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 28px;
  align-items: end;
  min-height: 26vh;
  padding: 20px 0 18px;
}

.directory-intro {
  min-height: 34vh;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.directory-card {
  display: grid;
  gap: 10px;
  min-height: 190px;
  border-top: 5px solid var(--blue);
  background: var(--surface);
  color: var(--ink);
  padding: 22px;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.directory-card.gold {
  border-color: var(--gold);
}

.directory-card.blue {
  border-color: var(--blue);
}

.directory-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.directory-card strong {
  font-size: 1.45rem;
}

.directory-card p {
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 850px;
  font-size: clamp(2.35rem, 5.2vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  margin-top: 18px;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  line-height: 1.5;
}

.source-note {
  display: grid;
  gap: 6px;
  border-left: 4px solid var(--gold);
  padding: 16px 0 16px 18px;
}

.source-note span,
.stat span,
.control-top span,
.meter-label span,
.donut-center span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-transform: uppercase;
}

.source-note strong {
  font-size: 1.35rem;
}

.source-note small {
  color: var(--muted);
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 18px;
}

.stat {
  min-width: 0;
  border-top: 5px solid var(--line);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  letter-spacing: 0;
}

.stat.revenue {
  border-color: var(--green);
}

.stat.outlays {
  border-color: var(--blue);
}

.stat.deficit {
  border-color: var(--red);
}

.stat.debt {
  border-color: var(--gold);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.viz-panel,
.control-panel {
  background: var(--surface);
  box-shadow: var(--shadow);
}

.viz-panel {
  padding: 22px;
}

.control-panel {
  padding: 18px;
  position: sticky;
  top: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}

.panel-heading h2 {
  font-size: 1.25rem;
}

.panel-heading p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

#resetButton {
  border: 1px solid var(--line);
  background: #f0f3f4;
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

#resetButton:hover {
  background: #e6ecee;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(220px, 330px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

.donut-wrap {
  position: relative;
  aspect-ratio: 1;
  width: min(100%, 330px);
  margin: 0 auto;
}

.donut {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: #e8ecef;
  stroke-width: 28;
}

.donut-segment {
  fill: none;
  stroke-width: 28;
  stroke-linecap: butt;
  transition: stroke-dasharray 180ms ease, stroke-dashoffset 180ms ease;
}

.donut-center {
  position: absolute;
  inset: 50%;
  display: grid;
  width: 132px;
  height: 94px;
  margin: -47px 0 0 -66px;
  place-items: center;
  text-align: center;
}

.donut-center strong {
  font-size: 1.7rem;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.92rem;
}

.bar-meta strong {
  font-weight: 780;
}

.bar-track {
  height: 16px;
  background: #edf0f2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  transition: width 180ms ease;
}

.controls {
  display: grid;
  gap: 18px;
}

.control {
  display: grid;
  gap: 9px;
}

.control-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.control-top strong {
  font-size: 0.98rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.balance-meter {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 18px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.meter-label strong {
  font-size: 1.2rem;
}

.meter-track {
  position: relative;
  height: 18px;
  margin-top: 12px;
  background: #e9edf0;
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--red);
  transition: left 180ms ease, width 180ms ease, background 180ms ease;
}

.zero-line {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 75%;
  width: 2px;
  background: var(--ink);
}

.meter-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.context-band {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: center;
  margin-top: 18px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.context-band div {
  max-width: 760px;
}

.context-band h2 {
  font-size: 1.05rem;
}

.context-band p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.context-band a {
  color: var(--blue);
  font-weight: 780;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .intro,
  .workspace,
  .chart-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

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

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

  .viz-panel,
  .control-panel {
    padding: 15px;
  }

  .panel-heading,
  .context-band {
    display: grid;
  }

  .bar-meta {
    font-size: 0.85rem;
  }
}

.military-shell {
  width: min(1240px, calc(100% - 32px));
}

.military-intro {
  min-height: 24vh;
}

.alert-strip {
  display: flex;
  gap: 10px;
  align-items: center;
  border-left: 5px solid var(--teal);
  background: #e9f3f4;
  padding: 14px 16px;
  margin: 4px 0 18px;
  line-height: 1.45;
}

.alert-strip strong {
  white-space: nowrap;
}

.alert-strip span {
  color: var(--muted);
}

.military-dashboard {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.year-rail,
.military-main,
.trend-panel,
.detail-panel,
.context-grid article {
  background: var(--surface);
  box-shadow: var(--shadow);
}

.year-rail {
  position: sticky;
  top: 14px;
  padding: 18px;
}

.year-buttons {
  display: grid;
  gap: 8px;
}

.year-buttons button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  background: #f6f8f8;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.year-buttons button[aria-pressed="true"] {
  border-color: var(--blue);
  background: #e9eef6;
}

.year-buttons span,
.toggle-block span,
.total-badge span,
.context-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.toggle-block {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #f3f5f6;
}

.segmented button {
  border: 0;
  background: transparent;
  min-height: 38px;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.military-main,
.trend-panel {
  padding: 22px;
}

.total-badge {
  display: grid;
  min-width: 150px;
  gap: 4px;
  text-align: right;
}

.total-badge strong {
  font-size: 1.7rem;
}

.stack-card {
  border: 1px solid var(--line);
  padding: 16px;
}

.stacked-bar {
  display: flex;
  height: 58px;
  overflow: hidden;
  background: #edf0f2;
}

.stack-segment {
  min-width: 2px;
  transition: width 180ms ease;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.86rem;
}

.legend-item i,
.appropriation-table i {
  width: 12px;
  height: 12px;
  display: inline-block;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  margin-top: 18px;
}

.detail-panel {
  padding: 18px;
}

.detail-panel h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.appropriation-table,
.change-list {
  display: grid;
  gap: 10px;
}

.appropriation-table article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 54px;
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.appropriation-table div {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.appropriation-table p {
  grid-column: 2;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.appropriation-table span,
.appropriation-table em {
  text-align: right;
  font-style: normal;
  white-space: nowrap;
}

.change-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 58px;
  gap: 10px;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.change-list span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.change-list b,
.change-list em {
  text-align: right;
  font-style: normal;
}

.change-list .up {
  color: var(--green);
}

.change-list .down {
  color: var(--red);
}

.trend-panel {
  margin-top: 18px;
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  min-height: 330px;
  align-items: end;
}

.trend-year {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 7px;
  min-width: 0;
  height: 300px;
  cursor: pointer;
}

.trend-stack {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  align-self: end;
  min-height: 40px;
  border: 2px solid transparent;
  background: #edf0f2;
  transition: border-color 180ms ease;
}

.trend-year.active .trend-stack {
  border-color: var(--ink);
}

.trend-stack span {
  display: block;
  width: 100%;
}

.trend-year strong,
.trend-year em {
  text-align: center;
  font-style: normal;
}

.trend-year em {
  color: var(--muted);
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.context-grid article {
  display: grid;
  gap: 7px;
  padding: 16px;
  border-top: 5px solid var(--line);
}

.context-grid article:nth-child(1) {
  border-color: var(--blue);
}

.context-grid article:nth-child(2) {
  border-color: var(--gold);
}

.context-grid article:nth-child(3) {
  border-color: var(--teal);
}

.context-grid p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .military-dashboard,
  .detail-grid,
  .context-grid {
    grid-template-columns: 1fr;
  }

  .year-rail {
    position: static;
  }

  .year-buttons {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .legend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .alert-strip,
  .appropriation-table article,
  .change-list article {
    display: grid;
  }

  .year-buttons,
  .trend-chart {
    grid-template-columns: 1fr;
  }

  .trend-chart {
    min-height: auto;
  }

  .trend-year {
    grid-template-columns: 96px minmax(0, 1fr) 82px;
    grid-template-rows: auto;
    height: auto;
    align-items: center;
  }

  .trend-stack {
    height: 34px !important;
    flex-direction: row;
  }

  .trend-stack span {
    width: auto;
    height: 100% !important;
  }

  .total-badge {
    text-align: left;
  }
}

.share-minted { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-alt); display: grid; gap: 10px; }
.share-minted-note { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.share-minted input { width: 100%; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.share-link-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.share-link-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; }
.share-link-row strong { display: block; font-size: 11px; }
.share-link-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.share-link-row.is-revoked, .share-link-row.is-expired { opacity: .55; }
