:root {
  --zm-green: #198A00;
  --zm-red: #DE2010;
  --zm-orange: #EF7D00;
  --zm-black: #10100F;
  --zm-white: #ffffff;
  --bg-soft: #f4f7f3;
  --card-radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-hover: 0 14px 34px rgba(0,0,0,0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, -apple-system, Arial, sans-serif;
  background: var(--bg-soft);
  color: #212121;
  position: relative;
  overflow-x: hidden;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 20%, rgba(25,138,0,0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(222,32,16,0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(239,125,0,0.04) 0%, transparent 60%);
}

.flag-bar {
  height: 6px;
  width: 100%;
  background: linear-gradient(90deg, var(--zm-black) 0% 20%, var(--zm-red) 20% 40%, var(--zm-black) 40% 55%, var(--zm-orange) 55% 75%, var(--zm-green) 75% 100%);
  background-size: 200% 100%;
  animation: flagShift 8s linear infinite;
}
@keyframes flagShift {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ---------------- Header ---------------- */
.site-header { background: var(--zm-white); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50; }
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.header-title { display: flex; align-items: center; gap: 14px; }
.emoji-eagle { font-size: 42px; animation: float 3.5s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.header-title h1 { margin: 0; font-size: 1.35rem; color: var(--zm-black); }
.subtitle { margin: 2px 0 0; font-size: 0.82rem; color: #666; }

.voter-badge {
  display: flex; align-items: center; gap: 10px; background: #eef7ec; color: var(--zm-green);
  padding: 8px 14px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  animation: popIn 0.35s ease;
}
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- Layout ---------------- */
.container { max-width: 1080px; margin: 24px auto 60px; padding: 0 20px; display: flex; flex-direction: column; gap: 22px; }

.card {
  background: var(--zm-white); border-radius: var(--card-radius); padding: 26px;
  box-shadow: var(--shadow); transition: box-shadow 0.25s ease, transform 0.25s ease;
  animation: fadeUp 0.5s ease both;
}
.card:hover { box-shadow: var(--shadow-hover); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.card h2 { margin-top: 0; color: var(--zm-black); }
.muted { color: #6b6b6b; font-size: 0.92rem; }
.small { font-size: 0.78rem; }

.section-heading-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

/* ---------------- Auth ---------------- */
.input-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 8px; }
.input-row input {
  flex: 1; min-width: 220px; padding: 12px 14px; border: 2px solid #e2e2e2; border-radius: 10px;
  font-size: 1rem; transition: border-color 0.2s ease;
}
.input-row input:focus { outline: none; border-color: var(--zm-green); }

.btn-primary {
  background: linear-gradient(135deg, var(--zm-green), #146d00);
  color: white; border: none; padding: 12px 22px; border-radius: 10px; font-weight: 600;
  cursor: pointer; font-size: 1rem; transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(25,138,0,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(25,138,0,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-danger { background: var(--zm-red); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; font-size: 0.85rem; text-decoration: none; display: inline-block; cursor: pointer; }
.btn-danger:hover { filter: brightness(1.1); }

.link-btn { background: none; border: none; color: var(--zm-green); font-weight: 600; cursor: pointer; padding: 8px 4px; text-decoration: underline; }

.feedback { margin-top: 14px; padding: 12px 16px; border-radius: 10px; font-weight: 500; animation: popIn 0.3s ease; }
.feedback.success { background: #e8f7e6; color: var(--zm-green); border: 1px solid #b6e6ac; }
.feedback.error { background: #fdeceb; color: var(--zm-red); border: 1px solid #f5b8b0; }
.feedback.info { background: #fff4e6; color: var(--zm-orange); border: 1px solid #ffdca8; }
.hidden { display: none !important; }

/* ---------------- Candidates ---------------- */
.candidate-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 14px;
}
.candidate-card {
  border-radius: 14px; padding: 16px; text-align: center; background: #fafafa;
  border: 2px solid transparent; cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.candidate-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--party-color, var(--zm-green));
}
.candidate-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.candidate-card.selected { border-color: var(--party-color, var(--zm-green)); background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--party-color) 18%, transparent); }
.candidate-card.voted-for { animation: votedPulse 0.6s ease; }
@keyframes votedPulse {
  0% { transform: scale(1); } 40% { transform: scale(1.05); } 100% { transform: scale(1); }
}

.candidate-photos { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.candidate-photos img { width: 62px; height: 62px; object-fit: cover; border-radius: 10px; border: 2px solid #eee; background: #fff; }
.candidate-name { font-weight: 700; font-size: 0.98rem; margin: 4px 0 2px; }
.candidate-mate { font-size: 0.78rem; color: #777; margin-bottom: 6px; }
.party-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  color: #fff; background: var(--party-color, var(--zm-green)); margin-bottom: 4px;
}
.symbol-desc { font-size: 0.72rem; color: #888; margin-top: 4px; }

.vote-btn {
  margin-top: 10px; width: 100%; padding: 9px; border-radius: 8px; border: none; font-weight: 600;
  background: var(--party-color, var(--zm-green)); color: #fff; cursor: pointer; transition: filter 0.15s ease;
}
.vote-btn:hover { filter: brightness(1.08); }
.vote-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.pill {
  background: #f1f1f1; padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: #444;
}
.pill.pill-success { background: #e8f7e6; color: var(--zm-green); }

/* ---------------- Results ---------------- */
.chart-wrap { position: relative; height: 360px; margin: 10px 0 20px; }
.results-bars { display: flex; flex-direction: column; gap: 10px; }
.result-row { display: flex; align-items: center; gap: 10px; }
.result-label { width: 160px; font-size: 0.85rem; font-weight: 600; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-bar-track { flex: 1; background: #eee; border-radius: 999px; height: 30px; overflow: hidden; }
.result-bar-fill {
  height: 100%; border-radius: 999px; width: 0;
  transition: width 1s cubic-bezier(.22,1,.36,1);
  display: flex; align-items: center; justify-content: flex-end; padding-right: 10px;
}
.result-pct { font-size: 0.8rem; color: #fff; font-weight: 700; }
.result-count { width: 70px; text-align: right; font-size: 0.8rem; color: #666; }

/* ---------------- My votes ---------------- */
.my-votes-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.my-vote-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; background: #fafafa;
  border-left: 5px solid var(--party-color, var(--zm-green));
}
.my-vote-item img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.my-vote-date { font-weight: 700; width: 100px; font-size: 0.85rem; }
.my-vote-candidate { font-size: 0.88rem; }
.my-vote-party { margin-left: auto; font-size: 0.75rem; font-weight: 700; color: var(--party-color, var(--zm-green)); }

/* ---------------- Footer ---------------- */
.site-footer { text-align: center; color: #999; font-size: 0.78rem; margin-top: 10px; line-height: 1.5; }

/* ---------------- Toasts ---------------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 999; }
.toast {
  background: var(--zm-black); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 0.9rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25); animation: toastIn 0.35s ease, toastOut 0.35s ease 2.6s forwards;
  border-left: 5px solid var(--zm-green);
}
.toast.error { border-left-color: var(--zm-red); }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(40px); opacity: 0; } }

/* ---------------- Confetti ---------------- */
.confetti-piece {
  position: fixed; top: -10px; width: 8px; height: 14px; z-index: 1000; pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.3; }
}

/* ---------------- Admin ---------------- */
.admin-body { background: var(--bg-soft); font-family: 'Segoe UI', Arial, sans-serif; margin: 0; }
.admin-login-card {
  max-width: 380px; margin: 8vh auto; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); padding-bottom: 26px; animation: fadeUp 0.4s ease;
}
.admin-login-card h1 { padding: 0 26px; margin-top: 20px; }
.admin-login-card form, .admin-login-card p { padding: 0 26px; }
.admin-login-card label { display: block; margin: 12px 0 6px; font-size: 0.85rem; font-weight: 600; }
.admin-login-card input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 2px solid #e2e2e2; font-size: 0.95rem; }
.admin-login-card .btn-primary { margin-top: 18px; width: 100%; }
.back-link { display: block; margin-top: 14px; color: var(--zm-green); text-decoration: none; font-size: 0.85rem; }

.admin-header { background: #fff; box-shadow: var(--shadow); }
.admin-header-inner { max-width: 1200px; margin: 0 auto; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-header-inner h1 { font-size: 1.1rem; margin: 0; }
.admin-header-inner nav a { margin-left: 16px; color: var(--zm-green); text-decoration: none; font-weight: 600; font-size: 0.85rem; }

.admin-main { max-width: 1200px; margin: 24px auto 60px; padding: 0 20px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: #e8f7e6; color: var(--zm-green); }
.alert-error { background: #fdeceb; color: var(--zm-red); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { background: #fff; border-radius: 14px; padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 1.9rem; font-weight: 800; color: var(--zm-green); }

.admin-panel { background: #fff; border-radius: 14px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.form-grid label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 4px; color: #555; }
.form-grid input[type=text], .form-grid input[type=number] { width: 100%; padding: 9px 10px; border-radius: 8px; border: 2px solid #e2e2e2; }
.form-grid input[type=color] { width: 100%; height: 38px; border-radius: 8px; border: 2px solid #e2e2e2; }
.checkbox-row { display: flex; align-items: center; }

.candidate-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.candidate-admin-card { background: #fafafa; border-radius: 12px; padding: 16px; }
.candidate-admin-thumbs { display: flex; gap: 10px; margin-bottom: 10px; }
.candidate-admin-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; background: #fff; }
.card-actions { display: flex; gap: 10px; margin-top: 10px; }

@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .result-label { width: 110px; }
}
