:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #646a73;
  --line: #e3e3df;
  --accent: #1d5c8f;
  --nodata: #e4e4e0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; }

.panel {
  width: 360px;
  flex: none;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#map { flex: 1; height: 100%; background: #dfe6ea; }

h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
h3 { font-size: 17px; margin: 0 0 2px; }
.sub, .muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

.controls { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
select {
  font: inherit; font-size: 14px; color: var(--text); font-weight: 400;
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

.seg { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 13px; padding: 7px 0; border: 0; background: #fff; color: var(--text); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }

.card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.hint { font-size: 13px; color: var(--muted); padding: 2px 2px 0; }
.detail { border-left: 3px solid var(--accent); scroll-margin: 12px; }
.detail.flash { animation: flash 0.9s ease-out; }
@keyframes flash { from { background: #e6f0fa; } to { background: var(--panel); } }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.close {
  flex: none; width: 28px; height: 28px; margin: -4px -6px 0 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.close:hover, .close:focus-visible { background: #efefec; color: var(--text); }
.notice { background: #fff8e6; border: 1px solid #f0dca8; border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.notice code { font-size: 12px; background: #fff; padding: 1px 4px; border-radius: 3px; }

.layer-desc { margin: -4px 0 0; font-size: 12px; color: var(--muted); }

/* Ballot progress: counted, received but not yet counted, not returned. */
.progress-text { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.progress-text .muted { font-size: 13px; }
.progress { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #e6e6e1; }
.seg-counted { background: #15508e; }
.seg-received { background: #8fb6dc; }
.seg-rest { background: #e6e6e1; }
.progress-key { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.progress-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.challenged { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.challenged b { color: var(--text); font-weight: 600; }

.bars { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bars li { font-size: 13px; }
.bars .row { display: flex; justify-content: space-between; gap: 8px; }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.bars .track { height: 6px; background: #efefec; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 3px; }
.compare-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.compare-key i { display: inline-block; width: 16px; height: 6px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; background: #55595e; }
.compare-key i.k-wide { opacity: 0.4; }
.bars.compare { gap: 10px; }
.pair { display: grid; grid-template-columns: 52px 1fr 46px; align-items: center; gap: 6px; margin-top: 3px; }
.pair .tag { font-size: 11px; color: var(--muted); }
.pair .track { margin-top: 0; }
.pair .num { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.pair.wide .fill { opacity: 0.4; }
.compare-totals { margin-top: 10px; font-size: 12px; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }

.status { margin-top: auto; font-size: 12px; color: var(--muted); line-height: 1.5; }
.status a { color: var(--accent); }

.legend { background: #fff; padding: 8px 10px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.2); font-size: 12px; line-height: 1.5; max-width: 220px; }
.legend b { display: block; margin-bottom: 4px; }
.legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }

/* Stacked layout for phones and portrait tablets: beside a 360px panel, the map
   would be narrow and tall, with the county a thin band in the middle. */
@media (max-width: 900px) {
  body { flex-direction: column-reverse; }
  /* Lewis County is about three times wider than tall, so a tall map on a
     phone is mostly empty space around it. */
  #map { height: clamp(260px, 72vw, 50vh); flex: none; }
  .panel { width: 100%; height: auto; flex: 1; border-right: 0; border-top: 1px solid var(--line); padding: 14px 16px; }
  /* A compact legend strip so it doesn't cover the short map. */
  .legend { max-width: calc(100vw - 24px); padding: 5px 8px; font-size: 11px; line-height: 1.4; }
  .legend b { margin-bottom: 1px; }
  .legend div { display: inline-block; margin-right: 8px; white-space: nowrap; }
  .legend i { width: 10px; height: 8px; margin-right: 4px; }
  .leaflet-control-attribution { font-size: 9px; }
}
