:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body {
  margin: 0;
  background: #f5f7fb;
  color: #1f2937;
}

.topbar {
  background: #1e40af;
  color: white;
  padding: 0.85rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.topbar-nav a {
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.72rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
}

.topbar-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.topbar-nav a.active {
  background: #f8fafc;
  color: #1e3a8a;
  border-color: #bfdbfe;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.topbar-nav a:active {
  transform: translateY(1px);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #dbeafe;
  font-size: 0.9rem;
}

.topbar-logout {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 0.42rem 0.62rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.25);
}

.topbar-logout:hover {
  background: rgba(255, 255, 255, 0.18);
}

.container {
  max-width: 780px;
  margin: 1.35rem auto 2rem;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .topbar-inner {
    align-items: flex-start;
  }

  .topbar-user {
    width: 100%;
    justify-content: flex-start;
  }
}

.card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.form-grid {
  display: grid;
  gap: 0.9rem;
}

label {
  font-size: 0.95rem;
  display: grid;
  gap: 0.35rem;
}

input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
}

select,
textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
}

button,
.button-link {
  display: inline-block;
  text-decoration: none;
  border: none;
  background: #1e40af;
  color: white;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.button-link.secondary {
  background: #334155;
}

.muted {
  color: #6b7280;
  margin-top: 1rem;
}

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.photo-actions {
  display: grid;
  gap: 0.45rem;
}

.photo-help {
  margin: 0;
  font-size: 0.84rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.7rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.92rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.inline-form {
  margin: 0;
}

.button-link.tiny,
button.button-link.tiny {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.candidate-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #d1d5db;
}

.text-center {
  text-align: center;
}

.identity-preview {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  margin: 1rem 0;
}

.identity-photo {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
}

.camera-box {
  margin: 1rem 0 0.75rem;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #eff6ff;
  overflow: hidden;
}

.camera-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  background: #0f172a;
}

.hidden-canvas {
  display: none;
}

.camera-fallback {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.camera-fallback summary {
  cursor: pointer;
  color: #1e3a8a;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.candidate-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  background: #f8fafc;
}

.candidate-check {
  justify-self: start;
  width: 100%;
}

.candidate-photo-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #d1d5db;
}

.candidate-name {
  text-align: center;
  font-size: 0.92rem;
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.centered {
  justify-content: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
}

.candidate-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.elected {
  background: #dcfce7;
  color: #166534;
}

.badge.tie {
  background: #ffedd5;
  color: #9a3412;
}

.badge.pending {
  background: #e5e7eb;
  color: #374151;
}

.badge.invalid {
  background: #fee2e2;
  color: #991b1b;
}
