@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Roboto:wght@400;500;700&family=Roboto+Mono:wght@500&display=swap');

/* AIC brand, light only: white surfaces on a cool off-white page, navy for headings and structure,
   blue for information and links, green for the main action. Matches the printed certificate. */
:root {
  --navy: #000238; --blue: #00548f; --blue-light: #407fab; --green: #2a8145; --green-dark: #226a38; --green-light: #5fa173;
  --bg: #f4f6f8; --card: #ffffff; --fg: #2c3d49; --heading: #000238; --muted: #5d6b76; --line: #e1e6ea; --line-strong: #c5ced5;
  --tint: #f4f6f8; --error: #a52019; --error-bg: #fdf0ef; --error-line: #f1c3bf; --ok-bg: #edf6f0; --ok-fg: #1f6234; --ok-line: #bfdcc8;
  --code-bg: #eef2f5; --shadow: 0 1px 2px rgba(0, 2, 56, 0.05), 0 6px 20px rgba(0, 2, 56, 0.06);
  --display: 'Poppins', 'Segoe UI', sans-serif; --body: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.55 var(--body); min-height: 100vh }
a { color: var(--blue) }
h1, h2, h3 { font-family: var(--display); color: var(--heading); line-height: 1.2; margin: 0; text-wrap: balance }
h1 { font-size: 24px; font-weight: 600 }
h2 { font-size: 19px; font-weight: 600 }
h3 { font-size: 16px; font-weight: 600 }
p { margin: 0 }
:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 2px }

/* Header: logo on white, with the navy and green rule used on the certificate */
.top { background: #fff; border-bottom: 3px solid var(--navy); box-shadow: 0 2px 0 var(--green); margin-bottom: 2px; padding-block: 12px }
/* The header, main column and footer share one width and side gutter, so their left and right edges line up. */
.brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)) }
.wide .brand { max-width: 1100px }
.brand-logo { height: 48px; width: auto; display: block }
.brand-label { text-align: right; display: grid; gap: 1px }
.brand-label b { font: 600 14px/1.2 var(--display); color: var(--navy) }
.brand-label small { font-size: 12px; color: var(--muted) }

main { max-width: 560px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right)) }
main.wide { max-width: 1100px }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px 22px; display: grid; gap: 16px; box-shadow: var(--shadow) }
.stack { display: grid; gap: 16px }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0 }
legend { padding: 0; margin-bottom: 10px }
.muted { color: var(--muted); font-size: 14px }

.field { display: grid; gap: 6px }
.field label, .label { font: 500 14px/1.3 var(--display); color: var(--heading) }
input[type=text], input[type=email], input[type=number], input[type=datetime-local], input[type=date], input[type=url], input[type=password], textarea, select {
  font: 400 17px var(--body); padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--fg); width: 100%
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); outline: 3px solid rgba(0, 84, 143, 0.15); outline-offset: 0 }
input::placeholder { color: #98a4ad }
textarea { font-size: 14px; font-family: var(--mono); min-height: 140px }
input.otp { font: 500 30px var(--mono); letter-spacing: 0.4em; text-align: center }
input[type=file] { font: 15px var(--body); color: var(--fg) }

button, .btn { font: 600 16px var(--display); padding: 13px 20px; border-radius: 6px; border: 1px solid var(--green); background: var(--green); color: #fff; cursor: pointer; min-height: 50px; width: 100%; text-decoration: none; display: inline-flex; align-items: center; justify-content: center }
button:hover { background: var(--green-dark); border-color: var(--green-dark) }
button[disabled] { opacity: 0.45; cursor: not-allowed }
button.secondary, .btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--line-strong) }
button.secondary:hover, .btn.secondary:hover { background: var(--tint); border-color: var(--navy) }
button.link { background: none; border: 0; color: var(--blue); min-height: 0; padding: 4px 0; width: auto; font: 500 15px var(--body); text-decoration: underline }
.row { display: flex; gap: 12px; flex-wrap: wrap }
.row > * { flex: 1 1 200px }

.alert { border-radius: 6px; padding: 12px 14px; font-size: 15px; border: 1px solid transparent }
.alert.error { background: var(--error-bg); color: var(--error); border-color: var(--error-line) }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line) }

.holding { background: var(--tint); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; display: grid; gap: 2px }
.holding .label { font: 400 13px var(--body); color: var(--muted) }
.holding b { font: 600 17px var(--display); color: var(--heading) }

.option { display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; min-height: 68px; background: #fff }
.option:hover { border-color: var(--blue-light) }
.option input { width: 24px; height: 24px; accent-color: var(--green); flex: none; margin: 0 }
.option b { font: 600 17px var(--display); color: var(--heading); display: block }
.option.selected { border-color: var(--green); background: var(--ok-bg); box-shadow: inset 0 0 0 1px var(--green) }
.option .desc { font-size: 14px; color: var(--muted) }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px }
.check input { width: 22px; height: 22px; accent-color: var(--green); flex: none; margin-top: 2px }

.step-label { font: 600 12px var(--display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--blue) }
.code-box { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; overflow: hidden }
.code-box:focus-within { border-color: var(--blue); outline: 3px solid rgba(0, 84, 143, 0.15) }
.code-box .prefix { display: flex; align-items: center; padding: 0 4px 0 14px; font: 500 26px var(--mono); color: var(--heading); background: var(--tint); border-right: 1px solid var(--line) ; padding-right: 10px }
.code-box input { border: 0; outline: 0; padding-left: 12px; font: 500 26px var(--mono); letter-spacing: 0.12em }
.code-box input:focus { outline: 0 }
.tip { display: grid; gap: 6px; background: var(--tint); border: 1px solid var(--line); border-radius: 6px; padding: 14px; font-size: 15px }
.tip .link { justify-self: start; font-size: 16px }
body:not(.wide) main { display: grid; gap: 16px; align-content: start }
.help { display: grid; gap: 4px; font-size: 15px; padding: 20px 22px; border-radius: 10px; background: #fff; border: 1px solid var(--line) }
.help b { font: 600 15px var(--display); color: var(--heading) }
select { appearance: auto }
.receipt { font: 500 24px var(--mono); letter-spacing: 0.08em; background: var(--tint); border: 1px solid var(--line); color: var(--heading); text-align: center; padding: 14px; border-radius: 6px }
.done-mark { width: 60px; height: 60px; border-radius: 50%; background: var(--green); display: grid; place-items: center }
footer.site { max-width: 560px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); font-size: 13px; color: var(--muted) }
.wide + footer.site, body.wide footer.site { max-width: 1100px }

/* Staff pages */
.wide button { width: auto }
.wide h1 { font-size: 22px }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff }
table { border-collapse: collapse; width: 100%; font-size: 14px }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle }
tbody tr:last-child td { border-bottom: 0 }
tbody tr:hover td { background: #fafbfc }
th { font: 600 11px var(--display); text-transform: uppercase; letter-spacing: 0.08em; color: var(--navy); background: var(--tint) }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums }
tfoot td { font-weight: 700; color: var(--navy); background: var(--tint); border-top: 2px solid var(--navy); border-bottom: 0 }
.row > .btn { flex: 0 0 auto; width: auto; align-self: center; min-height: 42px; padding: 8px 16px; font-size: 14px }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px }
.stat b { display: block; font: 600 22px var(--display); color: var(--heading); font-variant-numeric: tabular-nums }
.stat span { font-size: 13px; color: var(--muted) }
.pill { display: inline-block; font: 600 11px var(--display); text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 9px; border-radius: 999px; background: var(--code-bg); color: var(--muted); border: 1px solid var(--line) }
.pill.open { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line) }
.pill.counted { background: #e6eef6; color: var(--blue); border-color: #c4d6e8 }
code, .mono { font-family: var(--mono); font-size: 13px; word-break: break-all }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line) }
.tabs button { background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0; min-height: 44px; padding: 8px 14px; font-size: 14px; margin-bottom: -1px }
.tabs button:hover { background: transparent; color: var(--navy) }
.tabs button[aria-selected=true] { color: var(--navy); border-bottom-color: var(--green) }
details summary { cursor: pointer; color: var(--blue) }

@media (prefers-reduced-motion: no-preference) { button, .option { transition: background 150ms, border-color 150ms, color 150ms } }
@media (max-width: 480px) { .brand-logo { height: 40px } .brand-label small { display: none } }

/* Certificate of postal votes: an A4 document in AIC branding, always light, on screen and in print. */
.certificate {
  --c-navy: #000238; --c-blue: #00548f; --c-green: #2a8145; --c-ink: #1d2a33; --c-muted: #5d6b76; --c-line: #d5dbe0; --c-tint: #f3f6f8;
  background: #fff; color: var(--c-ink); font: 13.5px/1.55 var(--body); padding: 40px 44px; display: grid; gap: 22px;
  max-width: 210mm; margin: 0 auto; box-shadow: 0 2px 12px rgba(0, 2, 56, 0.25); border-radius: 4px;
}
.certificate h2, .certificate h3 { color: var(--c-navy); text-wrap: balance }
.cert-draft { background: #fdecea; color: #8c1d18; border: 1px solid #f2b8b5; padding: 8px 12px; border-radius: 4px; font: 600 13px var(--display); text-align: center }
.cert-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 3px solid var(--c-navy); position: relative }
.cert-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 2px; background: var(--c-green) }
.cert-logo { width: 180px; height: auto; flex: none }
.cert-head-meta { display: grid; gap: 2px }
.cert-eyebrow { font: 600 10.5px var(--display); letter-spacing: 0.22em; text-transform: uppercase; color: var(--c-blue) }
.cert-title { font: 700 26px/1.15 var(--display); margin: 0 }
.cert-sub { font: 500 15px var(--display); color: var(--c-ink) }
.cert-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--c-line); border: 1px solid var(--c-line); border-radius: 4px; overflow: hidden }
.cert-field { background: var(--c-tint); padding: 8px 10px; display: grid; gap: 1px }
.cert-field span, .cert-stat span { font-size: 11px; color: var(--c-muted) }
.cert-field b { font: 600 12.5px var(--display); color: var(--c-navy) }
.cert-section { display: grid; gap: 10px }
.cert-section h3 { font: 600 11.5px var(--display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--c-blue); padding-bottom: 5px; border-bottom: 1px solid var(--c-line) }
.certificate .result { background: var(--c-tint); border: 1px solid var(--c-line); border-radius: 4px; padding: 12px 14px; font-size: 14px }
.certificate .result strong { color: var(--c-navy); font-family: var(--display); font-weight: 600 }
.certificate .tbl { border: 1px solid var(--c-line); border-radius: 4px; overflow: hidden }
.certificate table { font-size: 12.5px }
.certificate th { background: var(--c-navy); color: #fff; font: 600 10.5px var(--display); letter-spacing: 0.08em; padding: 8px 10px }
.certificate td { padding: 7px 10px; border-bottom: 1px solid var(--c-line); color: var(--c-ink) }
.certificate tbody tr:nth-child(even) td { background: #fafbfc }
.certificate tfoot td { font-weight: 700; color: var(--c-navy); background: var(--c-tint); border-top: 2px solid var(--c-navy); border-bottom: 0 }
.cert-note { font-size: 11.5px; color: var(--c-muted) }
.cert-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
.cert-stat { border: 1px solid var(--c-line); border-radius: 4px; padding: 10px 12px; display: grid; gap: 2px }
.cert-stat b { font: 700 22px var(--display); color: var(--c-navy); font-variant-numeric: tabular-nums }
.cert-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding-top: 18px }
.cert-sign { display: grid; gap: 4px; font-size: 11.5px; color: var(--c-muted) }
.cert-sign-line { border-bottom: 1px solid var(--c-ink); height: 34px }
.cert-sign-row { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px }
.cert-sign-row span:last-child { min-width: 40%; border-top: 1px solid transparent }
.cert-evidence dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: 10.5px }
.cert-evidence dt { color: var(--c-muted) }
.cert-evidence dd.plain { font-family: var(--body); font-size: 10.5px }
.cert-evidence dd { margin: 0; font-family: var(--mono); font-size: 10px; word-break: break-all; color: var(--c-ink) }
.cert-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 10.5px; color: var(--c-muted); border-top: 1px solid var(--c-line); padding-top: 8px }
@media (max-width: 700px) { .certificate { padding: 22px 18px } .cert-head { flex-direction: column-reverse; align-items: flex-start } .cert-fields, .cert-stats, .cert-signs { grid-template-columns: 1fr 1fr } }

@page { size: A4; margin: 14mm 14mm 16mm; @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 9pt Roboto, Arial, sans-serif; color: #5d6b76 } }
@media print {
  body { background: #fff !important }
  body * { visibility: hidden }
  .certificate, .certificate * { visibility: visible }
  .certificate { position: absolute; left: 0; top: 0; width: 100%; max-width: none; box-shadow: none; border-radius: 0; padding: 0; gap: 16px }
  .certificate .tbl { overflow: visible }
  .certificate tr, .cert-signs, .cert-stat, .cert-field { break-inside: avoid }
  .cert-section h3 { break-after: avoid }
  .certificate thead { display: table-header-group }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact }
}
