:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  min-height: 100vh;
}

.wrap.wide { max-width: 1080px; }

.topbar {
  text-align: center;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.topbar p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.step-dot {
  width: 28px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
}

.step-dot.active { background: var(--primary); }
.step-dot.done { background: var(--success); }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}

.card + .card { margin-top: 16px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 16px;
}

label:first-of-type { margin-top: 0; }

input[type="text"], select, input[type="password"], input[type="file"], textarea, input[type="datetime-local"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  text-decoration: none;
}

.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; margin-top: 0; }
.btn.block-auto { width: auto; }

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }

.candidate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.candidate-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  text-align: left;
  padding: 0;
}

.candidate-card.selected { border-color: var(--primary); }

.candidate-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: #f1f5f9;
}

.candidate-card .cname {
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; }

/* Admin layout */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  background: #111827;
  color: #e5e7eb;
  padding: 20px 0;
  flex-shrink: 0;
}
.admin-sidebar h2 { font-size: 16px; padding: 0 20px 16px; margin: 0; border-bottom: 1px solid #1f2937; }
.admin-sidebar a {
  display: block;
  padding: 11px 20px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: #1f2937; color: #fff; }
.admin-main { flex: 1; padding: 28px 32px; max-width: 1200px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.admin-topbar h1 { font-size: 22px; margin: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 12px; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.inactive { background: #f1f5f9; color: #64748b; }
.badge.voted { background: #dbeafe; color: #1e40af; }
.badge.notvoted { background: #fef3c7; color: #92400e; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

.progress-bar { background: var(--border); border-radius: 999px; overflow: hidden; height: 10px; margin-top: 6px; }
.progress-bar > div { background: var(--primary); height: 100%; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type="text"] { width: auto; min-width: 160px; }

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

.chart-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chart-label { width: 160px; font-size: 14px; flex-shrink: 0; }
.chart-track { flex: 1; background: var(--border); border-radius: 6px; overflow: hidden; height: 22px; }
.chart-fill { background: var(--primary); height: 100%; display: flex; align-items: center; justify-content: flex-end; color: #fff; font-size: 12px; padding-right: 6px; }
.chart-count { width: 40px; text-align: right; font-size: 13px; font-weight: 600; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-sidebar a { display: inline-block; padding: 10px 14px; }
  .admin-main { padding: 20px; }
}
