:root {
  --chrome-bg: #f7f7f7;
  --bar-height: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font: 14px system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body {
  display: grid;
  grid-template-rows: var(--bar-height) auto var(--bar-height);
  grid-template-columns: 100%;
  background: #eee;
}

header {
  grid-row: 1;
  background: #222;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

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

nav {
  position: absolute;
  top: var(--bar-height);
  left: 0;
  right: 0;
  z-index: 10020;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid #ccc;
  padding: 0.35rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

nav label {
  font-size: 0.8rem;
  color: #444;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

nav select {
  font-size: 0.8rem;
  padding: 0.15rem 0.35rem;
}

main {
  grid-row: 2;
  display: flex;
  min-height: 0; /* important for flex + 100% height children */
}

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

/* Map now lives inside <article> */
#map {
  position: absolute;
  inset: 0;       /* top/right/bottom/left = 0 */
  z-index: 1;
}

footer {
  grid-row: 3;
  background: var(--chrome-bg);
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  font-size: 0.8rem;
  color: #555;
}

/* Slide-out sidebar (unchanged logic, just lives in <article>) */
.sb {
  position: absolute;
  top: 80px;
  right: 10px;
  width: 380px;
  max-width: 42vw;
  max-height: 72vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
  z-index: 10010;
  transform: translateX(110%);
  transition: transform .18s ease-out;
  font: 13px system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.sb.is-open { transform: translateX(0); }

.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: #fff;
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 6px;
  font: 12px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  z-index: 10005;
}
.legend .sw {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid #999;
}

.precinct-label {
  font-weight: 700;
  font-size: 12px;
  color: #111;
  text-shadow: 0 1px 2px rgba(255,255,255,0.9);
  pointer-events: none;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  opacity: 0.85;
}