:root {
  --primary: #2d6a2d;
  --primary-dark: #1a4a1a;
  --primary-light: #4a8f4a;
  --gold: #c8a44a;
  --gold-light: #e8c870;
  --bg: #f4f1eb;
  --white: #ffffff;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-800: #343a40;
  --danger: #c0392b;
  --success: #27ae60;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.16);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ---- DARK MODE VARIABLES ---- */
[data-theme="dark"] {
  --bg: #121212;
  --white: #1e1e1e;
  --gray-100: #2a2a2a;
  --gray-200: #333333;
  --gray-300: #444444;
  --gray-500: #888888;
  --gray-600: #aaaaaa;
  --gray-800: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- HEADER ---- */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  box-shadow: var(--shadow-lg);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 20px 14px;
  text-align: center;
}
.site-name { font-size: 2.2rem; font-weight: bold; color: white; line-height: 1.1; text-shadow: 1px 2px 4px rgba(0,0,0,0.3); }
.site-tagline { color: var(--gold-light); font-style: italic; margin-top: 5px; font-size: 1rem; }
.header-nav { background: rgba(0,0,0,0.25); }
.header-nav ul { max-width: 1100px; margin: 0 auto; padding: 0 20px; list-style: none; display: flex; justify-content: center; flex-wrap: wrap; }
.header-nav a { color: rgba(255,255,255,0.85); text-decoration: none; display: block; padding: 10px 22px; font-family: Arial, sans-serif; font-size: 0.9rem; letter-spacing: 0.4px; transition: all 0.2s; }
.header-nav a:hover, .header-nav a.active { background: var(--gold); color: var(--primary-dark); font-weight: bold; }

/* ---- LAYOUT ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.main-content { padding: 36px 0 60px; }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #3d7d3d 45%, var(--primary-dark) 100%);
  color: white;
  text-align: center;
  padding: 76px 20px;
}
.hero h1 { font-size: 2.7rem; margin-bottom: 14px; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
.hero p { font-size: 1.12rem; max-width: 600px; margin: 0 auto 30px; opacity: 0.94; font-family: Arial, sans-serif; }
.hero-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---- BUTTONS ---- */
.btn { display: inline-block; padding: 12px 30px; border-radius: 50px; text-decoration: none; font-size: 0.98rem; font-weight: bold; cursor: pointer; border: none; transition: all 0.2s; font-family: Arial, sans-serif; letter-spacing: 0.3px; text-align: center; }
.btn-primary { background: var(--gold); color: var(--primary-dark); }
.btn-primary:hover { background: var(--gold-light); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.2); }
.btn-outline { background: transparent; color: white; border: 2px solid rgba(255,255,255,0.7); }
.btn-outline:hover { background: white; color: var(--primary); }
.btn-green { background: var(--primary); color: white; }
.btn-green:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a93226; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-sm { padding: 6px 14px; font-size: 0.83rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ---- HOME PAGE ---- */
.how-it-works { background: white; padding: 56px 20px; }
.how-it-works h2 { text-align: center; color: var(--primary); font-size: 1.75rem; margin-bottom: 6px; }
.section-subtitle { text-align: center; color: var(--gray-600); font-family: Arial, sans-serif; margin-bottom: 38px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 28px; max-width: 880px; margin: 0 auto; }
.step-card { text-align: center; }
.step-num { width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: white; font-size: 1.4rem; font-weight: bold; display: flex; align-items: center; justify-content: center; margin: 0 auto 13px; }
.step-card h3 { color: var(--primary-dark); margin-bottom: 6px; }
.step-card p { color: var(--gray-600); font-family: Arial, sans-serif; font-size: 0.93rem; }
.categories-overview { padding: 56px 20px; }
.categories-overview h2 { text-align: center; color: var(--primary); font-size: 1.75rem; margin-bottom: 36px; }
.sections-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.section-overview-card { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.section-overview-card .card-body { padding: 24px; border-top: 4px solid var(--primary); }
.section-overview-card .sec-icon { font-size: 2rem; margin-bottom: 8px; }
.section-overview-card h3 { color: var(--primary-dark); margin-bottom: 4px; font-size: 1rem; }
.section-overview-card .count-row { display: flex; align-items: baseline; gap: 6px; }
.section-overview-card .count { color: var(--gold); font-size: 1.5rem; font-weight: bold; line-height: 1.2; }
.section-overview-card p { color: var(--gray-600); font-size: 0.88rem; font-family: Arial, sans-serif; margin: 0; }
.cta-center { text-align: center; margin-top: 34px; }

/* ---- BALLOT ---- */
.ballot-intro { background: white; border-radius: var(--radius-lg); padding: 26px 30px; margin-bottom: 24px; box-shadow: var(--shadow); border-left: 5px solid var(--gold); }
.ballot-intro h2 { color: var(--primary); margin-bottom: 6px; font-size: 1.4rem; }
.ballot-intro p { color: var(--gray-600); font-family: Arial, sans-serif; font-size: 0.95rem; }

/* Sticky progress */
#progress-bar-container { position: sticky; top: 0; z-index: 200; }
.sticky-progress { background: white; padding: 8px 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.12); display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--gold)); border-radius: 4px; transition: width 0.3s; }
.progress-text { font-family: Arial, sans-serif; font-size: 0.82rem; color: var(--gray-600); white-space: nowrap; }
.section-jumps { display: flex; gap: 5px; flex-wrap: wrap; }
.section-jump-btn { font-size: 0.72rem; padding: 3px 9px; border-radius: 20px; cursor: pointer; background: var(--gray-100); border: 1px solid var(--gray-300); color: var(--gray-600); font-family: Arial, sans-serif; transition: all 0.2s; }
.section-jump-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* Voter info */
.voter-info-card { background: white; border-radius: var(--radius-lg); padding: 26px 28px; margin-bottom: 22px; box-shadow: var(--shadow); }
.voter-info-card h3 { color: var(--primary); margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--gray-200); font-size: 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 0.87rem; font-weight: bold; color: var(--gray-800); margin-bottom: 5px; font-family: Arial, sans-serif; }
.form-group label .req { color: var(--danger); }
.form-group input { width: 100%; padding: 9px 12px; border: 2px solid var(--gray-300); border-radius: var(--radius); font-size: 0.95rem; font-family: Arial, sans-serif; transition: border-color 0.2s; }
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,106,45,0.1); }

/* Ballot sections */
.ballot-section { background: white; border-radius: var(--radius-lg); margin-bottom: 20px; box-shadow: var(--shadow); overflow: hidden; }
.ballot-section-header { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); color: white; padding: 14px 22px; display: flex; align-items: center; gap: 10px; }
.ballot-section-header .sec-icon { font-size: 1.4rem; }
.ballot-section-header h3 { font-size: 1.15rem; flex: 1; margin: 0; }
.cat-badge { background: var(--gold); color: var(--primary-dark); border-radius: 20px; padding: 2px 10px; font-size: 0.78rem; font-weight: bold; font-family: Arial, sans-serif; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.category-item { padding: 13px 18px; border-bottom: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); }
.category-item:nth-child(even) { background: var(--gray-100); }
.cat-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--primary-dark); margin-bottom: 5px; font-family: Arial, sans-serif; text-transform: uppercase; letter-spacing: 0.3px; }
.category-item input[type="text"] { width: 100%; padding: 7px 10px; border: 1.5px solid var(--gray-300); border-radius: 6px; font-size: 0.9rem; font-family: Arial, sans-serif; transition: all 0.2s; background: white; }
.category-item input[type="text"]:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,164,74,0.15); }
.category-item input[type="text"].has-value { border-color: var(--primary); background: #f0f7f0; }

/* Submit */
.submit-area { background: white; border-radius: var(--radius-lg); padding: 30px; text-align: center; box-shadow: var(--shadow); margin-top: 6px; }
.submit-area .disclaimer { font-size: 0.84rem; color: var(--gray-600); font-family: Arial, sans-serif; margin-bottom: 18px; max-width: 600px; margin-left: auto; margin-right: auto; }
.submit-area .btn { font-size: 1.15rem; padding: 15px 46px; }

/* ---- ALERTS ---- */
.alert { padding: 13px 17px; border-radius: var(--radius); margin-bottom: 18px; font-family: Arial, sans-serif; font-size: 0.94rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.hidden { display: none !important; }

/* ---- SUCCESS PAGE ---- */
.success-page { text-align: center; padding: 70px 20px; }
.success-icon { font-size: 5rem; margin-bottom: 14px; display: block; }
.success-page h2 { color: var(--primary); font-size: 1.9rem; margin-bottom: 10px; }
.success-page p { color: var(--gray-600); font-family: Arial, sans-serif; margin-bottom: 22px; max-width: 480px; margin-left: auto; margin-right: auto; }
.success-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- RESULTS ---- */
.stats-bar { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: white; border-radius: var(--radius-lg); padding: 22px 30px; display: flex; gap: 36px; align-items: center; margin-bottom: 30px; flex-wrap: wrap; }
.stat-item { text-align: center; }
.stat-num { font-size: 2rem; font-weight: bold; color: var(--gold-light); line-height: 1.1; }
.stat-lbl { font-size: 0.8rem; opacity: 0.8; font-family: Arial, sans-serif; }
.results-section-block { margin-bottom: 34px; }
.results-section-title { font-size: 1.35rem; color: var(--primary); padding-bottom: 8px; border-bottom: 3px solid var(--gold); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.result-card { background: white; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.result-cat-name { font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--gray-500); font-family: Arial, sans-serif; margin-bottom: 8px; }
.result-entry { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-family: Arial, sans-serif; }
.result-rank { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: bold; flex-shrink: 0; }
.result-rank.r1 { background: var(--gold); color: var(--primary-dark); }
.result-rank.r2 { background: #c0c0c0; color: #444; }
.result-rank.r3 { background: #cd7f32; color: white; }
.result-business { flex: 1; font-size: 0.88rem; color: var(--gray-800); }
.result-votes { font-size: 0.78rem; color: var(--gray-600); }
.no-votes { font-size: 0.84rem; color: var(--gray-500); font-style: italic; font-family: Arial, sans-serif; }
.results-note { font-family: Arial, sans-serif; font-size: 0.85rem; color: var(--gray-600); text-align: center; margin-bottom: 24px; }

/* ---- ADMIN ---- */
.admin-login { max-width: 400px; margin: 56px auto; background: white; border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow-lg); }
.admin-login h2 { color: var(--primary); margin-bottom: 18px; text-align: center; }
.admin-panel { background: white; border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px; }
.admin-panel h3 { color: var(--primary); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-200); font-size: 1.05rem; }
.admin-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-stat { background: var(--gray-100); border-radius: var(--radius); padding: 14px 20px; text-align: center; min-width: 120px; }
.admin-stat .n { font-size: 1.8rem; font-weight: bold; color: var(--primary); line-height: 1.1; }
.admin-stat .l { font-size: 0.8rem; color: var(--gray-600); font-family: Arial, sans-serif; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-family: Arial, sans-serif; font-size: 0.92rem; }
.toggle-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 0.87rem; }
th { background: var(--primary); color: white; padding: 9px 12px; text-align: left; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--gray-200); vertical-align: top; word-break: break-word; }
tr:hover td { background: var(--gray-100); }

/* ---- SPINNER ---- */
.spinner { display: inline-block; width: 17px; height: 17px; border: 3px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- THEME TOGGLE ---- */
.theme-toggle-wrap { display: flex; align-items: center; justify-content: flex-end; padding: 4px 20px; background: rgba(0,0,0,0.15); }
#theme-toggle { background: none; border: 1px solid rgba(255,255,255,0.4); color: rgba(255,255,255,0.85); padding: 3px 12px; border-radius: 20px; font-size: 0.78rem; cursor: pointer; font-family: Arial, sans-serif; transition: all 0.2s; }
#theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* ---- DARK MODE OVERRIDES ---- */
[data-theme="dark"] body { background: var(--bg); color: var(--gray-800); }
[data-theme="dark"] .how-it-works { background: var(--white); }
[data-theme="dark"] .section-overview-card,
[data-theme="dark"] .ballot-intro,
[data-theme="dark"] .voter-info-card,
[data-theme="dark"] .ballot-section,
[data-theme="dark"] .submit-area,
[data-theme="dark"] .admin-panel,
[data-theme="dark"] .admin-login,
[data-theme="dark"] .result-card { background: var(--white); }
[data-theme="dark"] .form-group input { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }
[data-theme="dark"] .cat-label { color: #ffffff; }
[data-theme="dark"] .category-item input[type="text"] { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-300); }
[data-theme="dark"] .category-item input[type="text"].has-value { background: #1a2e1a; }
[data-theme="dark"] .category-item:nth-child(even) { background: var(--gray-100); }
[data-theme="dark"] .admin-stat { background: var(--gray-100); }
[data-theme="dark"] td { border-bottom-color: var(--gray-200); }
[data-theme="dark"] tr:hover td { background: var(--gray-100); }
[data-theme="dark"] .section-jump-btn { background: var(--gray-200); border-color: var(--gray-300); color: var(--gray-600); }
[data-theme="dark"] #progress-bar-container,
[data-theme="dark"] .sticky-progress { background: var(--white); }
[data-theme="dark"] .progress-track { background: var(--gray-300); }
[data-theme="dark"] .alert-success { background: #1a3a1a; color: #6fcf97; border-color: #2d6a2d; }
[data-theme="dark"] .alert-error { background: #3a1a1a; color: #eb5757; border-color: #721c24; }
[data-theme="dark"] .alert-info { background: #1a2a3a; color: #56ccf2; border-color: #0c5460; }

/* ---- FOOTER ---- */
.site-footer { background: var(--primary-dark); color: rgba(255,255,255,0.6); text-align: center; padding: 22px 20px; font-family: Arial, sans-serif; font-size: 0.87rem; margin-top: 20px; }
.site-footer a { color: var(--gold-light); text-decoration: none; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sections-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .site-name { font-size: 1.6rem; }
  .hero h1 { font-size: 1.85rem; }
  .hero { padding: 48px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr; }
  .stats-bar { gap: 20px; justify-content: center; }
  .sticky-progress { padding: 7px 12px; }
  .section-jumps { display: none; }
  .header-nav a { padding: 9px 14px; font-size: 0.85rem; }
  .sections-grid { grid-template-columns: 1fr; }
}
