:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #607167;
  --line: #d8e0da;
  --soft: #eef4f0;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --accent: #0d766e;
  --accent-strong: #09514c;
  --accent-soft: #d7eeea;
  --gold: #b7791f;
  --red: #b33b36;
  --blue: #2d5f9a;
  --shadow: 0 18px 46px rgba(23, 33, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding: 34px clamp(18px, 4vw, 56px) 22px;
  border-bottom: 1px solid var(--line);
  background: #f6faf7;
}

.site-header h1,
.section-heading h2,
.selected-schools h2 {
  margin: 0;
  letter-spacing: 0;
}

.site-header h1 {
  font-size: clamp(2rem, 4vw, 4.8rem);
  line-height: 0.95;
  max-width: 780px;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 18px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.resource-links a {
  color: var(--accent-strong);
  text-underline-offset: 3px;
}

.resource-links a:hover {
  color: var(--accent);
}

.resource-links a:focus-visible,
.latest-cards:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 10px;
  min-width: min(100%, 430px);
}

.summary-strip div,
.metric-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.summary-strip div {
  padding: 14px 16px;
}

.summary-strip span {
  display: block;
  color: var(--accent-strong);
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
}

.summary-strip small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 34px) 40px;
}

.ad-slot {
  min-width: 0;
}

.ad-disclosure {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ad-slot-top {
  margin: 0 0 18px;
}

.ad-slot-bottom {
  margin: 24px 0 0;
}

.filament-ad {
  --ad-ink: #ffffff;
  --ad-text: #d5e3f4;
  --ad-button: #df2028;
  --ad-button-ink: #ffffff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: center;
  gap: 20px;
  padding: 24px 32px;
  overflow: hidden;
  border: 1px solid #214a7c;
  border-radius: 10px;
  background: #0a3161;
  color: var(--ad-ink);
  text-decoration: none;
  transition: box-shadow 160ms ease;
}

.filament-ad:hover {
  box-shadow: 0 8px 24px #17211c20;
}

.filament-ad:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.ad-copy {
  min-width: 0;
}

.ad-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.ad-logo {
  display: block;
  width: 260px;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.ad-origin {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid #ffffff40;
  color: var(--ad-text);
  font-size: 0.65rem;
  font-weight: 500;
}

.filament-ad h2 {
  margin: 13px 0 8px;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.filament-ad .ad-copy > p:not(.ad-kicker) {
  max-width: 65ch;
  margin: 0;
  color: var(--ad-text);
  font-size: 0.9rem;
  line-height: 1.55;
}

.ad-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 42px;
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--ad-button);
  color: var(--ad-button-ink);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.4;
}

.filament-ad:hover .ad-cta {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ad-art {
  display: block;
  width: 100%;
  height: auto;
}

.filament-ad-discover {
  --ad-ink: #0a3161;
  --ad-text: #455873;
  --ad-button: #df2028;
  --ad-button-ink: #ffffff;
  grid-template-columns: minmax(0, 1fr);
  padding: 23px;
  border-color: #c8d7ea;
  background: #f4f7fb;
}

.filament-ad-discover .ad-logo {
  width: 100%;
  max-width: 280px;
}

.filament-ad-discover .ad-art {
  max-width: 280px;
  margin: 12px auto 6px;
}

.ad-product {
  border: 1px solid #dce5f0;
  border-radius: 8px;
  background: #ffffff;
}

.ad-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.ad-features span {
  padding: 6px 8px;
  border: 1px solid #c8d7ea;
  border-radius: 4px;
  background: #ffffff;
  color: #0a3161;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
}

.ad-kicker {
  margin: 0 0 8px;
  color: #27527f;
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filament-ad-discover h2 {
  margin-top: 0;
  font-size: 2rem;
}

.filament-ad-discover .ad-cta {
  width: 100%;
}

.filament-ad-build {
  --ad-ink: #0a3161;
  --ad-text: #455873;
  --ad-button: #0a3161;
  --ad-button-ink: #ffffff;
  border-color: #c8d7ea;
  background: #edf4fb;
}

.filament-ad-build .ad-origin {
  border-color: #0a316130;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.control-panel,
.selected-schools,
.chart-panel,
.metric-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.field {
  grid-column: span 2;
  min-width: 0;
}

.search-field {
  grid-column: span 3;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
#table-filter {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd8d0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.group-field {
  grid-column: span 3;
}

.group-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(130px, 0.8fr) auto auto;
  gap: 8px;
}

.field-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.primary-button,
.ghost-button,
.chip button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  background: var(--accent);
  color: white;
}

.ghost-button {
  padding: 0 14px;
  background: #f7faf8;
  border-color: var(--line);
  color: var(--accent-strong);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.selected-schools {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 16px;
}

.selected-schools p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chip {
  display: inline-grid;
  grid-template-columns: 12px minmax(80px, 1fr) 28px;
  align-items: center;
  gap: 8px;
  max-width: 380px;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbf9;
}

.chip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chip span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.chip button {
  width: 28px;
  min-height: 28px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.chart-panel,
.metric-panel,
.table-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2,
.selected-schools h2 {
  font-size: 1.2rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 360px;
  aspect-ratio: 16 / 8;
}

#trend-chart {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 190px;
  max-width: min(280px, calc(100% - 24px));
  padding: 10px 12px;
  border: 1px solid rgba(23, 33, 28, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(23, 33, 28, 0.16);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  transition: opacity 120ms ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.chart-tooltip.is-below {
  transform: translate(-50%, 14px);
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.chart-tooltip span {
  display: block;
  color: var(--muted);
}

.note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.metric-panel > .eyebrow {
  flex: 0 0 auto;
  line-height: 1.5;
}

.metric-explanation {
  flex: 0 0 auto;
  margin: 0 0 12px;
  line-height: 1.45;
}

.latest-cards {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior-y: contain;
}

.metric-card {
  padding: 14px;
}

.metric-card strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.metric-score-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.rank-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.rank-badge sup {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 1;
  position: relative;
  top: -0.5em;
}

.metric-ranks {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-rank small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 500;
}

.rank-unavailable {
  color: var(--muted);
}

.metric-card .rank-badge {
  display: inline-flex;
  margin: 0;
  font-size: 1rem;
}

.metric-card .rank-badge span {
  display: inline;
  margin: 0;
  font-size: inherit;
  color: inherit;
}

.rank-badge .rank-up,
.metric-card .rank-badge .rank-up {
  color: #16803c;
}

.rank-badge .rank-down,
.metric-card .rank-badge .rank-down {
  color: #c62828;
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-card .metric-change {
  color: var(--accent-strong);
  font-weight: 700;
  line-height: 1.45;
}

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

.chart-layout > .table-panel {
  min-width: 0;
  margin-top: 0;
  grid-column: 1 / -1;
}

.statewide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 18px;
  margin-top: 18px;
}

.statewide-layout > .ranking-panel {
  margin-top: 0;
  min-width: 0;
}

.ranking-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.ranking-controls .field {
  flex: 1 1 140px;
}

.ranking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

table.ranking-table {
  min-width: 860px;
}

.ranking-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.ranking-annual {
  min-width: 160px;
  font-variant-numeric: tabular-nums;
}

.sort-column {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  text-align: inherit;
}

.sort-column:hover {
  color: var(--accent);
}

.sort-column:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sort-indicator {
  min-width: 8px;
}

.table-panel .table-wrap {
  max-height: 560px;
  margin-top: 14px;
}

.peer-add-button {
  min-height: 36px;
  padding: 6px 10px;
  white-space: nowrap;
  font-size: 0.8rem;
}

#table-filter {
  max-width: 280px;
}

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

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5faf7;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 1080px) {
  .site-header,
  .selected-schools,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .control-panel,
  .chart-layout,
  .statewide-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .field,
  .search-field,
  .group-field {
    grid-column: auto;
  }

  .chip-list {
    justify-content: flex-start;
  }

  .filament-ad-discover .ad-copy {
    display: flow-root;
  }

  .filament-ad-discover .ad-art {
    float: right;
    width: 32%;
    margin: 0 0 0 24px;
  }

  .filament-ad-discover .ad-kicker {
    margin-top: 16px;
  }

  .filament-ad-discover .ad-cta {
    width: auto;
  }
}

@media (max-width: 680px) {
  .ranking-actions {
    width: 100%;
  }

  .filament-ad {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 22px;
  }

  .filament-ad > .ad-art {
    width: min(220px, 100%);
    margin: 0 auto;
  }

  .ad-origin {
    display: none;
  }

  .filament-ad-discover .ad-art {
    float: none;
    width: 100%;
    max-width: 240px;
    margin: 12px auto;
  }

  .site-header {
    padding-top: 26px;
  }

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

  .control-panel,
  .chart-panel,
  .metric-panel,
  .table-panel {
    padding: 14px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .group-row {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .chart-wrap {
    min-height: 320px;
    aspect-ratio: 4 / 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .filament-ad {
    transition: none;
  }
}
