:root {
  --navy-950: #071b3c;
  --navy-900: #0a2b63;
  --navy-800: #123a76;
  --navy-100: #e8eef7;
  --gold-600: #c68700;
  --gold-500: #df9f08;
  --gold-100: #fff3cf;
  --ink: #172033;
  --muted: #5d6879;
  --line: #d9e0ea;
  --surface: #ffffff;
  --background: #f4f7fb;
  --success: #12623d;
  --success-bg: #e7f6ee;
  --danger: #9d2635;
  --danger-bg: #fdecef;
  --warning: #7a5200;
  --warning-bg: #fff4d5;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(7, 27, 60, 0.1);
}

* { box-sizing: border-box; }

html { color-scheme: light; font-size: 16px; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(223, 159, 8, 0.08), transparent 28rem),
    var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a { color: var(--navy-800); }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--navy-950);
  color: white;
  border-radius: .5rem;
}
.skip-link:focus { top: 1rem; }

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 22px rgba(7, 27, 60, .05);
}
.site-header a { display: block; max-width: 1180px; margin: 0 auto; padding: 1rem 1.5rem; }
.site-header img { width: min(100%, 980px); margin: 0 auto; }

.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2.25rem 0 4rem; }
.page-shell.narrow { width: min(700px, calc(100% - 2rem)); }

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.75rem, 5vw, 3.75rem);
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  width: 17rem;
  height: 17rem;
  right: -6rem;
  bottom: -9rem;
  border: 2.2rem solid rgba(223, 159, 8, .7);
  transform: rotate(45deg);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { max-width: 850px; margin: .35rem 0 1rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1.08; }
.hero p { max-width: 760px; margin: 0; font-size: clamp(1rem, 2vw, 1.22rem); color: #e9eef7; }
.hero .slogan { margin-top: 1.5rem; color: #fff2c8; font-weight: 700; }

.eyebrow { margin: 0; color: var(--gold-600); font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero .eyebrow { color: #ffd77b; }

h1, h2, h3 { line-height: 1.2; }
h2 { color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.5rem, 3vw, 2.2rem); }

.section-heading { margin: 2.4rem 0 1rem; }
.section-heading p { margin: .35rem 0 0; color: var(--muted); }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.choice-card {
  display: flex;
  flex-direction: column;
  padding: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--navy-900);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(7, 27, 60, .07);
}
.choice-card--official { border-top-color: var(--gold-500); }
.choice-card h3 { margin: .7rem 0 .45rem; color: var(--navy-950); font-size: 1.35rem; }
.choice-card p { color: var(--muted); }
.choice-card .button { margin-top: auto; }

.status-pill { align-self: flex-start; display: inline-flex; gap: .45rem; align-items: center; padding: .35rem .65rem; border-radius: 99px; background: var(--navy-100); color: var(--navy-900); font-size: .8rem; font-weight: 800; }
.status-pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.status-pill--open { background: var(--success-bg); color: var(--success); }
.status-pill--closed { background: #eef0f3; color: #4c5667; }

.panel { padding: clamp(1.25rem, 4vw, 2rem); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1.25rem; }
.panel h1 { margin: .4rem 0 .75rem; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 4vw, 2.65rem); }
.panel h2 { margin-top: 0; }

.event-summary { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: center; }
.event-summary p { margin: .35rem 0; }
.event-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }

.button {
  appearance: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: .75rem 1.2rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(223, 159, 8, .45); outline-offset: 2px; }
.button--primary { background: var(--navy-900); color: #fff; box-shadow: 0 8px 18px rgba(10, 43, 99, .18); }
.button--gold { background: var(--gold-500); color: var(--navy-950); }
.button--secondary { border-color: var(--navy-900); background: #fff; color: var(--navy-900); }
.button--quiet { min-height: 40px; padding: .5rem .8rem; background: #edf1f7; color: var(--navy-900); }
.button[disabled] { cursor: not-allowed; opacity: .55; transform: none; }

.notice, .flash { padding: 1rem 1.1rem; border-radius: .8rem; margin: 1rem 0; }
.notice--success, .flash--success { color: var(--success); background: var(--success-bg); border: 1px solid #bce3cd; }
.notice--error, .flash--error { color: var(--danger); background: var(--danger-bg); border: 1px solid #f2c5cd; }
.notice--warning, .flash--warning { color: var(--warning); background: var(--warning-bg); border: 1px solid #ecd99f; }
.flash { width: min(900px, calc(100% - 2rem)); margin: 1rem auto 0; }

.form-stack { display: grid; gap: 1rem; }
.form-stack label { display: grid; gap: .4rem; font-weight: 750; color: var(--navy-950); }
input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #b9c4d2;
  border-radius: .7rem;
  background: #fff;
  color: var(--ink);
  padding: .7rem .8rem;
}
input:disabled, select:disabled { background: #eef1f5; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.form-help { margin: 0; color: var(--muted); font-size: .9rem; }
.auth-panel { margin-top: 1rem; }
.identity-name { padding: 1rem; border-radius: .8rem; background: var(--navy-100); color: var(--navy-950); font-size: 1.2rem; font-weight: 800; }

.privacy-note { margin-top: 1.25rem; padding: 1rem; border-left: 4px solid var(--gold-500); background: var(--gold-100); color: #554019; }

.candidate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .8rem; margin: 1.25rem 0 2rem; }
.candidate-card { overflow: hidden; border: 1px solid var(--line); border-radius: .85rem; background: #fff; }
.candidate-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 35%; background: #eef1f5; }
.candidate-card__body { padding: .65rem; }
.candidate-card strong { display: block; color: var(--navy-950); font-size: .88rem; line-height: 1.25; }
.candidate-card span { display: block; margin-top: .2rem; color: var(--muted); font-size: .75rem; }

.ballot-header { position: sticky; top: 0; z-index: 10; padding: .8rem 1rem; margin: 0 0 1rem; background: rgba(244, 247, 251, .96); border: 1px solid var(--line); border-radius: .8rem; backdrop-filter: blur(8px); }
.progress-track { overflow: hidden; height: .65rem; border-radius: 99px; background: #dfe5ed; }
.progress-value { width: 0; height: 100%; background: linear-gradient(90deg, var(--navy-800), var(--gold-500)); transition: width .2s ease; }
.progress-value[data-count="1"] { width: 10%; }
.progress-value[data-count="2"] { width: 20%; }
.progress-value[data-count="3"] { width: 30%; }
.progress-value[data-count="4"] { width: 40%; }
.progress-value[data-count="5"] { width: 50%; }
.progress-value[data-count="6"] { width: 60%; }
.progress-value[data-count="7"] { width: 70%; }
.progress-value[data-count="8"] { width: 80%; }
.progress-value[data-count="9"] { width: 90%; }
.progress-value[data-count="10"] { width: 100%; }
.progress-label { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; font-weight: 700; }

.ranking-list { display: grid; gap: .8rem; }
.ranking-row { display: grid; grid-template-columns: 5.4rem 1fr 4rem; gap: 1rem; align-items: center; padding: .9rem; border: 1px solid var(--line); border-radius: .9rem; background: #fff; }
.ranking-position { color: var(--navy-950); font-weight: 900; text-align: center; }
.ranking-position span { display: block; font-size: 1.5rem; }
.ranking-preview { width: 3.7rem; height: 3.7rem; border-radius: .65rem; object-fit: cover; object-position: 50% 35%; background: #e6eaf0; }
.ranking-preview.is-empty { opacity: .25; }

.ballot-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.offline-notice { display: none; }
.offline .offline-notice { display: block; }

dialog { width: min(620px, calc(100% - 2rem)); border: 0; border-radius: 1rem; padding: 0; box-shadow: 0 24px 80px rgba(7, 27, 60, .3); }
dialog::backdrop { background: rgba(7, 27, 60, .62); }
.dialog-body { padding: 1.5rem; }
.dialog-body h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1rem; }
.confirmation-list { max-height: 48vh; overflow: auto; margin: 1rem 0; padding-left: 1.6rem; }
.confirmation-list li { padding: .25rem 0; }

.receipt { text-align: center; }
.receipt-mark { width: 4rem; height: 4rem; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; background: var(--success-bg); color: var(--success); font-size: 2rem; font-weight: 900; }
.receipt-code { display: inline-block; padding: .7rem 1rem; border: 1px dashed var(--navy-800); border-radius: .7rem; background: var(--navy-100); color: var(--navy-950); font-weight: 900; letter-spacing: .08em; }

.admin-bar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.admin-bar p { margin: 0; }
.admin-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin: 1rem 0 1.5rem; }
.stat-card { padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: #fff; }
.stat-card span { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; }
.stat-card strong { display: block; margin-top: .2rem; color: var(--navy-950); font-size: 1.8rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--navy-900); color: #fff; font-weight: 800; }
td.number { text-align: center; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.table-note { color: var(--muted); font-size: .9rem; }
.export-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin: 1rem 0; }

.site-footer { padding: 1.25rem 1rem 2.5rem; color: #748095; text-align: center; font-size: .78rem; }
.site-footer p { margin: 0; }

@media (max-width: 900px) {
  .candidate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 1rem, 1180px); padding-top: 1rem; }
  .site-header a { padding: .7rem .8rem; }
  .choice-grid { grid-template-columns: 1fr; }
  .event-summary { grid-template-columns: 1fr; }
  .event-actions { justify-content: flex-start; }
  .candidate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ranking-row { grid-template-columns: 4.2rem 1fr 3.2rem; gap: .6rem; padding: .65rem; }
  .ranking-preview { width: 3rem; height: 3rem; }
  .ballot-actions { align-items: stretch; flex-direction: column-reverse; }
  .ballot-actions .button { width: 100%; }
  .admin-bar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .hero { border-radius: 18px; }
  .candidate-grid { gap: .55rem; }
  .candidate-card__body { padding: .5rem; }
  .ranking-row { grid-template-columns: 3.4rem 1fr; }
  .ranking-preview { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { background: #fff; }
  .site-header, .site-footer, .button, .admin-bar, .export-actions { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  th { position: static; background: #ddd !important; color: #000 !important; }
}
