@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Noto+Sans+Thaana:wght@400;600;700&family=Public+Sans:wght@400;500;600;700&display=swap');

/* Electorium: an independent election desk.
   Teal ink + paper. Teal means "ours / free"; brass means "paid". Display type is a serif, body is a civic sans. */
:root {
  --bg: #f5f3ec;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --border: #dfe5de;
  --text: #17302d;
  --text-dim: #566b67;
  --ink: #0a2826;
  --ink-2: #123e39;
  --accent: #0d9488;
  --accent-2: #14b8a6;
  --accent-dim: #0f766e;
  --aqua: #5eead4;
  --brass: #8a5a00;
  --brass-bg: #fbf1dc;
  --brass-line: #ecd29a;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --warn-text: #b45309;
  --warn-border: #fde3c8;
  --danger: #b91c1c;
  --radius: 14px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "SF Mono", Consolas, "Cascadia Code", monospace;
  --side-w: 272px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body:not(.shell) { padding: clamp(16px, 4vw, 40px); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-2) 60%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ── App shell: sidebar + page ───────────────────────────────── */
body.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--ink); color: #cfe3df;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--ink-2); display: grid; place-items: center; color: var(--aqua); }
.brand .mark svg { width: 20px; height: 20px; }
.brand b { font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: -.01em; }
.brand small { display: block; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: #86a9a3; margin-top: -2px; }
.menu-btn { display: none; background: transparent; border: 1px solid #2c524d; color: #cfe3df; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.menu-btn:hover { background: var(--ink-2); }

.side-nav { flex: 1; }
.nav-group { margin: 0 0 18px; }
.nav-group h4 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 6px; padding: 0 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: #7fa39c;
}
.nav-pill { font-size: 9.5px; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.nav-pill.free { background: #164a44; color: var(--aqua); }
.nav-pill.paid { background: #3b2d0c; color: #f1c978; }
.nav-pill.on { background: #164a44; color: var(--aqua); }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0;
  color: #cfe3df; text-decoration: none; font-size: 14px; border-radius: 9px;
  border-inline-start: 3px solid transparent;
  transition: background-color .15s, color .15s;
}
.side-nav a:hover { background: #123733; color: #fff; }
.side-nav a.active { background: #15423d; color: #fff; border-inline-start-color: var(--aqua); font-weight: 600; }
.side-nav a .icon { width: 18px; height: 18px; flex: none; opacity: .9; }
.side-nav a .lock { margin-inline-start: auto; width: 14px; height: 14px; color: #f1c978; flex: none; }
.icon svg, .lock svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.side-foot { border-top: 1px solid #1d4540; padding: 14px 8px 0; margin-top: 8px; }
.me { font-size: 13px; margin-bottom: 10px; }
.me strong { display: block; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { color: #8fb1aa; font-size: 12px; }
.side-foot .btn-side {
  display: block; text-align: center; text-decoration: none; background: var(--aqua); color: var(--ink);
  font-weight: 700; font-size: 13.5px; padding: 9px 12px; border-radius: 9px; transition: transform .12s, background-color .15s;
}
.side-foot .btn-side:hover { background: #99f6e4; }
.side-foot .btn-side:active { transform: translateY(1px); }
.lang-toggle { margin-top: 10px; width: 100%; background: transparent; color: #cfe3df; border: 1px solid #2c524d; padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.lang-toggle:hover { background: var(--ink-2); }

main.page { padding: clamp(22px, 3.5vw, 44px) clamp(18px, 4vw, 56px) 90px; min-width: 0; max-width: 1260px; width: 100%; }

@media (max-width: 900px) {
  body.shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 50; height: auto; max-height: 100vh; padding: 10px 14px; }
  .side-head { padding-bottom: 0; }
  .menu-btn { display: inline-block; }
  .side-nav, .side-foot { display: none; }
  .side.open .side-nav { display: block; margin-top: 16px; }
  .side.open .side-foot { display: block; }
}

/* ── Page header ─────────────────────────────────────────────── */
header.page-head { display: block; margin: 0 0 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
header.page-head h1 {
  font-family: var(--display); font-weight: 600; font-size: clamp(28px, 4.2vw, 44px); line-height: 1.08;
  letter-spacing: -.02em; margin: 0 0 10px; color: var(--ink);
}
header.page-head .sub { max-width: 64ch; font-size: 16px; color: var(--text-dim); }
.kicker {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 14px; padding: 4px 11px 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.kicker .icon { width: 14px; height: 14px; }
.kicker.open { background: #e3ede9; color: var(--accent-dim); }
.kicker.account { background: #d2f4ed; color: #0b5e55; }
.kicker.paid { background: var(--brass-bg); color: var(--brass); border: 1px solid var(--brass-line); }
.kicker.admin { background: var(--ink); color: var(--aqua); }
.kicker .demo { opacity: .75; font-weight: 600; letter-spacing: .05em; }

/* ── Building blocks ─────────────────────────────────────────── */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 1px 2px rgba(10, 40, 38, .04);
}
.card h3 { margin: 0 0 6px; font-size: 11.5px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }

.stat { font-family: var(--display); font-size: clamp(30px, 5vw, 44px); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent-dim); transition: color .3s; line-height: 1.1; }
.stat.flash { color: var(--accent-2); }

.notice { background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent-2); border-radius: 10px; padding: 12px 16px; font-size: 14px; color: var(--text); margin-bottom: 22px; }
.muted { color: var(--text-dim); font-size: 13px; }
.scroll { overflow-x: auto; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; font-size: 13px; }
.chip strong { color: var(--accent-dim); font-variant-numeric: tabular-nums; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bar-label { width: 140px; flex-shrink: 0; font-size: 13px; color: var(--text-dim); }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 22px; overflow: hidden; position: relative; border: 1px solid var(--border); }
.bar-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); height: 100%; transition: transform .5s ease, width .5s ease; }
.bar-value { width: 130px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.bar-value.suppressed { color: var(--text-dim); font-style: italic; }

button, .btn {
  background: var(--accent); color: #fff; border: 1px solid transparent; border-radius: 10px; padding: 11px 18px;
  font: 600 15px/1.2 var(--font); cursor: pointer; text-decoration: none; display: inline-block;
  transition: background-color .15s, transform .1s;
}
button:hover, .btn:hover { background: var(--accent-dim); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary, .btn.secondary { background: var(--surface); color: var(--accent-dim); border-color: var(--accent-dim); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.brass, .btn.brass { background: var(--brass); color: #fff; }
button.brass:hover, .btn.brass:hover { background: #6f4800; }

select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=search] {
  background: var(--surface); color: var(--text); border: 1px solid #cfd8d3; border-radius: 10px;
  padding: 10px 12px; font: 15px var(--font); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 30%, transparent); }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field { margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
td.mono { font-family: var(--mono); color: var(--text-dim); }

.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.status-pill.verified { background: #ccfbf1; color: var(--accent-dim); }
.status-pill.pending { background: #fef3c7; color: var(--warn); }
.status-pill.rejected { background: #fee2e2; color: var(--danger); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 10px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: opacity .3s; pointer-events: none; box-shadow: 0 6px 20px rgba(10, 40, 38, .25);
}
.toast.show { opacity: 1; }

/* ── Locked / tiers ──────────────────────────────────────────── */
.lock-card {
  display: grid; grid-template-columns: 56px 1fr; gap: 20px; max-width: 760px;
  background: var(--surface); border: 1px solid var(--brass-line); border-radius: var(--radius); padding: 28px;
  box-shadow: 0 1px 0 var(--brass-line), 0 14px 30px -18px rgba(138, 90, 0, .35);
}
.lock-badge { width: 56px; height: 56px; border-radius: 16px; background: var(--brass-bg); color: var(--brass); display: grid; place-items: center; }
.lock-badge svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lock-card h2 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 0; letter-spacing: -.01em; color: var(--ink); }
.lock-card p { margin: 0; color: var(--text-dim); }
.lock-card ul { margin: 10px 0 4px; padding-inline-start: 18px; font-size: 14px; }
.lock-card li { margin: 5px 0; }
.lock-card .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.lock-card .free-note { font-size: 13px; color: var(--accent-dim); margin-top: 14px; }
@media (max-width: 600px) { .lock-card { grid-template-columns: 1fr; } }

.tiers { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: stretch; }
.tier { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 22px 20px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.tier::before { content: ""; position: absolute; inset-inline: 0; top: 0; height: 5px; background: var(--ink); }
.tier.account::before { background: var(--accent-2); }
.tier.paid { background: #fffdf8; border-color: var(--brass-line); }
.tier.paid::before { background: var(--brass); }
.tier .tag { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.tier.paid .tag { color: var(--brass); }
.tier .tag .icon { width: 14px; height: 14px; }
.tier h2 { font-family: var(--display); font-weight: 600; font-size: 23px; margin: 8px 0 6px; letter-spacing: -.01em; color: var(--ink); }
.tier p { margin: 0 0 12px; color: var(--text-dim); font-size: 14px; }
.tier ul { list-style: none; margin: 0 0 16px; padding: 0; font-size: 14px; flex: 1; }
.tier li { padding: 10px 0; border-top: 1px solid var(--border); display: block; }
.tier li a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--accent-2); }
.tier li a:hover { color: var(--accent-dim); }
.tier li span { display: block; color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.tier.paid li a { border-bottom-color: var(--brass-line); }
.tier .go { margin-top: auto; }

/* ── Bilingual / RTL ─────────────────────────────────────────── */
:root[lang="dv"] body, [lang="dv"] { font-family: "Noto Sans Thaana", var(--font); }
:root[lang="dv"] header.page-head h1, :root[lang="dv"] .brand b, :root[lang="dv"] .tier h2, :root[lang="dv"] .lock-card h2 { font-family: "Noto Sans Thaana", var(--display); }
/* Thaana needs more leading than Latin at the same point size */
[dir="rtl"] body { line-height: 1.9; }
[dir="rtl"] .bar-row { flex-direction: row-reverse; }
[dir="rtl"] .bar-value { text-align: left; }
[dir="rtl"] td, [dir="rtl"] th { text-align: right; }
[dir="rtl"] .next-list li { grid-template-columns: 1fr 28px; }

.draft-banner {
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; margin: -10px 0 22px;
}
.draft-banner[hidden] { display: none; }

/* ── Candidate/option avatars ────────────────────────────────── */
.avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.avatar-fallback { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.option-row { display: flex; align-items: center; gap: 10px; }

.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
