:root {
  --navy: #111b35;
  --blue: #4f73dc;
  --blue-dark: #385bb7;
  --ink: #1d2540;
  --muted: #7b8299;
  --line: #e7eaf2;
  --paper: #ffffff;
  --bg: #fff8e9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Noto Sans Tamil", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(255, 255, 255, 0.95), transparent 30%),
    radial-gradient(ellipse at 12% 12%, rgba(255, 215, 100, 0.22), transparent 38%),
    radial-gradient(ellipse at 92% 14%, rgba(237, 188, 77, 0.14), transparent 35%),
    radial-gradient(ellipse at 72% 95%, rgba(219, 177, 106, 0.07), transparent 40%),
    linear-gradient(135deg, #fffdf7 0%, #fff1ca 48%, #fff8e7 100%);
  background-attachment: fixed;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 8% 18%, rgba(255, 255, 255, 0.95) 0 1px, transparent 2px),
    radial-gradient(circle at 21% 68%, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 37% 27%, rgba(255, 255, 255, 0.85) 0 1px, transparent 2px),
    radial-gradient(circle at 51% 82%, rgba(255, 255, 255, 0.75) 0 1px, transparent 2px),
    radial-gradient(circle at 66% 15%, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 79% 58%, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 94% 36%, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px);
  content: "";
  opacity: 0.75;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 60px;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}

.heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
}

.brand-logo {
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

h1 {
  min-width: 0;
  flex: 1;
  margin: 0;
  color: var(--navy);
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -1.5px;
  text-align: center;
}

.notice {
  display: flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
  margin: 0 auto 18px;
  padding: 10px 14px;
  border: 1px solid #dde5fb;
  border-radius: 10px;
  background: #edf2ff;
  color: #53617f;
  font-size: 12px;
}

.notice p {
  margin: 0;
}

.notice-icon {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.notice.voted {
  border-color: #caead8;
  background: #edf9f2;
  color: #397b55;
}

.notice.voted .notice-icon {
  background: #3c9964;
}

.admin-back {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card,
.admin-panel {
  border: 1px solid rgba(231, 234, 242, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(30, 43, 78, 0.06);
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.stat-card strong {
  color: var(--navy);
  font-size: 24px;
}

.stat-card .leader-name {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-note {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid #f0dfab;
  border-radius: 9px;
  background: rgba(255, 249, 232, 0.9);
  color: #76632e;
  font-size: 12px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 18px;
}

.admin-panel {
  min-width: 0;
  padding: 18px;
}

.admin-panel h2 {
  margin: 0;
  color: var(--navy);
  font-size: 18px;
}

.panel-description {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.admin-form label span {
  color: var(--muted);
  font-weight: 400;
}

.admin-form input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.admin-form input:focus {
  border-color: var(--blue);
  outline: 2px solid rgba(79, 115, 220, 0.15);
}

.admin-form .btn {
  width: 100%;
  margin-top: 2px;
}

.admin-message {
  min-height: 18px;
  margin: 0;
  color: #397b55;
  font-size: 12px;
}

.table-wrapper {
  overflow-x: auto;
}

.candidate-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.candidate-table th,
.candidate-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.candidate-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.candidate-table td {
  color: var(--ink);
}

.candidate-name {
  min-width: 135px;
  font-weight: 600;
  white-space: nowrap;
}

.candidate-name img {
  width: 30px;
  height: 30px;
  margin-right: 6px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
}

.candidate-table td:last-child {
  color: var(--blue-dark);
}

.remove-candidate {
  padding: 6px 9px;
  border: 1px solid #f0caca;
  border-radius: 7px;
  background: #fff5f5;
  color: #b54848;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.remove-candidate:disabled {
  border-color: var(--line);
  background: #f4f5f8;
  color: #a4a9b5;
  cursor: not-allowed;
}

.students-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.student-card {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(30, 43, 78, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.student-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(30, 43, 78, 0.11);
}

.student-card.selected {
  border: 2px solid var(--blue);
  box-shadow: 0 10px 28px rgba(79, 115, 220, 0.18);
}

.photo-wrap {
  display: grid;
  width: 62px;
  flex: 0 0 62px;
  place-items: center;
  padding: 11px 0 11px 8px;
}

.photo-wrap img {
  width: 46px;
  height: 46px;
  display: block;
  object-fit: cover;
  border: 3px solid #edf1f8;
  border-radius: 50%;
}

.card-body {
  display: grid;
  min-width: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 11px 8px;
  text-align: left;
}

.card-body h2 {
  overflow: hidden;
  margin: 0;
  color: var(--navy);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-body .project {
  overflow: hidden;
  min-height: 0;
  margin: 2px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-btn {
  grid-column: 2;
  grid-row: 1 / 3;
  width: auto;
  height: 32px;
  margin-left: 6px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease;
}

.vote-btn:hover {
  background: var(--blue-dark);
}

.vote-btn:disabled {
  background: #cbd1df;
  cursor: not-allowed;
}

.student-card.selected .vote-btn {
  background: #3c9964;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  visibility: hidden;
  place-items: center;
  padding: 20px;
  background: rgba(17, 27, 53, 0.48);
  opacity: 0;
  transition: opacity 180ms ease, visibility 180ms ease;
  z-index: 10;
}

.modal.open {
  visibility: visible;
  opacity: 1;
}

.modal-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 24px 60px rgba(17, 27, 53, 0.24);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 8px;
  color: var(--navy);
}

.modal-card p {
  margin: 0 0 22px;
  color: var(--muted);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.btn {
  min-width: 110px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

@media (max-width: 620px) {
  .page {
    width: min(100% - 24px, 1180px);
    padding-top: 12px;
  }

  .brand-logo {
    width: 100px;
    height: 100px;
    flex-basis: 100px;
  }

  .heading-row {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  h1 {
    width: 100%;
    text-align: center;
    font-size: clamp(20px, 5vw, 28px);
    letter-spacing: -0.8px;
  }

  .students-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 12px 14px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    padding: 14px;
  }

}

/* ---------- Server-backed states (loading, errors, login, logout) ---------- */

.notice.error {
  border-color: #f0caca;
  background: #fff5f5;
  color: #b54848;
}

.notice.error .notice-icon {
  background: #c95454;
}

.grid-message {
  grid-column: 1 / -1;
  margin: 24px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.grid-message .btn {
  margin-left: 8px;
}

.admin-message.error {
  color: #b54848;
}

button.admin-back {
  font-family: inherit;
  cursor: pointer;
}

.admin-logout {
  color: #b54848;
}

.login-page {
  max-width: 440px;
}

.login-panel {
  margin-top: 8px;
}

.login-back {
  display: inline-block;
  margin-top: 14px;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
