html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2933;
  background: #fff;
}

header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #d9dee3;
}

#sidebar-toggle {
  flex: none;
  padding: 6px 10px;
  border: 1px solid #c2410c;
  border-radius: 4px;
  background: #fff;
  color: #9a3412;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-open #sidebar-toggle {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}

main {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#sidebar {
  display: none;
  flex: none;
  width: 340px;
  overflow-y: auto;
  padding: 4px 16px 16px;
  border-right: 1px solid #d9dee3;
  font-size: 0.875rem;
  line-height: 1.5;
  background: #fff;
}

.sidebar-open #sidebar {
  display: block;
}

#sidebar h2 {
  margin: 16px 0 6px;
  font-size: 1rem;
}

#sidebar p,
#sidebar ul {
  margin: 0 0 8px;
}

#sidebar ul {
  padding-left: 18px;
}

#sidebar li {
  margin-bottom: 6px;
}

#sidebar a {
  color: #1d4ed8;
}

#sidebar .hint {
  color: #52606d;
}

.top-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-list button {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e4e7eb;
  border-radius: 4px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.top-list button:hover,
.top-list button:focus-visible {
  border-color: #ea580c;
  background: #fff7ed;
}

.top-list .title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.top-list .where {
  display: block;
  color: #52606d;
  font-size: 0.8125rem;
}

.top-list li {
  margin-bottom: 4px;
}

.weights {
  border-collapse: collapse;
  margin-bottom: 8px;
}

.weights td {
  padding: 1px 12px 1px 0;
}

.weights td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.factors li {
  color: #3e4c59;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

header h1 span {
  font-weight: 400;
  color: #52606d;
}

header p {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: #52606d;
}

#map {
  flex: 1;
}

.legend {
  background: #fff;
  padding: 8px 10px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.legend h4 {
  margin: 0 0 4px;
  font-size: 0.8125rem;
}

.legend .swatch {
  display: inline-block;
  width: 22px;
  height: 0;
  margin-right: 6px;
  vertical-align: middle;
  border-top: 3px solid;
}

.legend .swatch.dashed {
  border-top-style: dashed;
}

.legend .swatch.fill {
  height: 10px;
  border: 1px solid;
}

.popup h3 {
  margin: 0 0 4px;
  font-size: 0.9375rem;
}

.popup table {
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.popup th {
  padding-right: 8px;
  text-align: left;
  font-weight: 500;
  color: #52606d;
  vertical-align: top;
}

.popup table + table {
  margin-top: 8px;
}

.popup .flag {
  margin: 4px 0;
  font-weight: 600;
  color: #9a3412;
}

.tier {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tier-High {
  background: #ea580c;
  color: #fff;
}

.tier-Medium {
  background: #fbbf24;
  color: #1f2933;
}

.tier-Low {
  background: #d6d3d1;
  color: #1f2933;
}

.score th {
  white-space: nowrap;
}

.score .bar {
  width: 90px;
}

.score .bar span {
  display: block;
  height: 8px;
  border-radius: 2px;
  background: #ea580c;
}

.score .pts {
  padding-left: 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  header p {
    display: none;
  }

  .legend {
    display: none;
  }

  /* On phones the sidebar slides over the map instead of beside it. */
  #sidebar {
    position: absolute;
    inset: 0;
    z-index: 1100; /* above Leaflet's controls (1000) */
    width: auto;
    border-right: none;
  }
}
