:root {
  --bg-color: #f7f9fa;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --border-color: #d1d5db;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #b91c1c;
  --success: #15803d;
  --focus-ring: #93c5fd;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  padding: 1rem;
}

.site-header {
  max-width: 600px;
  margin: 0 auto 1.5rem auto;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.main-content {
  max-width: 600px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

h1, h2, h3 {
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

p {
  margin-bottom: 0.75rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.code-input {
  font-family: monospace;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Radio buttons & choices */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.choice-label {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  background: #fafafa;
}

.choice-label:hover {
  background: #f3f4f6;
}

.choice-label input[type="radio"] {
  margin-right: 0.75rem;
  width: 1.25rem;
  height: 1.25rem;
}

/* Buttons */
.btn {
  display: inline-block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
  background-color: var(--primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #6b7280;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-error {
  background-color: #fee2e2;
  border: 1px solid #f87171;
  color: var(--danger);
}

.alert-success {
  background-color: #dcfce7;
  border: 1px solid #86efac;
  color: var(--success);
}

/* Visibility helpers and ballot/review components */
.hidden {
  display: none !important;
}

.noscript-note {
  margin-top: 1rem;
}

.noscript-btn {
  margin-top: 0.5rem;
}

.review-list {
  list-style: none;
  padding: 0;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.review-actions {
  display: flex;
  gap: 1rem;
  flex-direction: column;
}

.turnout-box {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f9fafb;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.table-full-width {
  width: 100%;
}

.card-helpdesk-code {
  background-color: #fff9db;
  border: 2px solid #f59f00;
  padding: 1.5rem;
  margin-top: 1rem;
}

.code-display-large {
  font-size: 2rem;
  font-family: monospace;
  font-weight: bold;
  letter-spacing: 0.15em;
  color: #d9480f;
  margin: 1rem 0;
}

.ballot-position-card {
  border: 1px solid #ccc;
  padding: 1rem;
  margin-bottom: 1rem;
}

.textarea-monospace-full {
  font-family: monospace;
  width: 100%;
}

.codes-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.codes-card-secondary {
  margin: 0;
  background-color: var(--surface-secondary, #f8f9fa);
}

.text-danger-bold {
  color: var(--color-danger, #e03131);
  font-weight: bold;
}

.text-success-bold {
  color: #2b8a3e;
  font-weight: bold;
}

.card-batch-status {
  margin-bottom: 1.5rem;
  background-color: #e7f5ff;
  border: 1px solid #74c0fc;
}

.alert-mt-half {
  margin-top: 0.5rem;
}

.card-send-action {
  border: 2px solid var(--border-color, #dee2e6);
}

.dashboard-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.mt-1 {
  margin-top: 1rem;
}

.mt-1-5 {
  margin-top: 1.5rem;
}

.site-footer {
  max-width: 600px;
  margin: 2rem auto 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* Optional vetted candidate pictures (same-origin WebP files) */
.candidate-img {
  display: block;
  width: 6rem;
  height: 6rem;
  max-width: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: #f3f4f6;
  flex: 0 0 auto;
}

.choice-label .candidate-img {
  margin-right: 0.75rem;
}

.review-item .candidate-img {
  width: 4rem;
  height: 4rem;
  margin-bottom: 0.25rem;
}

.admin-candidate-image {
  margin-top: 0.25rem;
}

/* Voter results page: count-only list, optional vetted picture */
.result-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fafafa;
}

.result-item .candidate-img {
  margin-right: 0.75rem;
}

.result-item .choice-text {
  flex: 1 1 auto;
}

.result-votes {
  margin-left: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* Unopposed (one-candidate) positions: pre-selected, locked, noted */
.unopposed-note {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--border-color);
  background: #f3f4f6;
}

.choice-locked {
  cursor: default;
}

.unopposed-mark {
  font-style: italic;
  color: var(--text-muted);
}

/* T239: voter identity banner ("Voting as <name>") with a log-out control */
.voter-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #f3f4f6;
}

.voter-identity-text {
  margin: 0;
  overflow-wrap: anywhere;
}

.voter-identity-logout {
  margin: 0;
}

/* T241: grouped ballot screens. Without JavaScript every screen is visible (no .js class). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.js .ballot-screen {
  display: none;
}

.js .ballot-screen.is-current {
  display: block;
}

.ballot-screen:focus {
  outline: none;
}

.screen-progress-list {
  list-style: none;
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0;
}

.screen-seg {
  flex: 1 1 0;
  min-width: 0;
}

.screen-seg-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.5rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  background: #e5e7eb;
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
}

.screen-seg-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.screen-seg-completed .screen-seg-btn {
  background: #dcfce7;
  border-color: #16a34a;
}

.screen-seg-current .screen-seg-btn {
  background: #ffffff;
  border-color: #1d4ed8;
  box-shadow: inset 0 -4px 0 #1d4ed8;
}

.screen-seg-check {
  visibility: hidden;
  font-weight: bold;
  color: #166534;
}

.screen-seg-completed .screen-seg-check {
  visibility: visible;
}

.screen-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.screen-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.review-incomplete {
  border-left: 4px solid #b91c1c;
  padding-left: 0.5rem;
}

.review-flag {
  color: #b91c1c;
  font-weight: bold;
}

.review-change {
  margin-left: 0.25rem;
}
