/* Inter (SIL Open Font License, fonts/OFL.txt), self-hosted: Latin subset,
   one variable file for every weight. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Palette: deep teal accent on near-white, with a matching dark theme. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #15252a;
  --muted: #566a70;
  --accent: #0d6b6b;
  --accent-strong: #094f4f;
  --accent-soft: #e5f1f0;
  --on-accent: #ffffff;
  --border: #d5e0e0;
  --border-soft: #e8eeee;
  --surface: #f4f8f8;
  --row-hover: #eef5f4;
  --error: #b3261e;
  --focus: rgb(13 107 107 / 0.35);
  --page: 72rem;
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1618;
    --fg: #e2ecec;
    --muted: #9db0b2;
    --accent: #4dbfb4;
    --accent-strong: #7fd6cd;
    --accent-soft: #15302e;
    --on-accent: #052421;
    --border: #273a3c;
    --border-soft: #1b2b2d;
    --surface: #132023;
    --row-hover: #16282a;
    --error: #ff8a80;
    --focus: rgb(77 191 180 / 0.4);
  }
}

/* Hidden means hidden, even for elements given display: flex below. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Type */

h1, h2, h3 {
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1 {
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent-strong);
}

/* Figures line up in columns. */
table, .stats dd, .price, .ccn {
  font-variant-numeric: tabular-nums;
}

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

/* Layout */

main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
}

main section {
  margin-top: 3rem;
}

/* Header: a full-width bar; its contents line up with the page. */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 2rem;
  padding: 0.85rem max(var(--gutter), calc((100% - var(--page)) / 2 + var(--gutter)));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--fg);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: var(--fg);
}

.brand svg {
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
}

.site-nav, #account-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
}

.site-nav {
  margin-right: auto;
}

#account-nav {
  min-height: 2.25rem;
}

.site-nav a, #account-nav a:not(.button) {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.site-nav a:hover, #account-nav a:not(.button):hover {
  color: var(--accent);
}

.site-nav a[aria-current="page"], #account-nav a[aria-current="page"] {
  color: var(--accent);
}

footer {
  max-width: var(--page);
  margin: 2rem auto 0;
  padding: 1.5rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* Buttons */

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

button:hover:not(:disabled), a.button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary, a.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

button.primary:hover:not(:disabled), a.button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

a.button.large, button.large {
  min-height: 2.75rem;
  padding: 0.55rem 1.2rem;
  font-size: 1rem;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* A button that reads as a link. */
button.link {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

button.link:hover:not(:disabled) {
  color: var(--accent-strong);
}

.actions, .formats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.actions {
  gap: 0.75rem;
}

.formats {
  display: inline-flex;
  gap: 0.35rem;
}

.formats button {
  min-height: 1.9rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.85rem;
}

/* Forms */

input, select {
  min-height: 2.5rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
}

input[type="checkbox"] {
  min-height: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

input[type="search"] {
  min-width: 18rem;
}

form.inline, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: end;
}

.filters {
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.filters label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
}

.error {
  color: var(--error);
  border-left: 3px solid var(--error);
  padding-left: 0.75rem;
}

/* Tables */

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

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--border);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr:hover td {
  background: var(--row-hover);
}

table.data .num {
  text-align: right;
}

table.data tr.secondary td {
  color: var(--muted);
}

table.data td {
  vertical-align: middle;
}

table.data.wrap td {
  white-space: normal;
}

/* Long text (the column descriptions) reads from the top. */
dialog table.data.wrap td {
  vertical-align: top;
}

/* Sortable table headings */
button.sort {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
}

button.sort:hover:not(:disabled) {
  color: var(--accent);
}

th[aria-sort="ascending"] button.sort, th[aria-sort="descending"] button.sort {
  color: var(--accent);
}

.summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 1.25rem 0 0.75rem;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

/* Loading */

/* A small spinner before "Loading…" text, and inside busy buttons. */
.loading::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.5em;
  vertical-align: -0.1em;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

button.loading::before {
  margin-right: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading::before { animation-duration: 3s; }
}

/* Old results stay visible, dimmed, while new ones load. */
.stale {
  opacity: 0.5;
}

/* Cards */

.cards {
  display: grid;
  gap: 1rem;
}

.cards.three {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.card {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
}

.card p {
  margin: 0.25rem 0 0;
}

.card.product {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-color: var(--border);
}

.card.product ul {
  flex: 1;
  margin: 1rem 0 1.25rem;
  padding-left: 1.1rem;
}

.card.product li {
  margin: 0.3rem 0;
}

.card.product li::marker {
  color: var(--accent);
}

.card .price {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 650;
  color: var(--accent);
}

/* Home */

.hero {
  padding: 2rem 0 0.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  max-width: 22ch;
  margin-bottom: 1.25rem;
}

.hero .lead {
  max-width: 62ch;
  margin-bottom: 1.75rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin: 2.5rem 0 0;
}

.stats div {
  padding: 0.9rem 1.1rem;
  border-radius: 8px;
  background: var(--accent-soft);
}

.stats dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.stats dd {
  margin: 0.15rem 0 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--accent-strong);
}

figure {
  margin: 1.5rem 0;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.05);
}

figcaption {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.6rem;
}

details {
  border-bottom: 1px solid var(--border-soft);
  padding: 0.75rem 0;
}

summary {
  cursor: pointer;
  font-weight: 550;
}

summary:hover {
  color: var(--accent);
}

#faq details p {
  max-width: 70ch;
  color: var(--muted);
}

/* Find a hospital */

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
}

.results:empty {
  display: none;
}

.results li + li {
  border-top: 1px solid var(--border-soft);
}

/* Each result is one clickable row: the name, then where it is. */
.results a {
  display: block;
  padding: 0.7rem 1rem;
  color: var(--fg);
  text-decoration: none;
}

.results a:hover {
  background: var(--row-hover);
}

.results .name {
  display: block;
  font-weight: 600;
}

.results a:hover .name {
  color: var(--accent);
}

.results .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* A CCN as a small tag. */
.ccn {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.hospital h2 {
  font-size: 1.75rem;
  margin: 0.75rem 0 0.25rem;
}

.hospital .where {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Downloads */

.states {
  columns: 16rem;
  margin: 0.5rem 0 0.25rem;
  padding-left: 0;
  list-style: none;
}

.states li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  break-inside: avoid;
  padding: 0.3rem 0.75rem 0.3rem 0;
}

.year summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.year summary .count {
  color: var(--muted);
  font-weight: 400;
  margin-right: auto;
}

/* Popup listing every column */

dialog.fields {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.25);
}

dialog.fields[open] {
  display: flex;
}

dialog.fields::backdrop {
  background: rgb(10 25 27 / 0.5);
}

dialog.fields p {
  margin: 0;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-head h2 {
  margin: 0;
}

.close {
  min-height: 2rem;
  padding: 0 0.6rem;
  font-size: 1.25rem;
}

.dialog-body {
  overflow: auto;
  min-height: 0;
  flex: 1;
}

.brand .mark {
  fill: var(--accent);
}

.brand .bar {
  fill: var(--on-accent);
}
