:root {
  --bg: #f3f1ec;
  --ink: #121212;
  --muted: #5c5c5c;
  --gold: #d4a017;
  --gold-deep: #b8860b;
  --panel: #ffffff;
  --line: #e4e0d8;
  --ok: #1f7a3f;
  --err: #b42318;
  --warn-bg: #fff6d8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(212,160,23,.18), transparent 40%),
    linear-gradient(180deg, #faf8f4 0%, var(--bg) 40%, #ebe7df 100%);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; padding: 1.25rem 0 3rem; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: .6rem; }
.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: .55rem; }
.center { text-align: center; }
.muted { color: var(--muted); }

/* Top strip like school site */
.site-top {
  background: #000;
  color: #fff;
  border-bottom: 1px solid #222;
}
.site-top-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: .45rem !important;
  padding-bottom: .45rem !important;
  font-size: .82rem;
}
.site-tagline { margin: 0; color: var(--gold); }
.site-top-links { margin: 0; color: #eee; }

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-logo img {
  height: 52px;
  width: auto;
  max-width: min(280px, 55vw);
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

/* Public voting header */
.vote-header {
  background: #0d0d0d;
  color: #fff;
  padding: 1rem 0 1.15rem;
  border-bottom: 4px solid var(--gold);
}
.vote-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: .5rem !important;
  padding-bottom: .5rem !important;
}
.vote-heading { flex: 1; min-width: 200px; }
.vote-header h1 { margin: 0 0 .25rem; font-size: clamp(1.35rem, 2.6vw, 2rem); }
.vote-header .muted { color: #cfcfcf; margin: 0; }

/* Admin header — one clean bar */
.admin-nav {
  background: #111;
  color: #fff;
  border-bottom: 3px solid var(--gold);
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding-top: .55rem !important;
  padding-bottom: .55rem !important;
}
.admin-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .45rem;
  margin-left: auto;
}
.admin-menu a {
  color: #f2f2f2;
  font-weight: 600;
  font-size: .9rem;
  padding: .45rem .75rem;
  border-radius: 999px;
  white-space: nowrap;
}
.admin-menu a:hover,
.admin-menu a.active {
  color: #111;
  background: var(--gold);
}
.admin-menu a.menu-logout {
  border: 1px solid #555;
}
.admin-menu a.menu-logout:hover {
  border-color: var(--gold);
}

/* Hamburger — must beat global button styles */
button.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 10px 9px;
  border: 1px solid #555;
  border-radius: 8px;
  background: #1a1a1a;
  cursor: pointer;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  flex-shrink: 0;
  box-shadow: none;
}
button.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
  transition: .2s ease;
}
button.nav-toggle.is-open span:nth-child(1) {
  transform: translateY(10px) rotate(45deg);
}
button.nav-toggle.is-open span:nth-child(2) {
  opacity: 0;
}
button.nav-toggle.is-open span:nth-child(3) {
  transform: translateY(-10px) rotate(-45deg);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.alert {
  padding: .85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.alert.warn { background: var(--warn-bg); color: #6a5200; }
.alert.ok { background: #e8f7ee; color: var(--ok); }
.alert.err { background: #fdecec; color: var(--err); }
.alert.ready { background: #e8f7ee; color: var(--ok); }

label { display: grid; gap: .35rem; font-weight: 600; }
input, select, button, textarea {
  font: inherit;
  padding: .7rem .85rem;
  border-radius: 10px;
  border: 1px solid #cfc9bc;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid rgba(212,160,23,.35); border-color: var(--gold); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--gold);
  color: #111;
  border: none;
  font-weight: 700;
  cursor: pointer;
  padding: .75rem 1.1rem;
  border-radius: 999px;
}
.btn:hover { background: var(--gold-deep); color: #fff; }
.btn.secondary { background: #ece8e0; }
.btn.secondary:hover { background: #ddd6c8; color: #111; }
.btn.danger { background: #c62828; color: #fff; }
.btn.danger:hover { background: #9f1d1d; }

.positions h3 {
  margin: 1.4rem 0 .7rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--gold);
}
.candidate-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .8rem;
}
.candidate-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .7rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  font-weight: 500;
}
.candidate-card input { position: absolute; opacity: 0; pointer-events: none; }
.candidate-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: .5rem;
  background: #eee;
}
.candidate-card:hover { border-color: #c9a227; transform: translateY(-2px); }
.candidate-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,.25);
}

#submitBtn { width: 100%; margin-top: 1rem; font-size: 1.05rem; }
.spinner { text-align: center; padding: 1rem; font-weight: 700; color: var(--gold-deep); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-top: 1rem; }
.stat {
  background: #faf7f0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}
.stat strong { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .9rem; }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.badge.draft { background: #eee; }
.badge.live { background: #d9f5e3; color: var(--ok); }
.badge.closed { background: #fdecec; color: var(--err); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.auth-card h1 { margin-top: 0; }

.winners-grid, .results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .8rem;
}
.winner-card, .result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .8rem;
  text-align: center;
}
.winner-card img, .result-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  margin: .4rem 0;
}
.winner-card { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,160,23,.15); }
.result-section { margin-bottom: 1.4rem; }
.result-section h3 { margin-bottom: .7rem; border-bottom: 2px solid var(--gold); padding-bottom: .35rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.check input { width: auto; }

.danger-zone {
  border-color: #f0b4b0;
  background: linear-gradient(180deg, #fff 0%, #fff8f7 100%);
}
.danger-zone h2 { color: var(--err); margin-top: 0; }
.danger-zone code {
  background: #fdecec;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-weight: 700;
}

/* Voting wizard */
.vote-main {
  padding-bottom: 5rem;
}
.wizard-shell {
  display: grid;
  gap: .85rem;
}
.wizard-progress-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 248, 244, .96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem .9rem;
  box-shadow: var(--shadow);
}
.wizard-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-weight: 700;
  font-size: .92rem;
  margin-bottom: .45rem;
}
#progressCount {
  color: var(--gold-deep);
  white-space: nowrap;
}
.wizard-progress-bar {
  height: 10px;
  background: #e8e2d6;
  border-radius: 999px;
  overflow: hidden;
}
.wizard-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), #f0c84a);
  border-radius: 999px;
  transition: width .25s ease;
}
.wizard-step-title {
  margin: 0 0 .85rem;
  font-size: 1.25rem;
  border-bottom: 2px solid var(--gold);
  padding-bottom: .4rem;
}
.wizard-nav {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: .65rem;
  margin-top: 1rem;
  position: sticky;
  bottom: .75rem;
}
.wizard-nav .btn {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
}
#startBtn {
  width: 100%;
  margin-top: .85rem;
  min-height: 48px;
}

.candidate-section-compact {
  grid-template-columns: 1fr;
  gap: .55rem;
}
.candidate-card-compact {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-align: left;
  padding: .55rem .7rem;
  width: 100%;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.candidate-card-compact img {
  width: 56px;
  height: 56px;
  aspect-ratio: auto;
  border-radius: 10px;
  margin: 0;
  flex-shrink: 0;
  object-fit: cover;
}
.candidate-meta {
  display: grid;
  gap: .15rem;
  min-width: 0;
}
.candidate-meta strong {
  font-size: 1rem;
  line-height: 1.25;
}
.candidate-meta .muted {
  font-size: .86rem;
}

.review-list {
  display: grid;
  gap: .55rem;
}
.review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7f0;
}
.review-pos {
  display: grid;
  gap: .15rem;
  min-width: 0;
}
.review-pos span {
  color: var(--muted);
  font-size: .9rem;
}
.err-text { color: var(--err); font-weight: 700; }
.review-edit {
  flex-shrink: 0;
  padding: .45rem .75rem;
  border-radius: 10px;
}

@media (min-width: 700px) {
  .candidate-section-compact {
    grid-template-columns: repeat(2, 1fr);
  }
  .wizard-nav {
    grid-template-columns: 160px 1fr;
    max-width: 420px;
    margin-left: auto;
  }
}

@media (max-width: 900px) {
  .site-top-inner {
    justify-content: center;
    text-align: center;
  }
  .site-top-links { display: none; }

  .admin-bar {
    flex-wrap: nowrap;
  }
  .brand-logo img {
    height: 40px;
    max-width: calc(100vw - 100px);
  }

  button.nav-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .admin-menu {
    display: none;
    width: 100%;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: .4rem;
    margin: .35rem 0 0;
    padding: .55rem 0 0;
    border-top: 1px solid #333;
  }
  .admin-menu.is-open {
    display: flex;
  }
  .admin-menu a {
    border-radius: 10px;
    background: #1b1b1b;
    text-align: left;
    padding: .8rem 1rem;
  }
  .admin-menu a.active,
  .admin-menu a:hover {
    background: var(--gold);
    color: #111;
  }

  .vote-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .brand-logo img {
    height: 42px;
  }
  .candidate-section {
    grid-template-columns: repeat(2, 1fr);
  }
}
