:root {
  color-scheme: dark;
  --page-bg: #07111f;
  --panel: #0c192a;
  --panel-strong: #101f32;
  --line: rgba(177, 204, 226, 0.14);
  --line-strong: rgba(177, 204, 226, 0.24);
  --text: #f4f8fb;
  --muted: #93a7b9;
  --gold: #f5c85b;
  --gold-strong: #d99331;
  --teal: #4dd7c5;
  --danger: #ff7a7a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    "Microsoft YaHei", sans-serif;
  --font-display: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    sans-serif;
  --font-number: "Bahnschrift", "DIN Alternate", "Arial Narrow",
    "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  color: #07111f;
  background: var(--gold);
  font-weight: 800;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* Public display */

.public-page {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -12%, rgba(31, 104, 117, 0.32), transparent 36%),
    radial-gradient(circle at 92% 8%, rgba(177, 104, 29, 0.15), transparent 32%),
    linear-gradient(145deg, #081524 0%, #07111f 52%, #091321 100%);
}

.page-atmosphere {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.page-atmosphere::before {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 180, 203, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 180, 203, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  content: "";
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 72%);
}

.atmosphere-line {
  position: absolute;
  width: 42vw;
  height: 42vw;
  border: 1px solid rgba(77, 215, 197, 0.09);
  border-radius: 50%;
}

.atmosphere-line--one {
  top: -25vw;
  left: -12vw;
}

.atmosphere-line--two {
  right: -28vw;
  bottom: -33vw;
  border-color: rgba(245, 200, 91, 0.07);
}

.site-header,
.results,
.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  padding-inline: clamp(20px, 4vw, 64px);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 132px;
  padding-top: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: flex-start;
  gap: 6px;
}

.brand-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(245, 200, 91, 0.45);
  border-radius: 10px;
  color: #0c1726;
  background: linear-gradient(145deg, #ffe39a 0%, var(--gold) 48%, #d58c2d 100%);
  box-shadow:
    0 12px 34px rgba(245, 200, 91, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 950;
}

.brand-mark::after {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(11, 23, 39, 0.18);
  border-radius: 7px;
  content: "";
}

.brand-mark span {
  position: relative;
  z-index: 1;
}

.brand-mark--small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 19px;
}

.brand-mark--small::after {
  inset: 4px;
  border-radius: 8px;
}

.brand-copy {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-family: var(--font-number);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot,
.connection-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.live-dot {
  color: #ff6868;
  box-shadow: 0 0 0 5px rgba(255, 104, 104, 0.12);
  animation: live-pulse 1.8s ease-in-out infinite;
}

.public-page.is-demo .eyebrow,
.public-page.is-demo .live-dot {
  color: var(--gold);
}

.public-page.is-demo .live-dot {
  box-shadow: 0 0 0 5px rgba(245, 200, 91, 0.12);
}

.brand h1 {
  max-width: 920px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.8vw, 2.75rem);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.14;
}

@media (min-width: 821px) {
  .public-page {
    height: 100vh;
    height: 100dvh;
  }
}

.header-metrics {
  display: flex;
  flex: 0 0 auto;
  align-items: stretch;
  gap: 14px;
}

.metric {
  display: flex;
  flex-direction: column;
  min-width: 138px;
  justify-content: center;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(10, 25, 42, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(14px);
}

.metric span {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.metric time,
.metric strong {
  color: var(--text);
  font-family: var(--font-number);
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.025em;
  line-height: 1.1;
}

.metric--total {
  min-width: 170px;
  border-color: rgba(245, 200, 91, 0.26);
  background:
    linear-gradient(145deg, rgba(245, 200, 91, 0.1), transparent 85%),
    rgba(10, 25, 42, 0.78);
}

.metric--total strong {
  color: var(--gold);
}

.results {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding-top: clamp(18px, 2.4vh, 30px);
  padding-bottom: 0;
}

.results-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.results-heading h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.4vw, 1.35rem);
  font-weight: 850;
  letter-spacing: 0.015em;
}

.results-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid rgba(245, 200, 91, 0.28);
  border-radius: 999px;
  color: #d7e0e7;
  background: rgba(245, 200, 91, 0.07);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.seat-chip strong {
  color: var(--gold);
  font-family: var(--font-number);
  font-size: 13px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  color: #71dbc6;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.connection-status[data-state="offline"] {
  color: #ff9b82;
}

.connection-status[data-state="demo"] {
  color: var(--gold);
}

.connection-status[data-state="connecting"] .connection-dot {
  animation: live-pulse 1.2s ease infinite;
}

.candidate-list {
  display: grid;
  flex: 1;
  grid-template-rows: repeat(var(--candidate-count, 9), minmax(64px, 1fr));
  gap: clamp(7px, 0.9vh, 11px);
  min-height: calc(var(--candidate-count, 9) * 64px + 70px);
}

.loading-panel {
  display: flex;
  grid-row: 1 / -1;
  min-height: 340px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  color: var(--muted);
  background: rgba(10, 24, 40, 0.6);
}

.loading-ring {
  display: inline-block;
  width: 21px;
  height: 21px;
  border: 2px solid rgba(147, 167, 185, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.loading-ring--large {
  width: 32px;
  height: 32px;
}

.candidate-row {
  --theme: #0f766e;
  --theme-deep: #073b37;
  position: relative;
  display: grid;
  min-width: 0;
  overflow: hidden;
  grid-template-columns:
    minmax(72px, 5.4vw)
    minmax(68px, 5.2vw)
    clamp(64px, 4.5vw, 86px)
    minmax(0, 1fr)
    auto;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: clamp(12px, 1.15vw, 18px);
  background:
    linear-gradient(100deg, var(--theme-deep) 0%, var(--theme) 64%, var(--theme-deep) 135%);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  isolation: isolate;
  transform-origin: center;
}

.candidate-row::before {
  position: absolute;
  z-index: -1;
  top: -120%;
  left: 38%;
  width: 22%;
  height: 340%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  content: "";
  transform: rotate(18deg);
}

.candidate-row::after {
  position: absolute;
  z-index: -1;
  right: -32px;
  bottom: -90px;
  width: 260px;
  height: 190px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  content: "";
}

.candidate-row.rank-first {
  border-color: rgba(255, 220, 126, 0.55);
  box-shadow:
    0 15px 34px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(245, 200, 91, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.17);
}

.candidate-row.rank-first::before {
  background: linear-gradient(90deg, transparent, rgba(255, 236, 177, 0.18), transparent);
}

.candidate-row.is-elected {
  border-color: rgba(255, 220, 126, 0.78);
  box-shadow:
    0 15px 34px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(245, 200, 91, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.19);
}

.candidate-row.is-light {
  border-color: rgba(13, 28, 43, 0.22);
  background:
    linear-gradient(100deg, #f0f2f3 0%, var(--theme) 58%, #b8c1c7 138%);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.candidate-row.is-light::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
}

.candidate-row.is-light::after {
  border-color: rgba(15, 30, 44, 0.12);
}

.candidate-row.is-light .rank-cell {
  border-color: rgba(15, 30, 44, 0.16);
  background: rgba(255, 255, 255, 0.2);
}

.candidate-row.is-light .rank-cell > span,
.candidate-row.is-light .rank-cell > strong,
.candidate-row.is-light .ballot-cell span,
.candidate-row.is-light .vote-cell span,
.candidate-row.is-light .vote-cell .vote-unit {
  color: rgba(11, 27, 42, 0.68);
  text-shadow: none;
}

.candidate-row.is-light .ballot-cell {
  border-color: rgba(15, 30, 44, 0.15);
  background: rgba(255, 255, 255, 0.18);
}

.candidate-row.is-light .ballot-cell strong,
.candidate-row.is-light .candidate-copy h3,
.candidate-row.is-light .vote-cell strong {
  color: #162332;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.16);
}

.candidate-row.is-light.rank-first .rank-cell > strong {
  color: #805700;
}

.candidate-row.is-light .candidate-photo {
  border-color: rgba(15, 30, 44, 0.48);
}

.candidate-row.is-light.is-elected {
  border-color: rgba(255, 220, 126, 0.78);
  box-shadow:
    0 15px 34px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(245, 200, 91, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.candidate-row.is-elected::before {
  background: linear-gradient(90deg, transparent, rgba(255, 236, 177, 0.22), transparent);
}

.rank-cell {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(4, 12, 20, 0.14);
}

.rank-cell > span {
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-number);
  font-size: clamp(8px, 0.7vw, 10px);
  font-weight: 700;
  letter-spacing: 0.18em;
}

.rank-cell > strong {
  font-family: var(--font-number);
  font-size: clamp(1.15rem, 1.45vw, 1.55rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.rank-first .rank-cell > strong {
  color: #ffe49a;
  text-shadow: 0 0 24px rgba(245, 200, 91, 0.22);
}

.ballot-cell {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(2, 9, 16, 0.11);
}

.ballot-cell span {
  color: rgba(255, 255, 255, 0.56);
  font-size: clamp(8px, 0.66vw, 10px);
  font-weight: 700;
  letter-spacing: 0.13em;
}

.ballot-cell strong {
  color: #fff8dd;
  font-family: var(--font-number);
  font-size: clamp(2.75rem, 4.2vw, 3.9rem);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  letter-spacing: -0.06em;
  line-height: 0.9;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.candidate-photo {
  display: grid;
  width: clamp(46px, 4.7vw, 64px);
  height: clamp(56px, 5.6vw, 78px);
  place-items: stretch;
  justify-self: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 11px;
  background: #dbe6ed;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.22);
}

.candidate-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.candidate-copy {
  position: relative;
  min-width: 0;
  padding: 8px clamp(16px, 2vw, 34px);
}

.candidate-copy h3 {
  overflow: hidden;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.35vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elected-stamp {
  position: absolute;
  top: 50%;
  right: clamp(10px, 3vw, 48px);
  display: grid;
  width: clamp(52px, 3.6vw, 66px);
  height: clamp(52px, 3.6vw, 66px);
  place-items: center;
  border: 3px solid #c62828;
  border-radius: 50%;
  color: #b71c1c;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.98), #ffffff 68%),
    #ffffff;
  box-shadow:
    inset 0 0 0 2px #ffffff,
    inset 0 0 0 3px rgba(198, 40, 40, 0.85),
    0 4px 14px rgba(65, 8, 8, 0.2);
  font-size: clamp(13px, 1.05vw, 17px);
  font-weight: 950;
  letter-spacing: 0.02em;
  line-height: 1;
  opacity: 0.96;
  pointer-events: none;
  transform: translateY(-50%) rotate(-8deg);
  white-space: nowrap;
}
.vote-cell {
  display: flex;
  min-width: clamp(190px, 20vw, 305px);
  height: 100%;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 8px clamp(20px, 2.2vw, 36px);
}

.vote-cell span {
  align-self: center;
  color: rgba(255, 255, 255, 0.58);
  font-size: clamp(9px, 0.72vw, 11px);
  font-weight: 700;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
}

.vote-cell strong {
  color: #ffe078;
  font-family: var(--font-number);
  font-size: clamp(2.15rem, 4.45vw, 4.75rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.9;
  text-align: right;
  text-shadow: 0 3px 18px rgba(31, 21, 0, 0.26);
}

.vote-cell .vote-unit {
  align-self: flex-end;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
  letter-spacing: 0.03em;
  writing-mode: initial;
}

.candidate-row.vote-changed {
  animation: vote-highlight 650ms ease;
}

.site-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 42px;
  margin-top: 0;
  border-top: 1px solid var(--line);
  color: #75899b;
  background: rgba(5, 13, 23, 0.56);
  font-size: 11px;
  letter-spacing: 0.025em;
}

.site-footer p {
  margin: 0;
}

.data-mode {
  flex: 0 0 auto;
  color: #a6b5c2;
}

/* Admin */

.admin-page {
  position: relative;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 10% 0%, rgba(24, 100, 94, 0.28), transparent 32%),
    linear-gradient(145deg, #07131f, #091725 58%, #07111f);
}

.admin-background {
  position: fixed;
  z-index: 0;
  inset: 0;
  background-image:
    linear-gradient(rgba(134, 167, 190, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(134, 167, 190, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000, transparent 90%);
  pointer-events: none;
}

.admin-header,
.admin-main,
.admin-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  padding-inline: clamp(20px, 4vw, 64px);
}

.admin-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 16, 28, 0.66);
  backdrop-filter: blur(15px);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
}

.admin-brand > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-brand strong {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.admin-brand small {
  color: var(--muted);
  font-size: 11px;
}

.admin-header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mode-chip {
  padding: 6px 10px;
  border: 1px solid rgba(245, 200, 91, 0.24);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(245, 200, 91, 0.07);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.text-button {
  padding: 6px 0;
  border: 0;
  color: #b3c4d1;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 150ms ease;
}

.text-button:hover {
  color: var(--text);
}

.admin-main {
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(28px, 5vh, 62px);
  padding-bottom: 56px;
}

.auth-card {
  width: min(100%, 520px);
  margin: 5vh auto 0;
  padding: clamp(26px, 4.5vw, 44px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 62%),
    rgba(12, 27, 45, 0.92);
  box-shadow: var(--shadow);
}

#boot-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.auth-card h1,
.dashboard-heading h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  font-weight: 900;
  letter-spacing: -0.025em;
}

.auth-card__intro {
  margin: 12px 0 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #d4dee6;
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: rgba(4, 13, 24, 0.72);
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.login-form input:focus {
  border-color: rgba(245, 200, 91, 0.68);
  box-shadow: 0 0 0 3px rgba(245, 200, 91, 0.09);
}

.primary-button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 230, 153, 0.48);
  border-radius: 11px;
  color: #111b25;
  background: linear-gradient(135deg, #ffe297, var(--gold) 58%, #d98c2d);
  box-shadow: 0 8px 24px rgba(245, 200, 91, 0.13);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 140ms ease,
    filter 140ms ease;
}

.primary-button:hover {
  filter: brightness(1.045);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  filter: saturate(0.35);
  opacity: 0.65;
  transform: none;
}

.form-error {
  min-height: 20px;
  margin: -3px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.demo-login {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.demo-login__icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(77, 215, 197, 0.22);
  border-radius: 11px;
  color: var(--teal);
  background: rgba(77, 215, 197, 0.06);
  font-family: var(--font-number);
  font-size: 11px;
  font-weight: 800;
}

.demo-login strong {
  font-size: 13px;
}

.demo-login p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.demo-login .primary-button {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.dashboard {
  width: 100%;
  max-width: 1480px;
}

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 26px;
}

.dashboard-heading > div:first-child > p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-summary {
  display: flex;
  gap: 12px;
}

.dashboard-summary > div {
  display: flex;
  min-width: 138px;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(11, 25, 42, 0.7);
}

.dashboard-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dashboard-summary strong {
  overflow: hidden;
  color: var(--gold);
  font-family: var(--font-number);
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-summary__elected strong {
  color: #6be2cd;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
  color: #8296a8;
  font-size: 11px;
}

.admin-toolbar p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}

#admin-sync-status {
  color: #71dbc6;
}

#admin-sync-status[data-state="offline"] {
  color: #ff9b82;
}

#admin-sync-status[data-state="demo"] {
  color: var(--gold);
}

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

.admin-candidate {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 58px 76px minmax(180px, 1fr) minmax(470px, auto);
  align-items: center;
  gap: 17px;
  overflow: hidden;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--theme) 15%, #0b192b), #0b192b 64%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.admin-candidate::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--theme);
  content: "";
}

.admin-candidate.is-elected {
  border-color: rgba(245, 200, 91, 0.42);
  background:
    linear-gradient(100deg, rgba(245, 200, 91, 0.12), transparent 42%),
    linear-gradient(100deg, color-mix(in srgb, var(--theme) 15%, #0b192b), #0b192b 64%);
}

.admin-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.admin-rank span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.admin-rank strong {
  font-family: var(--font-number);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.admin-photo {
  width: 64px;
  height: 74px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  background: #dbe6ed;
}

.admin-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-identity {
  min-width: 0;
}

.admin-identity span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-identity h2 {
  overflow: hidden;
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-progress {
  height: 4px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.vote-progress span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--theme), #f5c85b);
  transition: width 500ms ease;
}

.admin-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.elected-toggle {
  position: relative;
  display: inline-flex;
  height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: #aebdc9;
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.elected-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.elected-toggle__box {
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid rgba(174, 189, 201, 0.52);
  border-radius: 4px;
  background: rgba(2, 10, 18, 0.45);
  font-size: 10px;
}

.elected-toggle:has(input:checked) {
  border-color: rgba(245, 200, 91, 0.55);
  color: #ffe49a;
  background: rgba(245, 200, 91, 0.1);
}

.elected-toggle:has(input:checked) .elected-toggle__box {
  border-color: #f5c85b;
  color: #151b20;
  background: #f5c85b;
}

.elected-toggle:has(input:focus-visible) {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.elected-toggle:has(input:disabled) {
  cursor: wait;
  opacity: 0.48;
}

.vote-adjust,
.save-votes {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  font-family: var(--font-number);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.vote-adjust:hover,
.save-votes:hover {
  border-color: rgba(245, 200, 91, 0.38);
  background: rgba(245, 200, 91, 0.075);
  transform: translateY(-1px);
}

.vote-adjust:disabled,
.save-votes:disabled {
  cursor: wait;
  opacity: 0.45;
  transform: none;
}

.vote-adjust--minus {
  color: #ffaaa0;
}

.vote-total-input {
  width: 118px;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: #ffe078;
  background: rgba(3, 12, 22, 0.72);
  font-family: var(--font-number);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
  outline: none;
}

.vote-total-input:focus {
  border-color: rgba(245, 200, 91, 0.62);
  box-shadow: 0 0 0 3px rgba(245, 200, 91, 0.08);
}

.save-votes {
  min-width: 58px;
  padding: 0 12px;
  color: #141c23;
  background: #f5c85b;
  font-family: var(--font-sans);
  font-size: 11px;
}

.save-votes:hover {
  color: #141c23;
  background: #ffdc7c;
}

.activity-panel {
  margin-top: 26px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(9, 22, 38, 0.68);
}

.activity-panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}

.activity-panel h2 {
  margin: 0;
  font-size: 15px;
}

.activity-list {
  display: grid;
  gap: 0;
}

.activity-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 11px 0;
  border-top: 1px solid rgba(177, 204, 226, 0.08);
  color: #bdcbd5;
  font-size: 12px;
}

.activity-item:first-child {
  border-top: 0;
  padding-top: 2px;
}

.activity-item strong {
  color: var(--text);
}

.activity-item time {
  color: #7c91a2;
  font-family: var(--font-number);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-footer {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 0;
  border-top: 1px solid var(--line);
  color: #718596;
  background: rgba(5, 13, 23, 0.52);
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(245, 200, 91, 0.28);
  border-radius: 11px;
  color: #f6f7f2;
  background: rgba(12, 27, 44, 0.96);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.admin-page .toast {
  top: 92px;
  right: 24px;
  bottom: auto;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-tone="error"] {
  border-color: rgba(255, 122, 122, 0.4);
  color: #ffd7d2;
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 5px rgba(255, 104, 104, 0.12);
  }
  50% {
    opacity: 0.68;
    box-shadow: 0 0 0 9px rgba(255, 104, 104, 0.015);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes vote-highlight {
  0% {
    filter: brightness(1);
  }
  28% {
    filter: brightness(1.28);
  }
  100% {
    filter: brightness(1);
  }
}

@media (max-width: 1100px) {
  .site-header {
    min-height: 116px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .header-metrics {
    gap: 8px;
  }

  .metric {
    min-width: 122px;
    padding: 11px 14px;
  }

  .metric--total {
    min-width: 148px;
  }

  .candidate-row {
    grid-template-columns:
      minmax(64px, 5.5vw)
      minmax(60px, 5.5vw)
      clamp(58px, 5.4vw, 76px)
      minmax(0, 1fr)
      auto;
  }

  .candidate-photo {
    width: 53px;
    height: 66px;
  }

  .vote-cell {
    min-width: 175px;
    padding-inline: 20px;
  }

  .admin-candidate {
    grid-template-columns: 50px 66px minmax(150px, 1fr) minmax(430px, auto);
    gap: 13px;
  }

  .admin-photo {
    width: 56px;
    height: 66px;
  }
}

@media (max-width: 820px) {
  .site-header {
    align-items: flex-start;
    padding-top: 18px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 15px;
  }

  .brand-mark::after {
    inset: 4px;
    border-radius: 10px;
  }

  .header-metrics {
    flex-direction: column;
    gap: 6px;
  }

  .metric {
    min-width: 128px;
    padding: 8px 12px;
  }

  .metric--total {
    min-width: 128px;
  }

  .metric time,
  .metric strong {
    font-size: 20px;
  }

  .candidate-row {
    grid-template-columns: 54px 56px 52px minmax(0, 1fr);
    grid-template-areas:
      "rank ballot photo copy"
      "rank ballot photo votes";
    align-content: center;
    padding-block: 8px;
  }

  .rank-cell {
    grid-area: rank;
  }

  .ballot-cell {
    grid-area: ballot;
  }

  .ballot-cell strong {
    font-size: clamp(2.25rem, 8vw, 2.7rem);
  }

  .candidate-photo {
    grid-area: photo;
    width: 44px;
    height: 54px;
  }

  .candidate-copy {
    grid-area: copy;
    align-self: end;
    padding: 0 14px;
  }

  .elected-stamp {
    top: 50%;
    right: 2px;
    width: 46px;
    height: 46px;
    border-width: 2px;
    font-size: 11px;
    transform: translateY(-50%) rotate(-7deg);
  }

  .candidate-copy h3 {
    font-size: clamp(1.2rem, 5vw, 1.55rem);
  }

  .vote-cell {
    grid-area: votes;
    min-width: 0;
    height: auto;
    justify-content: flex-start;
    padding: 0 14px;
  }

  .vote-cell span {
    display: none;
  }

  .vote-cell strong {
    font-size: clamp(1.65rem, 7vw, 2.15rem);
    line-height: 1;
    text-align: left;
  }

  .vote-cell .vote-unit {
    display: inline;
    margin-bottom: 0;
  }

  .admin-candidate {
    grid-template-columns: 44px 58px minmax(0, 1fr);
    grid-template-areas:
      "rank photo identity"
      "controls controls controls";
    padding: 13px;
  }

  .admin-rank {
    grid-area: rank;
  }

  .admin-photo {
    grid-area: photo;
    width: 52px;
    height: 62px;
  }

  .admin-identity {
    grid-area: identity;
  }

  .admin-controls {
    grid-area: controls;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 9px;
    border-top: 1px solid rgba(177, 204, 226, 0.08);
  }

  .elected-toggle {
    order: -1;
    flex: 1 0 100%;
    justify-content: center;
  }

  .vote-total-input {
    flex: 1;
    width: auto;
    max-width: 180px;
  }

  .dashboard-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .dashboard-summary {
    width: 100%;
  }

  .dashboard-summary > div {
    flex: 1;
  }
}

@media (max-width: 620px) {
  .site-header,
  .results,
  .site-footer,
  .admin-header,
  .admin-main,
  .admin-footer {
    padding-inline: 16px;
  }

  .site-header {
    flex-direction: column;
    gap: 15px;
    padding-bottom: 15px;
  }

  .brand {
    align-items: flex-start;
    gap: 12px;
  }

  .brand h1 {
    font-size: clamp(1.45rem, 7vw, 1.95rem);
  }

  .header-metrics {
    width: 100%;
    flex-direction: row;
  }

  .metric {
    flex: 1;
    min-width: 0;
  }

  .metric--total {
    min-width: 0;
  }

  .results-heading {
    align-items: center;
  }

  .results-heading h2 {
    font-size: 15px;
  }

  .section-kicker {
    font-size: 9px;
  }

  .candidate-list {
    grid-template-rows: repeat(var(--candidate-count, 9), minmax(75px, auto));
  }

  .vote-cell strong {
    font-size: 25px;
  }

  .site-footer,
  .admin-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .admin-header {
    min-height: 66px;
  }

  .admin-brand small,
  .admin-header__actions .mode-chip,
  .admin-header__actions a {
    display: none;
  }

  .admin-header__actions {
    gap: 11px;
  }

  .auth-card {
    margin-top: 0;
  }

  .dashboard-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-summary > div {
    min-width: 0;
  }

  .dashboard-summary__elected {
    grid-column: 1 / -1;
  }

  .dashboard-summary strong {
    overflow: visible;
    font-size: 18px;
    line-height: 1.35;
    text-overflow: clip;
    white-space: normal;
  }

  .admin-toolbar > p:last-child {
    display: none;
  }

  .activity-panel {
    padding: 16px;
  }

  .admin-page .toast {
    top: 78px;
    right: 16px;
  }
}

@media (max-height: 800px) and (min-width: 821px) {
  .site-header {
    min-height: 96px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .metric {
    padding-block: 8px;
  }

  .metric time,
  .metric strong {
    font-size: 21px;
  }

  .results {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .results-heading {
    margin-bottom: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
