:root {
  color-scheme: light;
  --bg: #eef4f7;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667789;
  --line: #d7e1e7;
  --primary: #2364aa;
  --primary-dark: #174a7c;
  --accent: #bd3d2a;
  --bar: #2f80c4;
  --soft: #f7fafc;
  --soft-blue: #e7f0f8;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #dfeef5 0, rgba(223, 238, 245, 0) 260px),
    var(--bg);
  color: var(--text);
}

button,
input,
.link-button {
  font: inherit;
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.admin-shell {
  max-width: 1100px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.candidate-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0 12px;
}

.title-block {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(39, 74, 104, 0.09);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 920px;
  color: #202b49;
  font-size: clamp(25px, 6vw, 38px);
  line-height: 1.22;
}

h2 {
  font-size: 20px;
}

.topbar p,
.field span,
.stats span,
.voter-card p {
  color: var(--muted);
}

.topbar p {
  margin-top: 8px;
  line-height: 1.45;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kicker {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.vote-time {
  color: #526173;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.badge {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f9fcff;
  text-align: center;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 14px 34px rgba(39, 74, 104, 0.09);
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 127, 114, 0.14);
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
}

.compact {
  min-height: 38px;
  padding: 0 12px;
}

.candidate-grid {
  display: grid;
  gap: 14px;
}

.candidate-group {
  display: grid;
  gap: 9px;
}

.group-title {
  width: max-content;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 800;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.candidate-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.candidate-card:has(input:checked) {
  border-color: var(--primary);
  background: #edf6ff;
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.12);
}

.candidate-card input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.candidate-info {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.candidate-info strong {
  font-size: 19px;
  line-height: 1.25;
}

.candidate-info span,
.candidate-info em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.35;
}

.submit {
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  background: var(--primary);
  color: #fff;
}

.submit:hover {
  background: var(--primary-dark);
}

.top-submit {
  margin-top: 0;
}

.top-message {
  margin-bottom: 12px;
}

.message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
}

.success {
  color: var(--primary-dark);
}

.error {
  color: var(--accent);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.admin-page {
  display: none;
}

.admin-page.active {
  display: block;
}

.result-list {
  display: grid;
  gap: 10px;
}

.result-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
}

.rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--soft-blue);
  font-weight: 800;
}

.result-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.result-name span {
  display: grid;
  gap: 3px;
}

.result-name em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 500;
  line-height: 1.35;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.bar span {
  display: block;
  height: 100%;
  min-width: 0;
  background: var(--bar);
}

.voter-list {
  display: grid;
  gap: 10px;
}

.voter-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.voter-card.ignored {
  opacity: 0.58;
}

.voter-card h3 {
  font-size: 17px;
}

.voter-card p {
  margin-top: 5px;
  line-height: 1.4;
}

.selected-names {
  word-break: break-word;
}

.empty {
  color: var(--muted);
}

.success-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.success-panel {
  width: min(420px, 100%);
  padding: 28px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 10px 30px rgba(24, 32, 42, 0.06);
}

.success-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(21, 127, 114, 0.12);
  color: var(--primary-dark);
  font-size: 40px;
  font-weight: 800;
}

.success-panel p {
  margin-top: 10px;
  color: var(--muted);
}

.link-button {
  display: inline-grid;
  min-height: 46px;
  place-items: center;
  margin-top: 22px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

@media (min-width: 720px) {
  .shell {
    padding: 28px 22px 48px;
  }

  .panel {
    padding: 18px;
  }

  .candidate-grid {
    gap: 16px;
  }

  .group-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .meta-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .candidate-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .badge {
    width: max-content;
  }

  .group-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}
