:root {
  --bg: #0f172a;
  --card: #111c33;
  --card-elevated: #162544;
  --border: rgba(148, 163, 184, 0.2);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.15);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --yes: #22c55e;
  --no: #f97316;
  --abstain: #eab308;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent 40%),
    radial-gradient(circle at bottom right, rgba(248, 113, 113, 0.1), transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

main {
  width: min(1200px, 94vw);
  margin: 0 auto 4rem;
  flex: 1;
}

.app-header {
  padding: 2.5rem 3rem 1.5rem;
  text-align: center;
}

.app-header h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.75rem auto 2rem;
  max-width: 600px;
  color: var(--muted);
}

.tab-nav {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
  padding: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(8px);
}

.tab-button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: color 0.2s ease, background 0.2s ease;
}

.tab-button.active {
  background: var(--accent);
  color: #0f172a;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin: 0 0 1.5rem;
}

.panel-header .note {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(30, 41, 59, 0.9));
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
}

.form-card {
  display: grid;
  grid-template-columns: minmax(0, 2fr) auto auto;
  gap: 1rem;
  align-items: end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--muted);
}

.field-group input,
.field-group select {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
}

.field-group input:focus,
.field-group select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

button {
  font-family: inherit;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease, color 0.2s ease;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.35);
}

button.secondary {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 12px 30px rgba(248, 113, 113, 0.35);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

button.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

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

.list-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.voter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.voter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.voter-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.voter-details .id {
  color: var(--muted);
  font-size: 0.85rem;
}

.toggle-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.proxy-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
}

.simple-list,
.proxy-order {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.list-button {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-button.active,
.proxy-row.active {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.proxy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.65);
}

.proxy-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.proxy-info .label {
  font-size: 0.8rem;
  color: var(--muted);
}

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

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

.vote-layout {
  margin-top: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

.vote-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.vote-meta .card {
  height: 100%;
}

.tally-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.voter-canvas {
  padding-bottom: 1.75rem;
}

.canvas-wrapper {
  position: relative;
  min-height: 460px;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 1.25rem 1.5rem;
  overflow: hidden;
}

.canvas {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  align-items: flex-start;
  gap: 3.5rem;
  position: relative;
  z-index: 2;
}

.canvas-column {
  position: relative;
  min-height: 120px;
}

.canvas-column .canvas-card {
  margin: 0;
  width: 100%;
  position: absolute;
  left: 0;
  right: 0;
  transition: top 0.25s ease;
}

.tally-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
  margin-left: 2.5rem;
  padding-left: 0.5rem;
  align-self: stretch;
}

.canvas-card {
  min-width: 180px;
  background: var(--card-elevated);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.canvas-card.selected {
  box-shadow: 0 0 0 2px var(--accent), 0 18px 40px rgba(56, 189, 248, 0.45);
  transform: translateY(-4px);
}

.canvas-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.canvas-card .badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted);
}

.canvas-card[data-vote="YES"] {
  border-color: rgba(34, 197, 94, 0.6);
  box-shadow: 0 12px 25px rgba(34, 197, 94, 0.3);
}

.canvas-card[data-vote="NO"] {
  border-color: rgba(249, 115, 22, 0.6);
  box-shadow: 0 12px 25px rgba(249, 115, 22, 0.3);
}

.canvas-card[data-vote="ABSTAIN"] {
  border-color: rgba(234, 179, 8, 0.6);
  box-shadow: 0 12px 25px rgba(234, 179, 8, 0.25);
}

.canvas-card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.canvas-card .meta-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.canvas-card .meta-line {
  display: block;
  line-height: 1.2;
}

.canvas-card .meta-line--full {
  color: var(--text);
}

.canvas-card .meta.is-empty {
  margin-bottom: 0.1rem;
}

.canvas-card .meta.is-empty .meta-lines {
  display: none;
}

.canvas-card .meta strong {
  color: inherit;
}

.card-vote-pills {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  flex-shrink: 0;
  margin-left: auto;
}

.canvas-card .vote-pill {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(148, 163, 184, 0.12);
  border: 2px solid transparent;
  color: var(--muted);
  box-shadow: none;
  transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.canvas-card .vote-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.canvas-card .vote-pill.cast {
  color: var(--text);
}

.canvas-card .vote-pill-yes {
  border-color: rgba(34, 197, 94, 0.55);
  color: var(--yes);
  background: rgba(34, 197, 94, 0.16);
}

.canvas-card .vote-pill-yes.cast {
  background: rgba(34, 197, 94, 0.75);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35), 0 0 18px rgba(34, 197, 94, 0.45);
  color: #052e16;
}

.canvas-card .vote-pill-abstain {
  border-color: rgba(234, 179, 8, 0.55);
  color: var(--abstain);
  background: rgba(234, 179, 8, 0.18);
}

.canvas-card .vote-pill-abstain.cast {
  background: rgba(234, 179, 8, 0.75);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.35), 0 0 18px rgba(234, 179, 8, 0.45);
  color: #422006;
}

.canvas-card .vote-pill-no {
  border-color: rgba(248, 113, 113, 0.6);
  color: var(--danger);
  background: rgba(248, 113, 113, 0.2);
}

.canvas-card .vote-pill-no.cast {
  background: rgba(249, 115, 22, 0.75);
  border-color: rgba(249, 115, 22, 0.65);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.35), 0 0 18px rgba(249, 115, 22, 0.45);
  color: #431407;
}

.tally-card {
  min-width: 160px;
  border-radius: 18px;
  padding: 1rem;
  color: var(--text);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 2px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.45);
  box-shadow: inset 0 0 12px rgba(15, 23, 42, 0.55);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tally-card[data-vote="YES"] {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.18);
  box-shadow: 0 12px 24px rgba(34, 197, 94, 0.28);
}

.tally-card[data-vote="ABSTAIN"] {
  border-color: rgba(234, 179, 8, 0.6);
  background: rgba(234, 179, 8, 0.2);
  box-shadow: 0 12px 24px rgba(234, 179, 8, 0.25);
}

.tally-card[data-vote="NO"] {
  border-color: rgba(249, 115, 22, 0.65);
  background: rgba(249, 115, 22, 0.2);
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.28);
}

.tally-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.tally-card .badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.2);
  color: var(--text);
}

.tally-card[data-vote="YES"] .badge {
  background: rgba(34, 197, 94, 0.25);
  color: #dcfce7;
}

.tally-card[data-vote="ABSTAIN"] .badge {
  background: rgba(234, 179, 8, 0.28);
  color: #facc15;
}

.tally-card[data-vote="NO"] .badge {
  background: rgba(249, 115, 22, 0.3);
  color: #fed7aa;
}

.canvas-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.arrow-path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tally-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.tally-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.65);
}

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

.tally-item[data-vote="YES"] .label::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--yes);
}

.tally-item[data-vote="NO"] .label::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--no);
}

.tally-item[data-vote="ABSTAIN"] .label::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--abstain);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

@media (max-width: 1000px) {
  .form-card {
    grid-template-columns: 1fr;
  }

  .proxy-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vote-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .proxy-layout {
    grid-template-columns: 1fr;
  }

  .canvas {
    grid-auto-flow: row;
  }
}
