:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f0f4f8;
  --ink: #172033;
  --muted: #647084;
  --line: #dbe2ec;
  --primary: #126a7c;
  --primary-dark: #0b4d5b;
  --accent: #d6513d;
  --success: #16845b;
  --warning: #ad6b00;
  --shadow: 0 20px 50px rgba(23, 32, 51, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Components set their own display; make the hidden attribute always win */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(18, 106, 124, 0.08), transparent 360px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

/* Page gutter used by the header and main content, so everything lines up edge to edge */
:root {
  --gutter: clamp(12px, 2.5vw, 40px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 247, 251, 0.92);
  border-bottom: 1px solid rgba(219, 226, 236, 0.8);
  backdrop-filter: blur(16px);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px var(--gutter);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-name {
  margin-left: 10px;
  font-weight: 800;
  font-size: 17px;
  white-space: nowrap;
}

.save-indicator {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--success);
}

.save-indicator::before {
  content: "●";
  margin-right: 6px;
}

.save-indicator[data-tone="busy"] {
  color: var(--warning);
}

.save-indicator[data-tone="error"] {
  color: var(--accent);
}

/* ── Admin section navigation (in the sticky header) ─────────── */

.admin-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter);
  border-top: 1px solid rgba(219, 226, 236, 0.8);
}

.admin-nav-items {
  display: flex;
  flex: 1;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-nav-items::-webkit-scrollbar {
  display: none;
}

.admin-nav-items button,
.admin-nav-signout {
  flex-shrink: 0;
  min-height: 46px;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
}

.admin-nav-items button:hover,
.admin-nav-signout:hover {
  color: var(--ink);
}

.admin-nav-items button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-nav-toggle {
  display: none;
}

.admin-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-status h1 {
  margin-bottom: 6px;
  font-size: clamp(20px, 2.4vw, 28px);
}

.admin-status .eyebrow {
  margin-bottom: 4px;
}

.admin-status .hint {
  margin: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  border-radius: 4px;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #e9eef5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.nav-tab {
  min-height: 34px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.nav-tab.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 6px 16px rgba(23, 32, 51, 0.08);
}

.main {
  width: 100%;
  padding: 20px var(--gutter) 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.status-panel,
.panel,
.candidate-card,
.metric-card,
.winner-card,
.empty-state,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: clamp(24px, 4vw, 42px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.status-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  background: #102733;
  color: #fff;
}

.status-panel p {
  color: rgba(255, 255, 255, 0.72);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* As many tiles per row as fit: two on a phone, up to six on a wide screen */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr));
  gap: 12px;
}

.status-item,
.metric-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
}

.status-item strong,
.metric-card strong {
  display: block;
  font-size: 26px;
}

.status-item span,
.metric-card span {
  display: block;
  color: inherit;
  opacity: 0.76;
  font-size: 13px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  color: #fff;
  font-weight: 750;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.btn.secondary:hover {
  background: var(--panel-soft);
}

.btn.danger {
  background: var(--accent);
  border-color: var(--accent);
}

.btn.full {
  width: 100%;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.field.full {
  grid-column: 1 / -1;
}

.field span,
.field label {
  color: #354157;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 106, 124, 0.14);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.position-group {
  margin-top: 20px;
}

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

.position-heading h2 {
  margin: 0;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  background: #dff2f5;
  border-radius: 999px;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.candidate-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 16px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.candidate-card.selectable {
  cursor: pointer;
}

.candidate-card.selectable:hover,
.candidate-card.selected {
  border-color: rgba(18, 106, 124, 0.62);
  box-shadow: 0 18px 44px rgba(18, 106, 124, 0.13);
  transform: translateY(-2px);
}

.candidate-card input[type="radio"] {
  position: absolute;
  inset: 14px 14px auto auto;
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.candidate-photo {
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  background: var(--panel-soft);
  border-radius: var(--radius);
}

.candidate-meta p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.candidate-position {
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.metric-card {
  color: var(--ink);
  background: #fff;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: #354157;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.link-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-cell input {
  min-width: 280px;
}

.mini-btn {
  min-height: 34px;
  padding: 0 10px;
  color: var(--primary-dark);
  font-weight: 800;
  background: #e6f4f6;
  border: 1px solid #c8e7ec;
  border-radius: 6px;
}

.mini-btn.danger {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.mini-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
}

.badge.open {
  color: var(--success);
  background: #ddf5ea;
}

.badge.used {
  color: #7b2d20;
  background: #fde4df;
}

.badge.expired {
  color: var(--warning);
  background: #fff0d6;
}

.badge.automatic {
  width: fit-content;
  color: #144f39;
  background: #ddf5ea;
}

.result-list,
.winner-list {
  display: grid;
  gap: 14px;
}

.result-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 70px;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 12px;
  overflow: hidden;
  background: #edf1f6;
  border-radius: 999px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.winner-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.winner-card img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius);
}

.login-wrap {
  display: grid;
  min-height: 62vh;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
}

.loading-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

/* ── Spinner ─────────────────────────────────────────────────── */

.spinner {
  position: relative;
  width: 56px;
  height: 56px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--primary);
  animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) { animation-delay: -0.45s; }
.spinner-ring:nth-child(2) { animation-delay: -0.3s;  border-top-color: var(--primary-light, #1a8fa5); inset: 8px; }
.spinner-ring:nth-child(3) { animation-delay: -0.15s; border-top-color: var(--primary-dark, #083d47); inset: 16px; }
.spinner-ring:nth-child(4) { inset: 24px; border-top-color: var(--primary); }

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.empty-state {
  padding: 38px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: var(--primary);
  border-radius: 50%;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 15px;
  color: #fff;
  background: #172033;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

/* Keyboard focus is always visible */
button:focus-visible,
a:focus-visible,
.chip:focus-visible {
  outline: 3px solid rgba(18, 106, 124, 0.45);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .hero,
  .candidate-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  /* Admin sections become a menu instead of a scrolling tab row */
  .admin-nav {
    padding: 0;
  }

  .admin-nav-toggle {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 var(--gutter);
    color: var(--ink);
    font-weight: 800;
    background: transparent;
    border: 0;
  }

  .admin-nav-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .admin-nav.open .admin-nav-items {
    display: flex;
  }

  .admin-nav.open .admin-nav-caret {
    transform: rotate(180deg);
  }

  .admin-nav-items button {
    min-height: 48px;
    padding: 0 var(--gutter);
    text-align: left;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid transparent;
  }

  .admin-nav-items button.active {
    border-bottom-color: var(--line);
    border-left-color: var(--primary);
    background: #eef7f9;
  }

  .admin-nav-signout {
    padding-right: var(--gutter);
  }
}

@media (max-width: 640px) {
  /* The site name only gives way when the admin controls need the room */
  .topbar:has(.nav-tabs:not([hidden])) .brand-name {
    display: none;
  }

  /* On a phone, only offer the way to the other page */
  .nav-tab.active {
    display: none;
  }

  .save-indicator {
    font-size: 12px;
  }

  .metric-card strong {
    font-size: 20px;
  }

  /* Cards run edge to edge on phones: no grey gutters at the sides */
  .main {
    padding: 0 0 72px;
  }

  .hero {
    gap: 10px;
    margin-bottom: 10px;
  }

  .main > *,
  .hero > *,
  .nomination-section > .panel,
  .login-card,
  .admin-sections > .admin-section > .panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    margin-bottom: 10px;
    box-shadow: none;
  }

  .panel {
    padding: 18px 16px;
  }

  .panel .panel {
    padding: 16px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .result-row {
    grid-template-columns: 1fr;
  }
}

/* ── History section ─────────────────────────────────────────── */

.history-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.history-card:last-child {
  border-bottom: 0;
}

.history-card-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-detail {
  padding: 24px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.history-detail h3 {
  margin-bottom: 14px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Winner highlight row ────────────────────────────────────── */

.winner-row strong {
  color: var(--success);
}

.winner-row .bar span {
  background: var(--success) !important;
}

/* ── Ended election notice ───────────────────────────────────── */

.ended-notice {
  padding: 12px 0 4px;
}

.ended-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

/* ── Custom modal ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(10, 20, 35, 0.55);
  backdrop-filter: blur(3px);
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 32px;
  background: var(--surface, #fff);
  border-radius: var(--radius, 10px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  animation: slide-up 0.18s ease;
}

@keyframes slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.modal-message {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Divider row (between manual add and bulk upload) ────────── */

.divider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider-row::before,
.divider-row::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Ballot success panel ─────────────────────────────────────── */

.success-panel {
  text-align: center;
  padding: 40px 28px;
}

.success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success, #16845b);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  margin: 0 auto 18px;
}

/* ── Vote review list in confirmation modal ───────────────────── */

.vote-review {
  margin: 12px 0 20px;
}

.vote-review-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vote-review-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg, #f6f7fb);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.vote-review-list li::before {
  content: "✓";
  color: var(--success, #16845b);
  font-weight: 900;
  flex-shrink: 0;
}

/* ── Candidate card actions ──────────────────────────────────── */

.card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
  justify-content: flex-end;
}

/* ── Wide modal (edit candidate) ─────────────────────────────── */

.modal-wide {
  width: min(640px, calc(100vw - 32px));
}

.modal-wide .field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-wide .field.full {
  grid-column: 1 / -1;
}

/* ── Dues & Eligibility section ──────────────────────────────── */

.subsection-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 14px;
}

.eligibility-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.success-pill {
  background: #d1fae5;
  color: #065f46;
}

.danger-pill {
  background: #fee2e2;
  color: #991b1b;
}

.eligible-row {
  background: #f0fdf6;
}

.ineligible-row {
  background: #fff8f8;
}

.override-note-input {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-top: 6px;
}

.field-grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── Email settings panel ────────────────────────────────────── */

.email-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 4px;
}

.email-setting-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0;
}

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: unset;
}

.offset-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.offset-form input[type="number"] {
  padding: 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.dues-period-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  margin-top: 14px;
}

.dues-period-actions .row-actions {
  flex-wrap: nowrap;
}

.editing-row td {
  background: #fff0d6;
}

@media (max-width: 720px) {
  .dues-period-form {
    grid-template-columns: 1fr;
  }
}

.publish-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.publish-bar .hint {
  flex: 1;
  min-width: 220px;
  margin: 0;
}

/* Voter page: three columns fit a phone, and a long list scrolls inside the panel */
.eligibility-section .eligibility-table {
  min-width: 0;
}

.voter-eligibility-wrap {
  max-height: 520px;
  overflow-y: auto;
}

.voter-eligibility-wrap th {
  position: sticky;
  top: 0;
}

.eligibility-section .eligibility-toolbar {
  margin-bottom: 6px;
}

.dues-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--warning);
  font-size: 14px;
  font-weight: 600;
  background: #fff0d6;
  border-radius: var(--radius);
}

.status-reason {
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

/* ── Eligibility table row actions ───────────────────────────── */
.row-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* ── Eligibility table — full width, paginated ───────────────── */

.eligibility-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.eligibility-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.eligibility-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.eligibility-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}

.eligibility-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
  border-bottom: 1.5px solid var(--line);
}

.eligibility-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.eligibility-table tr:last-child td {
  border-bottom: 0;
}

.row-num {
  color: var(--muted);
  font-size: 12px;
  width: 32px;
  text-align: center;
}

.td-name { font-weight: 600; min-width: 160px; }
.td-email { color: var(--muted); min-width: 180px; }
.td-center { text-align: center; }
.td-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Progress bar inside % Paid cell */
.percent-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 80px;
}

.percent-bar-track {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.percent-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.eligible-fill   { background: #16845b; }
.ineligible-fill { background: #dc2626; }

.percent-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: var(--muted);
}

/* ── Nominations ─────────────────────────────────────────────── */

.nomination-section {
  padding: 0;
}

.nomination-form .field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.nomination-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.nominations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.nomination-card {
  padding: 16px;
  background: var(--bg, #f6f7fb);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.nomination-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.nomination-card-header strong {
  font-size: 15px;
  margin-right: 8px;
}

.nomination-nominators {
  padding-top: 4px;
}

.nominator-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nominator-list li {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}

.nominator-list li::before {
  content: "→ ";
  color: var(--primary);
}

@media (max-width: 600px) {
  .nomination-form .field-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Multi-row nomination form ───────────────────────────────── */

.nominee-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.nominee-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nominee-row-fields {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nominee-row-fields input,
.nominee-row-fields select {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.nominee-row .mini-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.nomination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .nominee-row-fields {
    grid-template-columns: 1fr;
  }
}

.audit-details {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

/* ── Ballot ──────────────────────────────────────────────────── */

/* Hidden from view but still focusable and announced by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ballot-header {
  padding: clamp(18px, 3vw, 28px);
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.ballot-header h1 {
  margin-bottom: 8px;
  font-size: clamp(24px, 3.4vw, 38px);
}

.ballot-meta {
  margin-bottom: 6px;
  color: var(--ink);
}

.ballot {
  display: grid;
  gap: 14px;
}

.ballot-position {
  min-width: 0;
  margin: 0;
  padding: 18px clamp(14px, 2vw, 22px) 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

/* Floated legend sits inside the box instead of on its border */
.ballot-position legend {
  float: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
}

.ballot-position-name {
  font-size: 20px;
  font-weight: 800;
}

.ballot-position-state {
  flex-shrink: 0;
  padding: 4px 10px;
  color: var(--warning);
  font-size: 12px;
  font-weight: 800;
  background: #fff0d6;
  border-radius: 999px;
}

.ballot-position.done .ballot-position-state {
  color: var(--success);
  background: #ddf5ea;
}

.ballot-position.missing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214, 81, 61, 0.18);
}

.ballot-position.missing .ballot-position-state {
  color: #fff;
  background: var(--accent);
}

.ballot-position > .hint {
  clear: both;
}

.ballot-options {
  clear: both;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 10px;
}

.ballot-option {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  cursor: pointer;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  transition: border-color 140ms ease, background 140ms ease;
}

.ballot-option:hover {
  border-color: rgba(18, 106, 124, 0.45);
}

.ballot-option.selected {
  background: #eef7f9;
  border-color: var(--primary);
}

.ballot-option:has(input:focus-visible) {
  outline: 3px solid rgba(18, 106, 124, 0.4);
  outline-offset: 2px;
}

.ballot-option.locked {
  cursor: default;
}

.ballot-option.abstain {
  grid-template-columns: auto minmax(0, 1fr);
  border-style: dashed;
}

.ballot-option.abstain.selected {
  background: #f4f5f8;
  border-color: #6b7689;
  border-style: solid;
}

.ballot-check {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid #9aa6b8;
  border-radius: 50%;
}

.ballot-option.selected .ballot-check {
  background: var(--primary);
  border-color: var(--primary);
}

.ballot-option.abstain.selected .ballot-check {
  background: #6b7689;
  border-color: #6b7689;
}

.ballot-option.selected .ballot-check::after {
  content: "✓";
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.ballot-photo {
  width: 56px;
  height: 56px;
  object-fit: cover;
  background: var(--panel-soft);
  border-radius: 50%;
}

.ballot-photo.initials {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: var(--primary);
}

.ballot-option-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ballot-option-name {
  font-size: 16px;
  font-weight: 800;
}

.ballot-statement {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ballot-option.expanded .ballot-statement {
  display: block;
}

.ballot-more {
  justify-self: start;
  padding: 2px 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  background: none;
  border: 0;
}

/* Progress and submit stay in reach at the bottom of the screen */
.ballot-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 2vw, 22px);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 -10px 30px rgba(23, 32, 51, 0.1);
}

.ballot-progress {
  display: grid;
  flex: 1;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
}

.ballot-progress .bar span {
  transition: width 200ms ease;
}

.ballot-bar .btn {
  flex-shrink: 0;
}

.vote-review-list li {
  justify-content: space-between;
}

.vote-review-list li.abstained::before {
  content: "–";
  color: var(--muted);
}

.vote-review-list li .hint {
  margin-right: auto;
}

.modal-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  color: #991b1b;
  font-size: 14px;
  background: #fef2f2;
  border-radius: 6px;
}

@media (max-width: 640px) {
  .ballot-header,
  .ballot-position,
  .ballot-bar {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .ballot-header {
    margin-bottom: 10px;
  }

  .ballot {
    gap: 10px;
  }

  .ballot-bar {
    box-shadow: 0 -8px 20px rgba(23, 32, 51, 0.12);
  }

  .ballot-photo {
    width: 48px;
    height: 48px;
  }

  .ballot-option {
    min-height: 68px;
    gap: 10px;
    padding: 10px 12px;
  }
}

@media (max-width: 640px) {
  /* Keep messages clear of the ballot's bottom bar */
  .toast {
    left: 12px;
    right: 12px;
    bottom: 92px;
    max-width: none;
  }
}

/* ── Voter messages ──────────────────────────────────────────── */

.voter-message h2 {
  margin-bottom: 8px;
}

.voter-message.success {
  text-align: center;
}

.help-line {
  margin: 14px 0 0;
  font-size: 14px;
}

.help-line a {
  color: var(--primary);
  font-weight: 700;
}

/* ── Admin voter list ────────────────────────────────────────── */

.two-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.two-cards > .panel {
  margin-bottom: 0;
}

.voter-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.chip.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.voter-count {
  margin: 0 0 8px;
}

.voters-table {
  min-width: 0;
}

.voter-identity {
  display: grid;
  gap: 2px;
}

.voter-identity .badge {
  width: fit-content;
  margin-top: 2px;
}

.voters-table .mini-btn {
  white-space: nowrap;
}

.voters-table .row-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.voters-table .actions-cell {
  width: 1%;
}

@media (max-width: 760px) {
  /* Each voter becomes a card */
  .voters-table thead {
    display: none;
  }

  .voters-table,
  .voters-table tbody {
    display: block;
  }

  .voters-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }

  .voters-table tr[hidden] {
    display: none;
  }

  .voters-table td {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
  }

  .voters-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .voters-table .voter-cell,
  .voters-table .actions-cell {
    display: block;
    width: 100%;
  }

  .voters-table .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Announcements */
.announce-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}

.announce-quick {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.announce-search {
  width: 100%;
  margin-bottom: 8px;
}

.announce-list {
  max-height: 360px;
  overflow-y: auto;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.announce-person {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.announce-person:last-child {
  border-bottom: 0;
}

.announce-person:hover {
  background: var(--panel-soft);
}

.announce-person input,
.announce-check input {
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
}

.announce-person-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.announce-person-name small {
  display: block;
  color: var(--muted);
}

.announce-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.announce-list > .hint {
  margin: 12px;
}

.announce-message {
  min-height: 200px;
}

.announce-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 4px 0 14px;
  font-size: 14px;
}

.announce-check input {
  margin-top: 2px;
}

.announce-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.announce-file {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  overflow-wrap: anywhere;
  background: var(--panel-soft);
  border-radius: var(--radius);
}

.announce-file > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.announce-file img {
  flex: none;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
}

.announce-file-icon {
  flex: none;
  width: 44px;
  font-size: 26px;
  text-align: center;
}

.announce-send {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.announce-summary {
  margin: 0;
}

.announce-invalid {
  color: var(--accent);
}

@media (max-width: 820px) {
  .announce-grid {
    grid-template-columns: 1fr;
  }

  .announce-send .btn {
    width: 100%;
  }
}

/* Candidates, grouped by position */
.candidate-groups {
  display: grid;
  gap: 22px;
}

.candidate-group .position-heading {
  margin-bottom: 10px;
}

.notice-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.notice-panel p {
  margin: 0;
}

.inline-check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 14px;
}

.inline-check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
}

/* Election: positions editor */
.positions-panel {
  margin-top: 16px;
}

.position-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.position-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-soft);
  border-radius: var(--radius);
}

.position-number {
  flex: none;
  width: 24px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.position-row .position-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.position-row input.position-name {
  min-height: 38px;
  padding: 6px 10px;
}

.position-row .pill {
  flex: none;
}

.position-actions {
  display: flex;
  flex: none;
  gap: 4px;
}

.position-add {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.position-add .btn {
  flex: none;
}

.position-suggestions {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.extend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.extend-row .field {
  flex: 1;
  min-width: 220px;
  margin: 0;
}

@media (max-width: 600px) {
  .position-row {
    flex-wrap: wrap;
  }

  .position-row .position-name {
    flex-basis: calc(100% - 34px);
  }

  .position-actions {
    margin-left: auto;
  }
}

/* Nominations: per-nominator remove, and the member's submission results */
.nominator-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  overflow-wrap: anywhere;
}

.nomination-results {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.nomination-results .ok {
  color: var(--success);
}

.nomination-results .failed {
  color: var(--accent);
}
