/* ============================================================
   Hawaii 2026 Elections
   style.css
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  --ocean-deep:  #12343f;
  --ocean:       #1f5c6d;
  --seafoam:     #dbe9e3;
  --sand:        #f2e6cf;
  --sand-deep:   #d9c5a0;
  --sun:         #d5902f;
  --coral:       #c75945;
  --paper:       #fffdf8;
  --paper-muted: #f6f1e6;
  --ink:         #18252d;
  --ink-soft:    #52636e;
  --line:        #d9d4c5;
  --accent:      #c75945;
  --accent-light:#f7ddd7;

  --green:       var(--ocean-deep);
  --green-mid:   var(--ocean);
  --green-light: #9dc1b5;
  --green-bg:    #e6f0eb;
  --red:         var(--coral);
  --red-light:   #f1b2a7;
  --red-bg:      #fae2dd;
  --yellow:      var(--sun);
  --yellow-bg:   #fbefcf;
  --gray:        #9e9b93;
  --gray-light:  var(--line);
  --bg:          var(--paper-muted);
  --white:       var(--paper);
  --text:        var(--ink);
  --text-muted:  var(--ink-soft);

  --radius:      8px;
  --radius-lg:   18px;
  --shadow-sm:   0 2px 8px rgba(24, 37, 45, .06);
  --shadow:      0 14px 34px rgba(24, 37, 45, .1);
  --shadow-lg:   0 24px 60px rgba(18, 52, 63, .18);
  --transition:  180ms ease;
  --max-w:       1140px;
  --font-sans:   "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-serif:  "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(213, 144, 47, .12), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 92, 109, .1), transparent 30%),
    linear-gradient(180deg, #f7f1e5 0%, #fffdf8 22%, #f4efe3 100%);
  color: var(--text);
  line-height: 1.6;
  font-size: 1rem;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition); }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── Utility ── */
.hidden { display: none !important; }

.app-loading, .app-error {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.app-error {
  color: var(--red);
}

.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
}

.section-intro {
  color: var(--text-muted);
  margin-top: .55rem;
  margin-bottom: 1.5rem;
  max-width: 65ch;
  font-size: 1.02rem;
  line-height: 1.7;
}

.section-kicker {
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ocean);
  margin-bottom: .5rem;
}

h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.08;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--paper);
  color: var(--ocean-deep);
  padding: .5rem 1rem;
  border-radius: var(--radius);
  z-index: 9999;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: .5rem;
}

/* ── Header ── */
.site-header {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(217, 197, 160, .2), transparent 16%),
    radial-gradient(circle at 88% 24%, rgba(219, 233, 227, .18), transparent 20%),
    linear-gradient(160deg, #102e38 0%, #1b4f5f 48%, #275e5f 100%);
  color: #fff;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: auto -12% 22% auto;
  width: 440px;
  height: 440px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 3rem auto auto -6rem;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3.7rem 2rem 1.65rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 1.5rem 2rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.site-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 4.5vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: .95;
  max-width: 8.5ch;
}

.header-copy {
  display: flex;
  flex-direction: column;
  gap: .95rem;
  max-width: 42rem;
}

.eyebrow,
.brief-kicker {
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: rgba(255, 245, 232, .76);
}

.hero-dek {
  max-width: 29rem;
  font-size: 1.08rem;
  line-height: 1.65;
  color: rgba(255, 248, 241, .84);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  margin-top: .35rem;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .8rem 1.2rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
}

.hero-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.hero-btn-primary {
  background: var(--sun);
  color: #2f2007;
  box-shadow: 0 10px 24px rgba(213, 144, 47, .28);
}

.hero-btn-primary:hover {
  background: #e2a84a;
}

.hero-btn-secondary {
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff8f0;
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(8px);
}

.hero-btn-secondary:hover {
  background: rgba(255, 255, 255, .14);
}

.header-brief {
  background: rgba(248, 241, 226, .12);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  padding: 1.15rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  justify-self: end;
  width: min(100%, 42rem);
  align-self: center;
}

.brief-copy {
  color: rgba(255, 248, 241, .8);
  line-height: 1.55;
  margin-top: .45rem;
  max-width: 24rem;
  font-size: 1rem;
}

.tagline {
  grid-column: 1 / -1;
  margin-top: .4rem;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .14);
  font-size: 1rem;
  color: rgba(255, 248, 241, .82);
  font-weight: 500;
}

.tagline a {
  color: #fff7ea;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.45);
}

.tagline a:hover {
  text-decoration-color: #fff;
}

.site-nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}

.site-nav a {
  color: rgba(255,255,255,.88);
  padding: .68rem .95rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(8px);
}

.site-nav a:hover {
  background: rgba(255,255,255,.14);
  color: #fff;
  text-decoration: none;
}

/* ── Stats Bar (inside header) ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .9rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .35rem;
  padding: .78rem .9rem;
  min-height: 92px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .08);
}

.stat-num {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: .9;
  letter-spacing: -.02em;
}

.stat-alert .stat-num {
  color: #ffcabf;
}

.stat-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(255, 255, 255, .72);
  font-weight: 600;
}

.stat-meta .stat-label {
  color: rgba(255, 255, 255, .72);
}

.stat-meta {
  grid-column: 1 / -1;
  min-height: auto;
}

/* ── Find My Races ── */
.find-section {
  position: relative;
  background:
    linear-gradient(180deg, rgba(242, 230, 207, .76), rgba(255, 253, 248, .88)),
    var(--paper);
  border-bottom: 1px solid var(--line);
}

.find-section h2 {
  color: var(--ocean-deep);
}

.address-search {
  display: flex;
  gap: .75rem;
  max-width: 760px;
}

.address-search input {
  flex: 1;
  padding: .95rem 1.125rem;
  font-size: 1rem;
  border: 1px solid #cbbda1;
  border-radius: 999px;
  background: rgba(255, 253, 248, .95);
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: inset 0 1px 2px rgba(24, 37, 45, .04);
}

.address-search input:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 4px rgba(31, 92, 109, .12);
}

.address-search button {
  padding: .95rem 1.7rem;
  font-size: .95rem;
  font-weight: 700;
  color: #2f2007;
  background: var(--sun);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(213, 144, 47, .18);
}

.address-search button:hover {
  background: #e4a84a;
  transform: translateY(-1px);
}

.address-search button:active {
  transform: translateY(0);
}

.my-races-results {
  background: rgba(255, 253, 248, .96);
  border: 1px solid #d4c4a5;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.my-races-results h3 {
  font-size: 1.1rem;
  margin-bottom: .75rem;
  color: var(--green);
}

/* ── Map Section ── */
.map-section {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.layer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
}

.layer-option {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .84rem;
  cursor: pointer;
  padding: .62rem .95rem;
  border: 1px solid #d6cfbf;
  border-radius: 100px;
  background: rgba(255, 253, 248, .92);
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  user-select: none;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.layer-option:has(input:checked) {
  background: var(--ocean-deep);
  border-color: var(--ocean-deep);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(18, 52, 63, .16);
}

.layer-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.map-container {
  height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #dce6e2;
  box-shadow: var(--shadow-lg);
}

/* ── Race List Section ── */
.race-list-section {
  background: linear-gradient(180deg, rgba(242, 230, 207, .4), rgba(255, 253, 248, .98));
  border-bottom: 1px solid var(--line);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.race-context {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .55rem .8rem;
  margin-bottom: .95rem;
  padding: .55rem .75rem;
  border: 1px solid rgba(31, 92, 109, .14);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(219, 233, 227, .24), rgba(242, 230, 207, .28));
}

.race-context-text {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  min-width: 0;
}

.race-context-kicker {
  display: inline-flex;
  align-items: center;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: rgba(31, 92, 109, .08);
  color: var(--ocean);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.race-context-copy {
  color: var(--ink);
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.35;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.filter-bar select {
  padding: .68rem .92rem;
  font-size: .95rem;
  border: 1px solid #d6cfbf;
  border-radius: 999px;
  background: rgba(255, 253, 248, .96);
  color: var(--text);
  cursor: pointer;
  min-width: 160px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 4px rgba(31, 92, 109, .12);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}

.race-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: .95rem;
}

.race-table thead {
  background: linear-gradient(135deg, var(--ocean-deep), #22576a);
  color: #fffaf1;
}

.race-table th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--transition);
}

.race-table th:hover {
  background: #163a28;
}

.sort-icon {
  display: inline-block;
  margin-left: .35rem;
  opacity: .7;
  font-style: normal;
}

.race-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.race-table tbody tr:last-child {
  border-bottom: none;
}

.race-table tbody tr:hover {
  background: #f5efe1;
}

.race-table tbody tr:focus-visible {
  outline: 3px solid rgba(213, 144, 47, .55);
  outline-offset: -3px;
  background: #f5efe1;
}

.race-table td {
  padding: .9rem 1.25rem;
  vertical-align: middle;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .28em .72em;
  font-size: .74rem;
  font-weight: 700;
  border-radius: 100px;
  line-height: 1.3;
  white-space: nowrap;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.badge-contested {
  background: var(--green-bg);
  color: var(--green);
}

.badge-uncontested {
  background: var(--red-bg);
  color: var(--red);
}

.badge-empty {
  background: var(--gray-light);
  color: var(--text-muted);
}

.badge-incumbent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-party {
  background: var(--gray-light);
  color: var(--text-muted);
}

/* ── Race Detail ── */
.race-detail {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1.125rem;
  margin-bottom: 1.75rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ocean);
  background: rgba(31, 92, 109, .05);
  border: 1px solid rgba(31, 92, 109, .22);
  border-radius: 100px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.back-btn:hover {
  background: var(--ocean);
  color: #fff;
}

.race-detail-header {
  margin-bottom: 1.75rem;
}

.race-detail-header h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: .5rem;
}

.race-detail-header .badge {
  margin-bottom: .75rem;
}

.detail-map-container {
  height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  overflow: hidden;
  background: #dce6e2;
  box-shadow: var(--shadow);
}

.race-detail-candidates {
  margin-bottom: 2.5rem;
}

/* ── Party Columns ── */
.party-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.party-column-header {
  font-size: 1.1rem;
  font-weight: 700;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
  text-align: center;
}

.party-column-header.party-democratic {
  background: #dbeafe;
  color: #1e40af;
}

.party-column-header.party-republican {
  background: #fee2e2;
  color: #991b1b;
}

.party-column-header.party-green {
  background: var(--green-bg);
  color: var(--green);
}

.party-column-header.party-libertarian {
  background: #fef9c3;
  color: #854d0e;
}

.party-column-header.party-nonpartisan,
.party-column-header.party-nonpartisan-special {
  background: var(--gray-light);
  color: var(--text);
}

.candidate-card {
  background: linear-gradient(180deg, rgba(255, 253, 248, .98), rgba(246, 241, 230, .92));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.candidate-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--gray);
}

.candidate-card h3 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: .625rem;
  color: var(--text);
  line-height: 1.1;
}

.candidate-card .badge {
  margin-right: .4rem;
  margin-bottom: .625rem;
}

.candidate-card p {
  margin-bottom: .5rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.candidate-card a {
  display: inline-block;
  margin-right: 1.25rem;
  margin-bottom: .25rem;
  font-size: .9rem;
}

.candidate-contact {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  align-items: baseline;
}

.candidate-phone {
  display: inline-block;
  font-size: .9rem;
  color: var(--text-muted);
}

.candidate-finance-summary {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  align-items: baseline;
}

.fin-stat {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}

.fin-warchest {
  color: var(--green-mid);
}

.fin-date {
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
}

.fin-source {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--gray-light);
  padding: .1rem .4rem;
  border-radius: 3px;
}

.my-race-item {
  padding: .625rem 0;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
}

.my-race-item:last-child {
  border-bottom: none;
}

.my-race-item a {
  font-weight: 600;
}

.my-race-item span {
  font-size: .9rem;
  color: var(--text-muted);
}

.my-race-item .badge {
  margin-left: .125rem;
}

.uncontested-banner {
  background: var(--yellow-bg);
  border: 1px solid rgba(213, 144, 47, .5);
  border-left: 5px solid var(--yellow);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
  margin-top: .75rem;
  margin-bottom: 1.5rem;
  color: #664d03;
  box-shadow: var(--shadow-sm);
}

.uncontested-banner p {
  font-weight: 600;
  margin-bottom: .25rem;
}

.uncontested-banner a {
  color: #664d03;
  text-decoration: underline;
  font-weight: 700;
}

.banner-guide {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid rgba(102, 77, 3, .2);
}

.banner-guide h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: #664d03;
}

.banner-guide-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  font-size: .9rem;
}

.banner-guide-dl dt {
  font-weight: 600;
  color: #664d03;
}

.banner-guide-dl dd {
  color: #664d03;
}

.banner-guide-note {
  font-size: .85rem;
  font-style: italic;
  margin-top: .4rem;
  margin-bottom: .25rem;
}

/* ── Finance ── */
.race-detail-finance {
  margin-bottom: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.race-detail-finance h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.finance-loading {
  display: flex;
  align-items: center;
  gap: .625rem;
  color: var(--text-muted);
  font-size: .95rem;
  padding: 1rem 0;
}

.loading-spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 2.5px solid var(--gray-light);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.finance-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.finance-bar .bar-label {
  width: 180px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.finance-bar .bar-fill-wrap {
  flex: 1;
  height: 22px;
  background: #ebe3d2;
  border-radius: 100px;
  overflow: hidden;
}

.finance-bar .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ocean), #8eb7ae);
  border-radius: 100px;
  transition: width .5s ease;
  min-width: 2px;
}

.finance-bar .bar-amount {
  width: 90px;
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

.contrib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-top: 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.contrib-table th {
  text-align: left;
  padding: .625rem 1rem;
  background: #f3eddf;
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.contrib-table td {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--line);
}

.contrib-table tbody tr:last-child td {
  border-bottom: none;
}

.contrib-table tbody tr:hover {
  background: var(--bg);
}

/* ── How to Run Guide ── */
.guide-section {
  background: linear-gradient(180deg, rgba(219, 233, 227, .35), rgba(255, 253, 248, 1));
  border-bottom: 1px solid var(--line);
}

.guide-section h2 {
  color: var(--ocean-deep);
}

.guide-links {
  margin-bottom: 2.5rem;
  background: linear-gradient(135deg, rgba(219, 233, 227, .7), rgba(242, 230, 207, .76));
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  border: 1px solid rgba(31, 92, 109, .12);
  box-shadow: var(--shadow-sm);
}

.guide-links h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--green);
}

.resource-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .625rem;
}

.resource-list li {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
}

.resource-list li a {
  font-weight: 600;
}

.guide-offices details {
  background: rgba(255, 253, 248, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: .625rem;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.guide-offices details[open] {
  box-shadow: var(--shadow);
  border-color: var(--gray);
}

.guide-offices summary {
  padding: 1.125rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background var(--transition);
}

.guide-offices summary::-webkit-details-marker {
  display: none;
}

.guide-offices summary::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-muted);
  display: inline-block;
  transition: transform var(--transition);
  width: 1.5rem;
  text-align: center;
}

.guide-offices details[open] summary::after {
  content: "\2212";
}

.guide-offices summary:hover {
  background: #f4efe2;
}

.office-details {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--line);
}

.office-details dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .5rem 1.25rem;
}

.office-details dt {
  font-weight: 700;
  color: var(--text);
  font-size: .875rem;
}

.office-details dd {
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.5;
}

/* ── Footer ── */
.site-footer {
  background: linear-gradient(180deg, #133540, #102a33);
  color: rgba(255,255,255,.8);
  text-align: center;
  padding: 2rem 2rem;
  font-size: .875rem;
}

.site-footer a {
  color: var(--green-light);
  font-weight: 600;
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.footer-credits {
  opacity: .7;
  font-size: .8rem;
}

.finance-source-note {
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.25rem;
  padding: .5rem .75rem;
  background: #f4efe1;
  border-radius: var(--radius);
  border-left: 3px solid var(--sand-deep);
}

/* ── Finance Detail Tables ── */
.finance-candidate-detail {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-light);
}

.finance-candidate-detail h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .375rem;
}

.finance-summary-line {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.finance-detail-table {
  margin-bottom: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.finance-detail-table summary {
  padding: .75rem 1.25rem;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background var(--transition);
  background: #f3eddf;
}

.finance-detail-table summary::-webkit-details-marker {
  display: none;
}

.finance-detail-table summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--text-muted);
}

.finance-detail-table[open] summary::after {
  content: "\2212";
}

.finance-detail-table summary:hover {
  background: #ebe3d2;
}

.finance-detail-content {
  max-height: 400px;
  overflow-y: auto;
}

.finance-detail-loading {
  padding: .75rem 1.25rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.finance-full-table {
  margin-top: 0;
  border: none;
  border-radius: 0;
}

.finance-full-table td {
  font-size: .8rem;
  padding: .4rem .75rem;
  white-space: nowrap;
}

.finance-full-table td:last-child {
  white-space: normal;
  min-width: 120px;
}

.finance-csc-link {
  display: block;
  padding: .625rem 1.25rem;
  font-size: .85rem;
  font-weight: 600;
  background: #f4efe1;
  border-top: 1px solid var(--line);
}

/* ── Election History ── */

.race-detail-history {
  margin-top: 2rem;
  overflow-x: auto;
}

.race-detail-history h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-bottom: 1.25rem;
}

.history-table th {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 2px solid var(--ocean-deep);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.history-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.history-year {
  font-weight: 700;
  color: var(--ocean-deep);
}

.history-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-votes {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-pct {
  font-weight: 600;
  color: var(--ocean);
}

.history-turnout {
  font-weight: 600;
  color: var(--ink-soft);
}

.history-redistricting-note {
  font-size: .82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: .75rem;
  padding: .5rem .75rem;
  background: var(--paper-muted);
  border-left: 3px solid var(--sun);
  border-radius: 0 4px 4px 0;
}

.history-predecessor {
  font-style: italic;
  opacity: .75;
}

.party-tag {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: 3px;
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.party-tag-sm {
  padding: .1rem .35rem;
  font-size: .68rem;
}

.history-primary-details {
  margin-top: .75rem;
}

.history-primary-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ocean);
  padding: .5rem 0;
}

.history-primary-details summary:hover {
  color: var(--ocean-deep);
}

.history-primary-year {
  margin: 1rem 0;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}

.history-primary-year:last-child {
  border-bottom: none;
}

.history-primary-year h4 {
  font-size: .95rem;
  margin-bottom: .5rem;
  color: var(--ink);
}

.history-primary-party {
  margin-bottom: .75rem;
}

.history-primary-party > .party-tag {
  margin-bottom: .35rem;
}

.history-primary-row {
  display: grid;
  grid-template-columns: 180px 1fr 70px;
  align-items: center;
  gap: .5rem;
  padding: .2rem 0;
  font-size: .82rem;
}

.history-primary-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-primary-bar-wrap {
  height: 14px;
  background: var(--paper-muted);
  border-radius: 3px;
  overflow: hidden;
}

.history-primary-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width .3s ease;
}

.history-primary-votes {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

@media (max-width: 768px) {
  .history-table {
    font-size: .75rem;
  }
  .history-table th,
  .history-table td {
    padding: .35rem .4rem;
  }
  .history-name {
    max-width: 100px;
  }
  .history-primary-row {
    grid-template-columns: 140px 1fr 60px;
    font-size: .75rem;
  }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.site-nav a:focus-visible,
.hero-btn:focus-visible,
.back-btn:focus-visible {
  outline: 3px solid rgba(213, 144, 47, .65);
  outline-offset: 3px;
}

.layer-option:has(input:focus-visible) {
  box-shadow: 0 0 0 4px rgba(213, 144, 47, .22);
  border-color: var(--sun);
}

/* ── Leaflet popup override ── */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-popup-content {
  font-family: inherit !important;
  font-size: .9rem !important;
  line-height: 1.5 !important;
  margin: 10px 14px !important;
}

.map-popup strong {
  font-size: .95rem;
}

.map-popup a {
  color: var(--accent);
  font-weight: 600;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .header-inner {
    grid-template-columns: 1fr;
    padding: 2.8rem 1.25rem 1.4rem;
  }

  .site-header h1 {
    font-size: 2.35rem;
    max-width: none;
  }

  .hero-dek {
    font-size: 1rem;
    max-width: none;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-btn {
    width: 100%;
  }

  .tagline {
    font-size: .95rem;
    padding-top: .9rem;
  }

  .section-inner {
    padding: 2rem 1.25rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  .site-nav {
    padding: 0 1.25rem 1.25rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-nav a {
    text-align: center;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
    padding: .8rem .75rem;
    font-size: .72rem;
  }

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

  .stat-item {
    min-height: auto;
  }

  .stat-num {
    font-size: 2.1rem;
  }

  .stat-meta {
    grid-column: auto;
  }

  .address-search {
    flex-direction: column;
    max-width: none;
  }

  .address-search button {
    width: 100%;
  }

  .layer-controls {
    gap: .375rem;
  }

  .layer-option {
    font-size: .75rem;
    padding: .5rem .72rem;
  }

  .map-container {
    height: min(320px, 44vh);
    border-radius: var(--radius);
  }

  .filter-bar {
    flex-direction: column;
    gap: .75rem;
  }

  .race-context {
    flex-direction: column;
    align-items: stretch;
  }

  .race-context-text {
    align-items: flex-start;
  }

  .filter-bar select {
    width: 100%;
    min-width: unset;
  }

  .race-table {
    font-size: .9rem;
    background: transparent;
  }

  .table-wrapper {
    overflow: visible;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .race-table thead {
    display: none;
  }

  .race-table,
  .race-table tbody,
  .race-table tr,
  .race-table td {
    display: block;
    width: 100%;
  }

  .race-table tbody {
    display: grid;
    gap: .9rem;
  }

  .race-table tbody tr {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 248, .96);
    box-shadow: var(--shadow-sm);
  }

  .race-table td {
    padding: 0;
    margin-bottom: .55rem;
  }

  .race-table td:last-child {
    margin-bottom: 0;
  }

  .race-table td::before {
    display: block;
    margin-bottom: .15rem;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .race-table td:nth-child(1) {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.15;
    color: var(--ink);
  }

  .race-table td:nth-child(1)::before { content: "Race"; }
  .race-table td:nth-child(2)::before { content: "Candidates"; }
  .race-table td:nth-child(3)::before { content: "Status"; }
  .race-table td:nth-child(4)::before { content: "Level"; }

  .candidate-card {
    padding: 1.2rem;
  }

  .candidate-card h3 {
    font-size: 1.25rem;
  }

  .finance-bar {
    flex-wrap: wrap;
  }

  .finance-bar .bar-label {
    width: 100%;
  }

  .office-details dl {
    grid-template-columns: 1fr;
  }

  .detail-map-container {
    height: 220px;
  }

  .resource-list {
    grid-template-columns: 1fr;
  }

  .guide-links {
    padding: 1.25rem;
  }
}
