:root {
  --ink: #1b2433;
  --muted: #5d6878;
  --line: #e2e6ec;
  --bg: #f6f7f9;
  --card: #fff;
  --navy: #1f3a5f;
  --navy-2: #2c4f7c;
  --gold: #f2b53a;
  --green: #2f7d4f;
  --green-bg: #e7f4ec;
  --red: #b3372f;
  --red-bg: #fbeceb;
  --amber-bg: #fdf4e1;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.loading { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Top bar */
.top { background: var(--navy); color: #fff; }
.top-in { max-width: 1040px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand img { width: 28px; height: 28px; }
.brand small { font-weight: 400; opacity: .8; }
.nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
.nav a { color: #dfe7f2; text-decoration: none; padding: .4rem .7rem; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.who a, .who button { color: #dfe7f2; }

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* Cards and lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.grid .card { margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.grid .card .grow { flex: 1; }
.club-link { text-decoration: none; color: inherit; }
.club-link:hover .card { border-color: var(--navy-2); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: .6rem 0; border-top: 1px solid var(--line); display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 10rem; }
.list select, .row select, .row input[type=text] { width: auto; }
.post { border-top: 1px solid var(--line); padding: .75rem 0; }
.post:first-child { border-top: 0; padding-top: 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Tags */
.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #eef1f5; color: var(--muted); font-weight: 600; }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.amber { background: var(--amber-bg); color: #8a5a00; }
.tag.navy { background: var(--navy); color: #fff; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: .75rem 0 .25rem; }
label.check { font-weight: 400; display: flex; gap: .5rem; align-items: center; margin: .35rem 0; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid #c9d0da; border-radius: 8px; background: #fff; color: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(44,79,124,.35); outline-offset: 1px; }
.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: .5rem 1rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--navy-2); }
button.ghost, .btn.ghost { background: #fff; color: var(--navy); border-color: #c9d0da; }
button.ghost:hover { background: #f0f3f7; }
button.danger { background: #fff; color: var(--red); border-color: #e3b6b2; }
button.danger:hover { background: var(--red-bg); }
button.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; font-weight: 400; }
button.small, .btn.small { padding: .25rem .65rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.msg { padding: .6rem .8rem; border-radius: 8px; margin: .75rem 0; }
.msg.err { background: var(--red-bg); color: var(--red); }
.msg.ok { background: var(--green-bg); color: var(--green); }
.msg.info { background: var(--amber-bg); color: #6b4700; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; overflow-x: auto; }
.tabs button { background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: .5rem .8rem; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--gold); }

/* Sign-in */
.signin { max-width: 420px; margin: 4rem auto; padding: 0 1rem; }
.signin .brand { color: var(--navy); font-size: 1.3rem; margin-bottom: 1rem; }

/* Election stages */
.stages { display: flex; gap: 0; margin: 1rem 0 1.5rem; counter-reset: s; overflow-x: auto; }
.stages li { list-style: none; flex: 1; min-width: 90px; text-align: center; font-size: .8rem; color: var(--muted); position: relative; padding-top: 1.8rem; }
.stages li::before { counter-increment: s; content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #e3e7ee; line-height: 1.5rem; font-weight: 700; }
.stages li::after { content: ""; position: absolute; top: .72rem; left: calc(50% + .9rem); right: calc(-50% + .9rem); height: 2px; background: #e3e7ee; }
.stages li:last-child::after { display: none; }
.stages li.done::before { background: var(--green); color: #fff; content: "✓"; }
.stages li.now { color: var(--ink); font-weight: 700; }
.stages li.now::before { background: var(--gold); color: var(--ink); }
.stages { padding: 0; }

.bar { height: .5rem; background: #e8ecf1; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--navy-2); }
.bar.win > span { background: var(--green); }
.result { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr 3rem; gap: .75rem; align-items: center; padding: .35rem 0; }
label.check.result { display: grid; margin: 0; }
.result .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.ballot label.check { padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; align-items: flex-start; }
.ballot label.check:has(input:checked) { border-color: var(--navy-2); background: #f1f5fb; }
.ballot input { margin-top: .3rem; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .5rem; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); border-top: 0; }
.table-wrap { overflow-x: auto; }

/* Slips */
.slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0; }
.slip { border: 1px dashed #8a94a3; padding: 1rem; break-inside: avoid; background: #fff; }
.slip .school { font-size: .8rem; color: var(--muted); }
.slip .nm { font-weight: 700; font-size: 1.05rem; margin: .2rem 0 .5rem; }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .75rem; margin: 0; }
.slip dt { font-size: .8rem; color: var(--muted); }
.slip dd { margin: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; letter-spacing: .06em; }
.slip .how { font-size: .75rem; color: var(--muted); margin-top: .5rem; }

@media print {
  .top, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  body, :root { background: #fff; }
  .slips { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .top-in { gap: .4rem 1rem; }
  .brand small { display: none; }
  .who { margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -.5rem; }
  .result { grid-template-columns: 1fr 3rem; }
  .result .bar { grid-column: 1 / -1; grid-row: 2; }
}
