:root {
  --brand: #003c5b;
  --brand-dark: #002a41;
  --active: #2563eb;
  --active-soft: #e7f0ff;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --surface-subtle: #eef4f8;
  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --border: #d9e1e8;
  --border-strong: #b8c5d1;
  --accent-green: #13795b;
  --accent-gold: #9a6700;
  --accent-rose: #b42318;
  --accent-rust: #dc6a2a;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--surface-muted);
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button {
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.eyebrow,
.section-label {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.1;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.header-link {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.header-link:focus-visible,
button:focus-visible,
.button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.26);
  outline-offset: 2px;
}

.provider-workspace {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.provider-panel {
  z-index: 5;
  display: flex;
  min-width: 0;
  max-height: calc(100vh - 76px);
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.08);
}

.panel-heading,
.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-row {
  align-items: center;
}

.section-label {
  color: var(--accent-green);
}

.panel-heading h2,
.selected-panel h3 {
  margin: 4px 0 0;
  color: var(--brand);
  line-height: 1.15;
}

.panel-heading h2 {
  font-size: 28px;
}

.api-status {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.api-status.is-loading {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--active-soft);
  color: var(--active);
}

.api-status.is-error {
  border-color: rgba(180, 35, 24, 0.32);
  background: #fff1f0;
  color: var(--accent-rose);
}

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

.stats-grid div,
.selected-panel,
.facet-panel,
.ranking-panel,
.api-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.stats-grid div {
  min-width: 0;
  padding: 12px;
}

dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  color: var(--text);
  font-weight: 800;
}

.stats-grid dd {
  color: var(--brand-dark);
  font-size: 24px;
  line-height: 1.15;
}

.selected-panel,
.facet-panel,
.ranking-panel,
.api-chip {
  padding: 14px;
}

.selected-panel {
  display: grid;
  gap: 12px;
}

.selected-panel h3 {
  font-size: 19px;
}

.selected-panel dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.selected-panel dl div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}

.selected-panel dd {
  overflow-wrap: anywhere;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.button-secondary {
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--brand);
}

.button-secondary:hover {
  border-color: var(--brand);
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--brand);
}

.icon-button:hover {
  border-color: var(--brand);
}

.bar-list,
.provider-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
}

.bar-label,
.provider-row-name {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.bar-count,
.provider-row-count {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

.bar-track,
.provider-row-bar {
  position: relative;
  display: block;
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6ed;
}

.bar-track span,
.provider-row-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent-green) 100%);
}

.provider-list {
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.provider-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  color: inherit;
  text-align: left;
}

.provider-row:hover,
.provider-row.is-active {
  border-color: var(--brand);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.1);
}

.provider-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.provider-row-body {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.provider-row-campus {
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.provider-row-count {
  justify-self: end;
  white-space: nowrap;
}

.api-chip {
  display: grid;
  gap: 5px;
  margin-top: auto;
}

.api-chip span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.api-chip code {
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.map-shell {
  position: relative;
  min-width: 0;
  min-height: calc(100vh - 76px);
  background: #cfdde6;
}

#map {
  position: absolute;
  inset: 0;
}

.map-message {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 900;
  max-width: 620px;
  border: 1px solid rgba(180, 35, 24, 0.32);
  border-radius: 8px;
  background: #fff1f0;
  padding: 12px 14px;
  color: var(--accent-rose);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.provider-popup {
  min-width: 220px;
}

.provider-popup h3 {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 16px;
  line-height: 1.2;
}

.provider-popup dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.provider-popup div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.provider-popup dd {
  overflow-wrap: anywhere;
}

.provider-tooltip {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
}

@media (max-width: 1040px) {
  .provider-workspace {
    grid-template-columns: 1fr;
  }

  .provider-panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  }

  .map-shell {
    min-height: 62vh;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .provider-workspace,
  .map-shell {
    min-height: 68vh;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .api-status {
    align-self: flex-start;
  }

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

  .provider-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .provider-row-count {
    grid-column: 2;
    justify-self: start;
  }
}
