:root {
  --primary: #185B20;
  --primary-light: #08AC04;
  --secondary: #BBCE26;
  --contrast: #5F3F8C;
  --cta: #CD8A44;
  --bg: #F5F3EE;
  --text: #1A1A1A;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

img { max-width: 100%; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--primary);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
}
.site-header .brand img { height: 40px; width: auto; border-radius: 6px; background: var(--white); }
.site-header .brand span { font-weight: 700; font-size: 1.05rem; }
.site-header nav a {
  color: var(--white);
  margin-left: 16px;
  font-weight: 600;
  font-size: 0.95rem;
}
.site-header nav a:hover { text-decoration: underline; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: var(--white);
  padding: 40px 0;
}
.hero h1 { margin: 0 0 12px; font-size: 1.9rem; text-align: center; }
.hero p { margin: 0; font-size: 1.05rem; opacity: 0.95; text-align: justify; }

/* Logo strip */
.logo-strip {
  background: var(--white);
  padding: 20px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.logo-strip .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  flex-wrap: wrap;
}
.logo-strip img { height: 56px; width: auto; object-fit: contain; border-radius: 6px; }

/* Sections */
.section { padding: 36px 0; }
.section h2 {
  color: var(--primary);
  font-size: 1.4rem;
  margin-bottom: 18px;
}

/* Contestant grid */
.contestant-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 600px) {
  .contestant-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .contestant-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1140px) {
  .contestant-grid { grid-template-columns: repeat(4, 1fr); }
}

.contestant-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
}
.contestant-card:hover { transform: translateY(-3px); }
.contestant-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.contestant-card .card-body { padding: 12px 14px 16px; flex: 1; display: flex; flex-direction: column; }
.contestant-card .number-badge {
  display: inline-block;
  background: var(--contrast);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
  width: fit-content;
}
.contestant-card h3 { margin: 0 0 4px; font-size: 1.05rem; color: var(--text); }
.contestant-card .vote-count { font-size: 0.85rem; color: var(--primary); font-weight: 600; margin-bottom: 10px; }
.contestant-card a.link { text-decoration: none; }

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn-cta { background: var(--cta); color: var(--white); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 1.05rem; min-height: 52px; }
.btn, .qty-presets button { min-height: 44px; }

/* Contestant page */
.contestant-page {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
@media (min-width: 860px) {
  .contestant-page { grid-template-columns: 380px 1fr; }
}
.contestant-photo img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  width: 100%;
}
.contestant-info h1 { color: var(--primary); margin: 0 0 6px; font-size: 1.7rem; }
.contestant-info .vote-count-big { font-size: 1.1rem; color: var(--contrast); font-weight: 700; margin-bottom: 16px; }
.contestant-info .bio { margin-bottom: 24px; }

/* Vote widget */
.vote-widget {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.vote-widget h3 { margin: 0 0 14px; color: var(--primary); font-size: 1.1rem; }
.qty-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.qty-presets button {
  border: 2px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  min-width: 52px;
  min-height: 48px;
  flex: 1 1 auto;
}
.qty-presets button.active,
.qty-presets button:hover {
  background: var(--primary);
  color: var(--white);
}
.qty-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.qty-custom label { font-size: 0.9rem; font-weight: 600; flex: 1 1 100%; }
.qty-custom input {
  width: 100%;
  flex: 1 1 auto;
  padding: 12px 14px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
  min-height: 48px;
}
@media (min-width: 480px) {
  .qty-custom label { flex: 0 0 auto; }
  .qty-custom input { width: auto; }
}
.amount-display {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
}
.amount-display span { color: var(--cta); }

/* Share box */
.share-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.share-box h3 { margin: 0 0 12px; color: var(--primary); font-size: 1.05rem; }
.share-box .qr-code { margin: 0 auto 12px; }
.share-box .share-link {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.share-box .share-link input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Chart card */
.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Leaderboard — card list, not a table, so it can never force horizontal
   scroll on a narrow screen no matter how long a contestant's name is. */
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
}
.leaderboard-list .rank {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.leaderboard-list li:nth-child(1) .rank { background: var(--contrast); }
.leaderboard-list .name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: break-word;
}
.leaderboard-list li:nth-child(1) .name { color: var(--contrast); }
.leaderboard-list .votes {
  flex: 0 0 auto;
  font-weight: 800;
  color: var(--primary);
  font-size: 0.95rem;
  text-align: right;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
@media (min-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
.stats-row-single {
  grid-template-columns: 1fr;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 640px) {
  .stats-row-single { grid-template-columns: 1fr; }
}
.stat-tile {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--primary); }
.stat-tile .stat-label { font-size: 0.85rem; color: #666; margin-top: 4px; }

/* Footer */
.site-footer {
  background: var(--primary);
  color: var(--white);
  padding: 28px 0;
  margin-top: 40px;
}
.site-footer .footer-logos {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.site-footer .footer-logos img { height: 40px; width: auto; border-radius: 4px; background: var(--white); }
.site-footer p { font-size: 0.85rem; opacity: 0.85; margin: 4px 0; }
.site-footer a { color: var(--white); text-decoration: underline; opacity: 1; }
.site-footer a:hover { opacity: 0.85; }

/* Sticky mobile vote CTA */
.sticky-vote-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.12);
  padding: 10px 16px;
  z-index: 20;
  display: none;
}
@media (max-width: 859px) {
  .sticky-vote-cta { display: flex; }
  body.has-sticky-cta { padding-bottom: 78px; }
}
.sticky-vote-cta {
  align-items: center;
  gap: 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.sticky-vote-cta .sticky-amount {
  flex: 0 0 auto;
  font-weight: 800;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.2;
}
.sticky-vote-cta .sticky-amount span { display: block; color: var(--cta); font-size: 1.05rem; }
.sticky-vote-cta .btn { flex: 1 1 auto; margin: 0; }

.badge-closed {
  display: inline-block;
  background: #999;
  color: var(--white);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.92rem;
}
.alert-success { background: #e3f6e1; color: var(--primary); border: 1px solid var(--primary-light); }
.alert-error { background: #fdeaea; color: #a33; border: 1px solid #e0a1a1; }

/* ===== Admin ===== */
.admin-header {
  background: var(--contrast);
  color: var(--white);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow);
}
.admin-header .admin-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-header .admin-brand { font-weight: 700; font-size: 1rem; color: var(--white); }
.admin-nav-toggle {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.4rem;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  display: none;
}
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.admin-nav a, .admin-nav button {
  color: var(--white);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,0.15); text-decoration: none; }
@media (max-width: 760px) {
  .admin-nav-toggle { display: block; }
  .admin-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-top: 8px;
    padding-bottom: 6px;
  }
  .admin-nav.open { display: flex; }
}

.admin-main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.admin-card h2 { margin-top: 0; color: var(--contrast); font-size: 1.2rem; }

.admin-stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (min-width: 560px) { .admin-stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px) { .admin-stats-row { grid-template-columns: repeat(4, 1fr); } }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* Card-list rows for admin data (contestants, transactions, activity) —
   same "no cramped tables on mobile" approach as the public leaderboard. */
.data-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.data-list li {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}
.data-list .field { display: flex; flex-direction: column; gap: 2px; }
.data-list .field .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: #888; }
.data-list .field .value { font-size: 0.92rem; font-weight: 600; }
.data-list .field.grow { flex: 1 1 160px; }
.data-list .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status-pill.success, .status-pill.active { background: #e3f6e1; color: var(--primary); }
.status-pill.pending { background: #fff6e0; color: #a67300; }
.status-pill.failed, .status-pill.withdrawn { background: #fdeaea; color: #a33; }

.admin-form .form-row { margin-bottom: 16px; }
.admin-form label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.admin-form input[type=text],
.admin-form input[type=email],
.admin-form input[type=password],
.admin-form input[type=number],
.admin-form input[type=date],
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  min-height: 48px;
  font-family: inherit;
}
.admin-form textarea { min-height: 100px; resize: vertical; }
.admin-form .help-text { font-size: 0.8rem; color: #777; margin-top: 4px; }
.admin-form .checkbox-row { display: flex; align-items: center; gap: 10px; }
.admin-form .checkbox-row input { width: 22px; height: 22px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--contrast) 100%);
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
}
.login-card img { height: 56px; margin: 0 auto 16px; }
.login-card h1 { font-size: 1.2rem; text-align: center; color: var(--primary); margin: 0 0 20px; }
