:root {
  --primary: #c92a2a;
  --primary-dark: #a51d1d;
  --gold: #f59f00;
  --bg-start: #fff5e6;
  --bg-end: #ffe0b3;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --muted: #868e96;
  --border: #ffd6a8;
  --shadow: 0 8px 30px rgba(201, 42, 42, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

.site-header {
  text-align: center;
  padding: 36px 16px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.18), transparent 50%);
  pointer-events: none;
}
.site-header h1 {
  font-size: 30px;
  margin-bottom: 6px;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.site-header .subtitle { font-size: 15px; opacity: 0.95; }

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin: 20px 0 28px;
}
.stats-bar .stat {
  background: #fff;
  border: 1px solid var(--border);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.stats-bar .stat strong { color: var(--primary); font-size: 18px; margin-right: 4px; }

.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.candidate-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.candidate-card:hover { transform: translateY(-4px); box-shadow: 0 12px 36px rgba(201, 42, 42, 0.2); }

.photo-wrap {
  position: relative;
  width: 100%;
  padding-top: 118%;
  background: linear-gradient(135deg, #ffe9d6, #ffd6a8);
  overflow: hidden;
}
.photo-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: rgba(201, 42, 42, 0.35);
}
.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--gold);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 2;
}
.rank-badge.rank-1 { background: linear-gradient(135deg, #ffd700, #ffaa00); }
.rank-badge.rank-2 { background: linear-gradient(135deg, #c0c0c0, #999); }
.rank-badge.rank-3 { background: linear-gradient(135deg, #cd7f32, #a0522d); }

.card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.candidate-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}
.candidate-intro {
  font-size: 13.5px;
  color: var(--muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.vote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.vote-count { font-size: 13px; color: var(--muted); }
.vote-count strong { color: var(--primary); font-size: 20px; margin-right: 2px; }

.vote-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(201, 42, 42, 0.3);
}
.vote-btn:hover:not(:disabled) { transform: scale(1.05); }
.vote-btn:active:not(:disabled) { transform: scale(0.97); }
.vote-btn:disabled { background: #adb5bd; box-shadow: none; cursor: not-allowed; }
.vote-btn.voted { background: #868e96; }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #fff;
  color: var(--text);
  padding: 14px 26px;
  border-radius: 30px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  z-index: 9999;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
  border-left: 4px solid var(--primary);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-left-color: #e03131; }
.toast.success { border-left-color: #2f9e44; }

.footer {
  text-align: center;
  margin-top: 40px;
  color: var(--muted);
  font-size: 13px;
}
.footer a { color: var(--primary); text-decoration: none; }

.loading { text-align: center; padding: 40px; color: var(--muted); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* 后台样式 */
.admin-header {
  background: #2c2c2c;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0 0 12px 12px;
  margin-bottom: 24px;
}
.admin-header h1 { font-size: 20px; }
.admin-header .actions { display: flex; gap: 10px; }
.admin-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.admin-btn.secondary { background: #495057; }
.admin-btn.danger { background: #e03131; }

.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: #fff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.login-box h2 { text-align: center; margin-bottom: 20px; color: var(--primary); }
.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 14px;
}
.login-box button { width: 100%; }

.admin-table {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border-collapse: collapse;
}
.admin-table th, .admin-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #f1f1f1;
  font-size: 14px;
  vertical-align: middle;
}
.admin-table th { background: #f8f9fa; font-weight: 600; color: #495057; }
.admin-table td .thumb {
  width: 50px; height: 60px; object-fit: cover; border-radius: 6px;
  background: #f1f1f1;
}
.admin-table tr:last-child td { border-bottom: none; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 18px; color: var(--primary); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: #495057; font-weight: 600; }
.form-group input[type=text], .form-group textarea, .form-group input[type=number] {
  width: 100%; padding: 10px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 14px;
  font-family: inherit;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group input[type=file] { width: 100%; }
.photo-preview {
  width: 80px; height: 96px; object-fit: cover; border-radius: 8px;
  border: 1px solid #dee2e6; margin-top: 6px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@media (max-width: 600px) {
  .site-header h1 { font-size: 24px; }
  .candidates-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-body { padding: 12px; }
  .candidate-name { font-size: 16px; }
  .candidate-intro { font-size: 12px; -webkit-line-clamp: 3; }
  .vote-btn { padding: 8px 14px; font-size: 13px; }
  .vote-count strong { font-size: 17px; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
}
