:root {
  --bg: #f3f2f2;
  --ink: #181818;
  --muted: #5c5c5c;
  --line: #dddbda;
  --line-strong: #c9c7c5;
  --surface: #ffffff;
  --surface-alt: #f8f8f8;
  --surface-soft: #f4f6f9;
  --brand: #0176d3;
  --brand-dark: #014486;
  --brand-soft: #eaf5fe;
  --success: #2e844a;
  --mark: #fff03f;
  --shadow: 0 2px 2px rgba(0, 0, 0, 0.08);
  --sticky-top: 0px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Salesforce Sans", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 52px;
  padding: 0 18px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  z-index: 8;
}

.app-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.waffle {
  display: grid;
  width: 28px;
  height: 28px;
  grid-template-columns: repeat(3, 4px);
  grid-auto-rows: 4px;
  gap: 4px;
  place-content: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
}

.waffle span {
  display: block;
  border-radius: 50%;
  background: #ffffff;
}

.global-search {
  justify-self: center;
  width: min(560px, 100%);
}

.global-search input {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 0 12px;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  min-height: 34px;
  padding: 4px 7px 4px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.96);
  color: #032d60;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.powered-by img {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
}

.app-tabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-tabs a {
  flex: 0 0 auto;
  padding: 11px 16px 10px;
  border-bottom: 3px solid transparent;
  color: #032d60;
  font-weight: 650;
  text-decoration: none;
}

.app-tabs a.active {
  border-bottom-color: var(--brand);
  color: var(--brand-dark);
}

.app-tabs a:hover {
  background: #f3f9ff;
  color: var(--brand-dark);
}

main {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.scroll-anchor {
  height: 1px;
}

.record-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.record-title {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.object-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 4px;
  background: #2e844a;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow,
.stat-label,
.result-count,
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  color: #032d60;
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: 0;
}

.hero-meta {
  display: grid;
  gap: 5px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat-strip > div {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-strip strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #032d60;
  font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 2.2vw, 32px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-strip > div:last-child strong {
  font-size: clamp(16px, 1.6vw, 22px);
  line-height: 1.14;
  white-space: normal;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
}

label {
  color: #3e3e3c;
  font-size: 12px;
  font-weight: 700;
}

input[type="search"] {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 0 11px;
}

input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 3px var(--brand);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: #0176d3;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0 12px;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.result-count {
  align-self: center;
  justify-self: end;
  min-width: 220px;
  margin: 0;
  text-align: right;
}

.table-shell {
  margin-bottom: 72px;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  position: sticky;
  top: var(--sticky-top);
  padding: 0;
  background: #f3f3f3;
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 var(--line-strong);
  text-align: left;
  z-index: 3;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.summary-table > tbody > tr.parish-row {
  background: var(--surface);
}

.summary-table > tbody > tr.parish-row:hover {
  background: #f7fbff;
}

.summary-table > tbody > tr.detail-row > td {
  padding: 0;
  background: var(--surface-soft);
}

.sort-button {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

.sort-button:hover,
.sort-button.is-active {
  background: #eaf5fe;
  color: #032d60;
}

.sort-indicator {
  min-width: 12px;
  color: var(--brand);
  font-size: 10px;
}

.parish-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.parish-button:hover {
  background: transparent;
  border-color: transparent;
}

.toggle-mark {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #0176d3;
  border-radius: 50%;
  color: #0176d3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1;
}

.parish-name {
  display: block;
  color: #032d60;
  font-weight: 750;
}

.parish-sub {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.number {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

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

.city-primary {
  display: block;
  color: #032d60;
  font-weight: 750;
}

.city-mix {
  display: block;
  max-width: 520px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.32;
}

.detail-panel {
  display: none;
  padding: 12px 14px 16px 45px;
}

.detail-panel.is-open {
  display: block;
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: #3e3e3c;
  font-size: 12px;
  font-weight: 700;
}

.detail-heading a {
  color: #0176d3;
  font-weight: 700;
}

.precinct-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.precinct-table th {
  top: var(--sticky-top);
  background: #eef4ff;
}

.precinct-table td,
.precinct-table th .sort-button {
  padding-left: 12px;
  padding-right: 12px;
}

.share-bar {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) 58px;
  gap: 8px;
  align-items: center;
}

.share-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8dde6;
}

.share-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}

mark {
  border-radius: 2px;
  background: var(--mark);
  color: inherit;
  padding: 0 1px;
}

.empty-state {
  max-width: 540px;
  margin: 36px auto 80px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.source-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 2px 0 0;
  color: #032d60;
  font-size: 18px;
  line-height: 1.2;
}

.manifest-link,
.source-link {
  color: #0176d3;
  font-weight: 700;
  text-decoration: none;
}

.manifest-link:hover,
.source-link:hover {
  text-decoration: underline;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--line);
}

.source-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 8px 10px;
  background: var(--surface);
}

.source-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-link strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

@media (max-width: 900px) {
  :root {
    --sticky-top: 0px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  .powered-by {
    justify-self: start;
  }

  .app-tabs {
    padding: 0 12px;
  }

  main {
    width: min(100% - 20px, 1500px);
  }

  .record-header {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    justify-items: start;
  }

  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }

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

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .result-count {
    justify-self: start;
    min-width: 0;
    text-align: left;
  }

  .detail-panel {
    padding-left: 12px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  td {
    padding: 8px 10px;
  }

  .summary-table {
    min-width: 1030px;
  }

  .precinct-table {
    min-width: 780px;
  }
}
