/* ==========================================================================
   Pilketos — design system
   Arah desain: surat suara cetak yang tenang. Kertas hangat, tinta gelap,
   satu warna hijau tua sebagai identitas, emas hanya untuk nomor urut.
   Tipografi: Fraunces (judul & angka), Plus Jakarta Sans (isi).
   ========================================================================== */

:root {
  --ink: #17211f;
  --ink-2: #4b5855;
  --ink-3: #75817e;
  --paper: #f5f3ee;
  --surface: #ffffff;
  --line: #ddd8cc;
  --line-soft: #ebe7dd;

  --brand: #0e5a4b;
  --brand-ink: #0a4136;
  --brand-soft: #e2eee9;
  --gold: #a87814;
  --gold-soft: #f6ecd0;

  --ok: #17703f;
  --ok-soft: #e1f1e7;
  --warn: #8f5f00;
  --warn-soft: #fbf0d4;
  --danger: #a8281f;
  --danger-soft: #fbe8e5;

  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;

  --r-sm: 6px;
  --r-md: 10px;
  --shadow-pop: 0 18px 48px -12px rgba(23, 33, 31, 0.28);

  --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.86rem);
  --step-0: clamp(0.94rem, 0.92rem + 0.1vw, 1rem);
  --step-1: clamp(1.1rem, 1.05rem + 0.25vw, 1.25rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.6rem);
  --step-4: clamp(2.1rem, 1.5rem + 3vw, 3.6rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-ink); }
button { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; border-radius: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-2); }
.small { font-size: var(--step--1); }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: var(--step--1); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.55rem 1.1rem;
  border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: var(--step-0); line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8a1f17; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0.35rem 0.8rem; font-size: var(--step--1); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn.danger { color: var(--danger); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 0.35rem; }
.field + .field { margin-top: 1.1rem; }
.field label, .label { font-weight: 600; font-size: var(--step--1); color: var(--ink); }
.hint { font-size: var(--step--1); color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 0.6rem 0.85rem;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #c9c3b5; border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: var(--step--1); font-weight: 500; }
.input-lg { min-height: 52px; font-size: 1.1rem; }
.input-mono { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.checkbox { display: flex; gap: 0.65rem; align-items: flex-start; }
.checkbox input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.form-grid { display: grid; gap: 1.1rem 1.25rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .field + .field { margin-top: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* ---------- Alerts, pills ---------- */
.alert { display: flex; gap: 0.75rem; padding: 0.8rem 1rem; border-radius: var(--r-md); border: 1px solid; font-size: var(--step-0); margin-bottom: 1.25rem; }
.alert svg { flex: none; margin-top: 2px; }
.alert-success { background: var(--ok-soft); border-color: #b5dcc3; color: #0f4d2b; }
.alert-error { background: var(--danger-soft); border-color: #f0c1bc; color: #7d1d16; }
.alert-info { background: var(--brand-soft); border-color: #bcd8cf; color: var(--brand-ink); }
.alert-warn { background: var(--warn-soft); border-color: #ecd59a; color: #5e3f00; }
.alert ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

.pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.6rem; border-radius: 4px; font-size: var(--step--1); font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-open { background: var(--ok-soft); color: var(--ok); }
.pill-draft, .pill-scheduled { background: var(--warn-soft); color: var(--warn); }
.pill-closed, .pill-ended { background: #ecebe6; color: var(--ink-2); }
.pill-done { background: var(--ok-soft); color: var(--ok); }
.pill-todo { background: #ecebe6; color: var(--ink-2); }

/* ==========================================================================
   Student shell
   ========================================================================== */
.student-shell { min-height: 100vh; display: flex; flex-direction: column; }
.student-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--surface); }
.brand-mark { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark .mark { width: 34px; height: 34px; flex: none; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.brand-mark .name { font-weight: 700; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark .sub { font-size: var(--step--1); color: var(--ink-3); display: block; font-weight: 500; }
.who { display: flex; align-items: center; gap: 0.9rem; font-size: var(--step--1); text-align: right; }
.who strong { display: block; font-size: var(--step-0); }
.student-main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 8rem; }
.student-foot { padding: 1.25rem clamp(1rem, 4vw, 2.5rem); font-size: var(--step--1); color: var(--ink-3); border-top: 1px solid var(--line); }

/* ---------- Login (split) ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-side { background: var(--brand-ink); color: #eaf3ef; padding: clamp(2rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: space-between; gap: 3rem; position: relative; overflow: hidden; }
.login-side::after { content: attr(data-year); position: absolute; right: -0.05em; bottom: -0.28em; font-family: var(--font-display); font-weight: 700; font-size: clamp(8rem, 22vw, 17rem); line-height: 1; color: rgba(255, 255, 255, 0.05); pointer-events: none; white-space: nowrap; }
.login-side .brand-mark .mark { background: #fff; color: var(--brand-ink); }
.login-side .brand-mark .sub { color: #a9c6bc; }
.login-head h1 { font-size: var(--step-4); color: #fff; max-width: 14ch; margin-top: 1rem; }
.login-head p { margin-top: 1.1rem; max-width: 40ch; color: #c5dad2; font-size: var(--step-1); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; position: relative; z-index: 1; }
.steps li { display: grid; grid-template-columns: 2.6rem 1fr; align-items: baseline; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.18); }
.steps .n { font-family: var(--font-display); font-weight: 600; color: #e7c978; font-size: 1.15rem; }
.steps strong { display: block; color: #fff; }
.steps span { color: #b9d2c9; font-size: var(--step--1); }
.login-form-wrap { display: grid; place-items: center; padding: clamp(2rem, 5vw, 4rem) clamp(1.25rem, 5vw, 4rem); }
.login-form { width: 100%; max-width: 410px; }
.login-form h2 { font-size: var(--step-2); }
.login-form .lead { margin: 0.5rem 0 1.75rem; color: var(--ink-2); }
.state-note { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1.5rem; padding: 0.65rem 0.85rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); font-size: var(--step--1); }
.login-help { margin-top: 1.5rem; font-size: var(--step--1); color: var(--ink-3); }

/* ---------- Ballot ---------- */
.page-head { max-width: 62ch; margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.page-head h1 { font-size: var(--step-3); }
.page-head p { margin-top: 0.7rem; color: var(--ink-2); font-size: var(--step-1); }
.rule-note { display: inline-flex; gap: 0.5rem; align-items: center; margin-top: 1rem; font-size: var(--step--1); color: var(--ink-2); }

.ballot-grid { display: grid; gap: clamp(1rem, 2.4vw, 1.75rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.ballot-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 880px; }
.cand { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.cand:hover { border-color: var(--ink-3); }
.cand-radio { position: absolute; opacity: 0; pointer-events: none; }
.cand-face { display: block; cursor: pointer; }
.cand-photo { position: relative; aspect-ratio: 4 / 4.6; background: var(--brand-soft); overflow: hidden; }
.cand-photo img { width: 100%; height: 100%; object-fit: cover; }
.cand-photo .initials { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: 4.5rem; color: color-mix(in srgb, var(--brand) 45%, white); }
.cand-no { position: absolute; top: 0; left: 0; min-width: 3.4rem; padding: 0.35rem 0.8rem 0.45rem; background: var(--gold); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1; border-bottom-right-radius: var(--r-md); }
.cand-check { position: absolute; top: 0.75rem; right: 0.75rem; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; transform: scale(0.6); opacity: 0; transition: transform .18s, opacity .18s; }
.cand-body { padding: 1rem 1.1rem 0.5rem; }
.cand-name { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; line-height: 1.2; }
.cand-vice { margin-top: 0.15rem; color: var(--ink-2); font-size: var(--step-0); }
.cand-vice::before { content: '& '; color: var(--ink-3); }
.cand-class { margin-top: 0.5rem; font-size: var(--step--1); color: var(--ink-3); }
.cand-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1.1rem 1.1rem; margin-top: auto; }
.btn-select { cursor: pointer; background: var(--surface); border-color: var(--brand); color: var(--brand); min-width: 7.5rem; }
.btn-select .on { display: none; }
.cand-radio:checked ~ .cand-face .cand-check { opacity: 1; transform: scale(1); }
.cand-radio:checked ~ .cand-actions .btn-select { background: var(--brand); color: #fff; }
.cand-radio:checked ~ .cand-actions .btn-select .on { display: inline; }
.cand-radio:checked ~ .cand-actions .btn-select .off { display: none; }
.cand:has(.cand-radio:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.cand:has(.cand-radio:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 3px; }

.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--ink); color: #fff; box-shadow: 0 -10px 30px rgba(23, 33, 31, 0.25); }
.action-bar-inner { max-width: 1180px; margin: 0 auto; padding: 0.85rem clamp(1rem, 4vw, 2.5rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.action-bar .eyebrow { color: #a9b6b2; }
.action-bar .picked { font-weight: 600; font-size: var(--step-1); }
.action-bar .btn-primary { background: #fff; color: var(--ink); }
.action-bar .btn-primary:hover { background: var(--gold-soft); }

/* dialogs */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(23, 33, 31, 0.55); }
.dlg { padding: 1.5rem 1.5rem 1.25rem; }
.dlg h2 { font-size: var(--step-2); }
.dlg-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.1rem; }
.dlg-no { flex: none; min-width: 3.2rem; height: 3.2rem; padding: 0 0.6rem; display: grid; place-items: center; border-radius: 8px; background: var(--gold); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.8rem; }
.dlg h3 { font-size: var(--step-0); font-family: var(--font-body); font-weight: 700; margin: 1.1rem 0 0.35rem; }
.dlg ol { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.4rem; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 1.5rem; }
.confirm-pick { margin: 1.1rem 0; padding: 1rem; border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; }
.confirm-pick strong { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.25; }

.waiting { max-width: 640px; padding: clamp(1.5rem, 4vw, 2.5rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.waiting h1 { font-size: var(--step-2); margin: 0.75rem 0 0.5rem; }

/* ---------- Thanks ---------- */
.thanks { max-width: 560px; margin: clamp(1rem, 6vw, 4rem) auto 0; text-align: center; }
.thanks-icon { width: 76px; height: 76px; margin: 0 auto 1.5rem; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; }
.thanks h1 { font-size: var(--step-3); }
.thanks p { margin-top: 0.8rem; color: var(--ink-2); font-size: var(--step-1); }
.thanks .meta { font-size: var(--step--1); color: var(--ink-3); }
.thanks-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin-top: 2rem; }
.countdown { margin-top: 1rem; font-size: var(--step--1); color: var(--ink-3); }

/* ==========================================================================
   Admin shell
   ========================================================================== */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: var(--ink); color: #d6dedb; padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.sidebar .brand-mark { padding: 0.25rem 0.5rem; color: #fff; }
.sidebar .brand-mark .sub { color: #8d9a96; }
.nav { display: grid; gap: 0.15rem; }
.nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.7rem; border-radius: 7px; color: #c3cdca; text-decoration: none; font-weight: 500; font-size: var(--step-0); }
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 600; }
.nav svg { flex: none; opacity: 0.85; }
.sidebar-foot { margin-top: auto; padding: 0.75rem 0.5rem 0; border-top: 1px solid rgba(255, 255, 255, 0.12); font-size: var(--step--1); }
.sidebar-foot a, .sidebar-foot .link-btn { color: #c3cdca; font-weight: 500; }
.sidebar-foot .link-btn { text-decoration: none; }
.sidebar-foot .link-btn:hover, .sidebar-foot a:hover { color: #fff; text-decoration: underline; }
.admin-top { display: none; }
.admin-main { padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2.75rem) 4rem; max-width: 1240px; width: 100%; }
.page-title { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-title h1 { font-size: var(--step-3); }
.page-title .sub { margin-top: 0.35rem; color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: var(--step-1); }
.panel-body { padding: 1.25rem; }
.panel + .panel { margin-top: 1.5rem; }
.panel.danger { border-color: #e6b8b3; }
.panel.danger .panel-head { background: var(--danger-soft); border-radius: var(--r-md) var(--r-md) 0 0; }

/* ---------- Dashboard ---------- */
.live-dot { display: inline-flex; align-items: center; gap: 0.45rem; font-size: var(--step--1); color: var(--ink-2); }
.live-dot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(23, 112, 63, 0.5); animation: pulse 2s infinite; }
.live-dot[data-state="error"]::before { background: var(--danger); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(23, 112, 63, 0); } 100% { box-shadow: 0 0 0 0 rgba(23, 112, 63, 0); } }

.figures { display: grid; grid-template-columns: 1.4fr 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.figure { padding: 1.25rem 1.4rem; }
.figure + .figure { border-left: 1px solid var(--line-soft); }
.figure .big { font-family: var(--font-display); font-size: var(--step-4); font-weight: 600; line-height: 1; margin-top: 0.4rem; font-variant-numeric: tabular-nums; }
.figure .big small { font-size: var(--step-1); font-weight: 500; color: var(--ink-3); font-family: var(--font-body); }
.meter { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; margin-top: 1rem; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .6s ease; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.5rem; margin-top: 1.5rem; align-items: start; }
.dash-grid .panel + .panel { margin-top: 0; }
.tally { list-style: none; margin: 0; padding: 0; }
.tally li { display: grid; grid-template-columns: 3rem minmax(0, 1fr) auto; gap: 0 1rem; align-items: center; padding: 1rem 1.25rem; }
.tally li + li { border-top: 1px solid var(--line-soft); }
.tally .no { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 8px; background: var(--gold-soft); color: var(--gold); font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; }
.tally .who-name { font-weight: 600; line-height: 1.25; }
.tally .lead-tag { display: none; margin-left: 0.5rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ok); }
.tally li.is-leading .lead-tag { display: inline; }
.tally .bar { grid-column: 2 / 3; height: 10px; margin-top: 0.55rem; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.tally .bar > span { display: block; height: 100%; background: #9fb8b0; border-radius: 5px; transition: width .6s ease, background-color .3s; }
.tally li.is-leading .bar > span { background: var(--brand); }
.tally .count { text-align: right; line-height: 1.1; }
.tally .count strong { font-family: var(--font-display); font-size: var(--step-2); font-variant-numeric: tabular-nums; }
.tally .count span { display: block; font-size: var(--step--1); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.empty { padding: 2rem 1.25rem; text-align: center; color: var(--ink-2); }

.class-table th, .class-table td { padding: 0.65rem 1.25rem; text-align: left; font-size: var(--step--1); }
.class-table th { color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; border-bottom: 1px solid var(--line-soft); }
.class-table tr + tr td { border-top: 1px solid var(--line-soft); }
.class-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.mini-bar { height: 6px; background: var(--line-soft); border-radius: 3px; margin-top: 0.35rem; overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .6s ease; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table th, .table td { padding: 0.75rem 1.1rem; text-align: left; vertical-align: middle; }
.table th { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); border-bottom: 1px solid var(--line); background: #faf9f5; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--line-soft); }
.table tbody tr:hover { background: #fbfaf6; }
.table .actions { text-align: right; white-space: nowrap; }
.table th.r { text-align: right; }
.table .actions > * + * { margin-left: 0.9rem; }
.table .actions form { display: inline; }
.action-group { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0.35rem; }
.action-group form { display: inline-flex; margin: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  text-decoration: none; cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.icon-btn.danger:hover { border-color: #e6b8b3; color: var(--danger); background: var(--danger-soft); }
.col-check { width: 42px; text-align: center !important; padding-left: 1rem !important; padding-right: 0.4rem !important; }
.check-input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1.25rem; background: var(--brand-soft); border-bottom: 1px solid #bcd8cf; font-size: var(--step--1); }
.bulk-bar[hidden] { display: none; }
.bulk-bar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.bulk-bar-actions form { display: inline-flex; margin: 0; }
.thumb { width: 48px; height: 58px; object-fit: cover; border-radius: 6px; background: var(--brand-soft); }
.thumb-ph { width: 48px; height: 58px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; }
.cell-no { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--gold); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.filters .input, .filters .select { min-height: 40px; width: auto; }
.filters .grow { flex: 1 1 220px; min-width: 180px; }
.filters .grow .input { width: 100%; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.9rem 1.25rem; font-size: var(--step--1); color: var(--ink-2); }
.pager ul { list-style: none; display: flex; gap: 0.3rem; margin: 0; padding: 0; }
.pager a, .pager span.current, .pager span.disabled, .pager span.gap { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 0.5rem; border-radius: 6px; text-decoration: none; border: 1px solid transparent; }
.pager a { color: var(--ink); border-color: var(--line); background: var(--surface); }
.pager a:hover { border-color: var(--ink-3); }
.pager .current { background: var(--brand); color: #fff; font-weight: 600; }
.pager .disabled, .pager .gap { color: var(--ink-3); }

/* ---------- Upload ---------- */
.dropzone { display: grid; gap: 0.35rem; justify-items: center; text-align: center; padding: 2rem 1rem; border: 2px dashed #c9c3b5; border-radius: var(--r-md); background: #faf9f5; cursor: pointer; transition: border-color .15s, background-color .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }
.dropzone .file-name { font-weight: 600; color: var(--brand); }
.cols-table { width: auto; margin-top: 0.5rem; font-size: var(--step--1); }
.cols-table th, .cols-table td { text-align: left; padding: 0.3rem 1.25rem 0.3rem 0; }
.cols-table th { color: var(--ink-3); font-weight: 600; }
.photo-field { display: flex; gap: 1rem; align-items: center; }
.photo-preview { width: 96px; height: 116px; object-fit: cover; border-radius: 8px; background: var(--brand-soft); flex: none; }

/* ---------- Results ---------- */
.winner { display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: center; padding: 1.5rem; border-radius: var(--r-md); background: var(--brand-ink); color: #fff; margin-bottom: 1.5rem; }
.winner .no { width: 4.5rem; height: 4.5rem; display: grid; place-items: center; border-radius: 10px; background: #e7c978; color: var(--brand-ink); font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; }
.winner h2 { font-size: var(--step-2); color: #fff; }
.winner p { color: #bcd5cb; margin-top: 0.25rem; }
.public-wrap { max-width: 860px; margin: 0 auto; }

/* ---------- Auth (admin login) ---------- */
.plain { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.plain-card { width: 100%; max-width: 410px; }
.plain-card .brand-mark { margin-bottom: 2rem; }
.plain-card h1 { font-size: var(--step-2); margin-bottom: 1.5rem; }

/* ---------- Voter cards (print) ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.voter-card { background: var(--surface); border: 1px dashed #b9b2a4; border-radius: var(--r-md); padding: 0.95rem 1.05rem; display: flex; flex-direction: column; gap: 0.7rem; break-inside: avoid; page-break-inside: avoid; }
.voter-card-head { display: flex; align-items: center; gap: 0.65rem; padding-bottom: 0.55rem; border-bottom: 1px solid var(--line); }
.voter-card-mark { width: 30px; height: 30px; flex: none; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.voter-card-title { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; text-transform: uppercase; line-height: 1.2; }
.voter-card-sub { font-size: 0.75rem; color: var(--ink-2); line-height: 1.25; }
.voter-card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 0.85rem; margin: 0; }
.voter-card-meta > div:first-child { grid-column: 1 / -1; }
.voter-card-meta dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.voter-card-meta dd { margin: 0.1rem 0 0; font-size: 0.92rem; color: var(--ink); word-break: break-word; }
.voter-card-code { font-weight: 700; letter-spacing: 0.04em; }
.voter-card-foot { padding-top: 0.5rem; border-top: 1px solid var(--line-soft); font-size: 0.72rem; color: var(--ink-3); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 1.5rem 1.25rem 1.75rem; gap: 1.5rem; }
  .login-head h1 { font-size: var(--step-3); max-width: none; }
  .login-head p { font-size: var(--step-0); }
  .login-side .steps { display: none; }
  .login-side::after { font-size: 9rem; }
  .login-form-wrap { align-items: start; }

  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; height: 100%; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-pop); }
  .admin-top { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 1rem; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .admin-top .brand-mark .sub { color: #8d9a96; }
  .scrim { position: fixed; inset: 0; background: rgba(23, 33, 31, 0.5); z-index: 35; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:first-child { grid-column: 1 / -1; }
  .figure:nth-child(2) { border-left: 0; border-top: 1px solid var(--line-soft); }
  .figure:nth-child(3) { border-top: 1px solid var(--line-soft); }
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .ballot-grid.cols-2 { grid-template-columns: 1fr; }
  .cand { flex-direction: row; flex-wrap: wrap; }
  .cand-face { width: 100%; display: grid; grid-template-columns: 38% 1fr; }
  .cand-photo { aspect-ratio: auto; min-height: 150px; }
  .cand-photo .initials { font-size: 3rem; }
  .cand-no { font-size: 1.5rem; min-width: 2.7rem; padding: 0.3rem 0.6rem 0.4rem; }
  .cand-body { align-self: center; padding: 0.9rem 1rem; }
  .cand-actions { width: 100%; padding-top: 0.25rem; }
  .who { display: none; }
  .action-bar-inner { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .action-bar .btn { width: 100%; }
  .tally li { grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 0 0.75rem; padding: 0.9rem 1rem; }
  .tally .no { width: 2.5rem; height: 2.5rem; font-size: 1.25rem; }
  .winner { grid-template-columns: 1fr; }
  .table th, .table td { padding: 0.65rem 0.8rem; }
  .photo-field { flex-direction: column; align-items: flex-start; }
  .cards-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .sidebar, .admin-top, .no-print, .toolbar { display: none !important; }
  .admin-shell { display: block; }
  .admin-main { padding: 0; max-width: none; }
  .panel { border-color: #999; break-inside: avoid; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6mm; }
  .voter-card { border: 1px dashed #444; background: #fff; padding: 4.5mm 5mm; border-radius: 3px; }
  .voter-card-mark { background: #111; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .voter-card-sub, .voter-card-meta dt, .voter-card-foot { color: #333; }
  .winner { background: #fff; color: #000; border: 2px solid #000; }
  .winner h2, .winner p { color: #000; }
  .winner .no { background: #fff; border: 2px solid #000; color: #000; }
  .meter > span, .tally .bar > span, .mini-bar > span { background: #000 !important; }
}
