:root {
  --blue: #02529c;
  --blue-dark: #013a70;
  --navy: #0b1f3a;
  --red: #dc1e35;
  --paper: #fffdf8;
  --bg: #eef2f7;
  --ink: #14213a;
  --muted: #5b6880;
  --line: #d5dce8;
  --ok: #17794a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Roboto', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'Roboto Slab', Georgia, serif; margin: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--blue); }

/* flag ribbon */
.ribbon {
  height: 10px;
  background: linear-gradient(to bottom,
    var(--blue) 0 30%, #fff 30% 40%, var(--red) 40% 60%, #fff 60% 70%, var(--blue) 70% 100%);
}

.masthead { background: var(--navy); color: #fff; }
.masthead-inner {
  max-width: 1100px; margin: 0 auto; padding: 18px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.seal { width: 58px; height: 58px; flex: none; }
.masthead .titles { flex: 1; min-width: 220px; }
.masthead .is { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: #a9bddb; }
.masthead h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
.masthead .sub { font-size: 14px; color: #c9d6ea; }

.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.userbox img, .avatar-fallback { width: 34px; height: 34px; border-radius: 50%; background: #2a436b; }
.avatar-fallback { display: grid; place-items: center; font-weight: 700; }
.userbox .who { line-height: 1.2; }
.userbox .who small { display: block; color: #a9bddb; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 6px;
  padding: 10px 16px; font-weight: 500; text-decoration: none;
  background: var(--blue); color: #fff;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.discord { background: #5865f2; }
.btn.discord:hover { background: #4752c4; }
.btn.ghost { background: transparent; border-color: #5a7099; color: #fff; padding: 7px 12px; font-size: 13px; }
.btn.ghost:hover { background: #17325a; }
.btn.light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.light:hover { background: #f1f4f9; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b3162a; }
.btn.small { padding: 6px 10px; font-size: 13px; }

main { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; }

.notice {
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--blue);
  border-radius: 6px; padding: 14px 18px; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.notice.warn { border-left-color: var(--red); }
.notice p { margin: 0; }
.notice small { color: var(--muted); }

.ballots { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .ballots { grid-template-columns: 1fr; } }

.ballot {
  background: var(--paper); border: 1px solid #cfd6e2; border-radius: 4px;
  box-shadow: 0 1px 2px rgba(11,31,58,.06), 0 8px 24px rgba(11,31,58,.07);
  position: relative; overflow: hidden;
}
.ballot-head { padding: 20px 22px 14px; border-bottom: 3px double var(--ink); text-align: center; }
.ballot-head .kicker { font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
.ballot-head h2 { font-size: 23px; margin: 2px 0; }
.ballot-head .en { color: var(--muted); font-size: 14px; }
.status {
  display: inline-block; margin-top: 10px; padding: 3px 12px; border-radius: 99px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.status.open { background: #e2f4ea; color: var(--ok); }
.status.closed { background: #fbe4e7; color: #a5142a; }
.instruction { padding: 12px 22px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; }

.options { list-style: none; margin: 0; padding: 0; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 22px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; color: inherit;
}
.option:not(:disabled):hover { background: #f3f6fb; }
.option:disabled { cursor: default; }
.option.selected { background: #eaf2fc; }
.option.dim { opacity: .5; }
.logo {
  width: 54px; height: 54px; flex: none; border-radius: 8px; background: #fff;
  border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden;
  font-family: 'Roboto Slab', serif; font-weight: 700; font-size: 20px; color: #fff;
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.option .text { flex: 1; min-width: 0; }
.option .name { font-weight: 700; font-size: 17px; }
.option .subline { font-size: 14px; color: var(--muted); }
.box {
  width: 38px; height: 38px; flex: none; border: 2.5px solid var(--ink); border-radius: 3px;
  background: #fff; display: grid; place-items: center;
}
.box svg { width: 26px; height: 26px; opacity: 0; }
.option.selected .box svg { opacity: 1; }

.ballot-foot { padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ballot-foot .hint { font-size: 13px; color: var(--muted); }
.empty { padding: 34px 22px; text-align: center; color: var(--muted); }
.stamp {
  display: inline-flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 700;
  border: 2px solid var(--ok); border-radius: 4px; padding: 6px 12px; transform: rotate(-2deg);
  text-transform: uppercase; letter-spacing: .08em; font-size: 13px;
}

footer { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; color: var(--muted); font-size: 13px; text-align: center; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(11,31,58,.55); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal { background: #fff; border-radius: 8px; max-width: 440px; width: 100%; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { margin: 0 0 14px; }
.modal .choice { background: #f3f6fb; border: 1px solid var(--line); border-radius: 6px; padding: 12px; font-weight: 700; margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal input[type=text] { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; margin-bottom: 14px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 6px; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.err { background: #a5142a; }
[hidden] { display: none !important; }

/* ---------- admin ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 22px; margin-bottom: 22px; }
.panel > h2 { font-size: 20px; margin-bottom: 4px; }
.panel > .desc { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
}
.switch-row strong { display: block; }
.switch-row small { color: var(--muted); }

.result h3 { font-size: 17px; margin-bottom: 2px; }
.result .total { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.pie-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.pie { width: 190px; height: 190px; flex: none; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; }
.result table { flex: 1; min-width: 220px; }
.scroll { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.scroll th { position: sticky; top: 0; background: #f6f8fb; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }

.item-list { list-style: none; margin: 0 0 16px; padding: 0; }
.item-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-list .text { flex: 1; min-width: 0; }
.item-list .name { font-weight: 700; }
.item-list .subline { font-size: 13px; color: var(--muted); }
.item-list .logo { width: 42px; height: 42px; font-size: 16px; }

form.editor { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 12px; }
form.editor h3 { font-size: 15px; }
form.editor label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
form.editor input[type=text] { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
form.editor .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
form.editor .row > label { flex: 1; min-width: 150px; }
form.editor input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
form.editor .actions { display: flex; gap: 10px; }
