/* E-Voting OSIS — SMKS YKP Magetan
   Palet diambil dari situs sekolah */
:root {
  --dark: #313b43;
  --dark-2: #262e35;
  --red: #ea3323;
  --red-dk: #c9281a;
  --crimson: #d33934;
  --orange: #ec6c2d;
  --bg: #f1f3f5;
  --card: #ffffff;
  --text: #1d252b;
  --muted: #66727c;
  --line: #dfe3e7;
  --ok: #1d9a5f;
  --ok-bg: #e5f6ee;
  --err-bg: #fdeceb;
  --info-bg: #eaf1f6;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; color: var(--dark); }
h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: .95rem; margin: .8rem 0 .2rem; }
p { margin: 0 0 .8rem; }
a { color: var(--red-dk); }
code { background: #eef0f2; padding: .1em .4em; border-radius: 4px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }

/* ---------- Header ---------- */
.topstrip { height: 10px; background: linear-gradient(90deg, var(--crimson), var(--orange)); }
header.site { background: var(--dark); border-bottom: 3px solid var(--red); }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.site-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 76px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand img { height: 52px; width: auto; display: block; }
.site-title { color: #fff; font-weight: 700; font-size: 1.05rem; text-align: right; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a { color: #e8ecef; text-decoration: none; padding: 10px 14px; font-weight: 600; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--red); }
.nav a.nav-out { background: var(--red); color: #fff; border-radius: 6px; margin-left: 8px; border-bottom: 0; }
.nav a.nav-out:hover { background: var(--red-dk); }

.main { flex: 1; padding-top: 28px; padding-bottom: 40px; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px; }
body.center .main { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ---------- Komponen ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.card.narrow { width: 100%; max-width: 460px; }
.card.hero { text-align: center; padding: 36px 28px; border-top: 4px solid var(--red); }
.card.hero h1 { font-size: 2rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 14px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid #c5ccd2; border-radius: 8px;
}
input[type=file] { padding: 8px; background: #f7f8f9; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid rgba(234, 51, 35, .35); outline-offset: 1px; border-color: var(--red);
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.filters select, .filters input { margin: 0; flex: 1; min-width: 130px; width: auto; }
form.inline { display: inline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-block; background: var(--red); color: #fff; border: 0; border-radius: 8px;
  padding: 11px 20px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
  transition: background .15s;
}
.btn:hover { background: var(--red-dk); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-lg { width: 100%; padding: 16px; font-size: 1.15rem; margin-top: 14px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 6px; }
.btn-ghost { background: #fff; color: var(--dark); border: 1px solid #c5ccd2; }
.btn-ghost:hover { background: #eef0f2; }
.btn-danger { background: var(--dark); }
.btn-danger:hover { background: #000; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; border-left: 4px solid; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok); color: #0f6b40; }
.alert-err { background: var(--err-bg); border-color: var(--red); color: #9d1d12; }
.alert-info { background: var(--info-bg); border-color: var(--dark); color: var(--dark); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: #e8ebee; color: var(--muted); font-size: .8rem; font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: #0f6b40; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code.code { font-size: 1rem; letter-spacing: .08em; font-weight: 700; background: #f1f3f5; }
.danger-zone { border-color: #f1b8b3; }

/* ---------- Halaman pemilih ---------- */
.code-input {
  text-align: center; font-size: 2.2rem; font-weight: 800; letter-spacing: .18em;
  padding: 16px 10px; text-transform: uppercase; border-width: 2px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.check {
  width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff;
  font-size: 2.4rem; line-height: 72px; margin: 0 auto 14px;
}

.vote-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 22px; }
.cand { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.cand-photo { position: relative; height: clamp(240px, 44vh, 440px); background: #dfe3e7; }
.cand-photo img { object-position: center 20%; }
.cand-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand-no {
  position: absolute; top: 0; left: 0; background: var(--red); color: #fff;
  font-weight: 800; font-size: 1.6rem; min-width: 56px; text-align: center; padding: 6px 12px;
  border-bottom-right-radius: 10px;
}
.cand-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cand-body h2 { font-size: 1.25rem; margin: 0; }
.cand-body details { font-size: .93rem; flex: 1; }
.cand-body summary { cursor: pointer; font-weight: 700; color: var(--red-dk); padding: 4px 0; }
.cand-body button { margin-top: auto; padding: 14px; font-size: 1.05rem; }

.modal { position: fixed; inset: 0; background: rgba(20, 26, 31, .72); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 400px; text-align: center; border-top: 5px solid var(--red); max-height: 96vh; overflow: auto; }
.modal-box img { width: 150px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; margin-bottom: 12px; background: #dfe3e7; }
.modal-box h2 { font-size: 1.3rem; }
.m-name { font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }
.m-actions { display: flex; gap: 10px; margin-top: 16px; }
.m-actions .btn { flex: 1; padding: 14px 10px; }

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 14px 0 20px; }
.stats-2 { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.stat { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 8px; padding: 12px 16px; }
.stat span { display: block; color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat b { font-size: 1.8rem; line-height: 1.2; color: var(--dark); font-variant-numeric: tabular-nums; }
.stat b.ok { color: var(--ok); }
.stat b.off { color: var(--red); }

.live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .88rem; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b3bac0; }
.dot.on { background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(29,154,95,.5); } 70% { box-shadow: 0 0 0 8px rgba(29,154,95,0); } 100% { box-shadow: 0 0 0 0 rgba(29,154,95,0); } }

.bars { display: flex; flex-direction: column; gap: 18px; }
.bar-row { display: flex; gap: 14px; align-items: center; }
.bar-row img { width: 64px; height: 84px; object-fit: cover; border-radius: 6px; background: #dfe3e7; flex: none; }
.bar-main { flex: 1; min-width: 0; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.bar { height: 16px; background: #e8ebee; border-radius: 99px; overflow: hidden; }
.bar.sm { height: 9px; min-width: 100px; }
.bar i { display: block; height: 100%; background: var(--dark); border-radius: 99px; transition: width .6s ease; }
.bar-row.lead .bar i { background: linear-gradient(90deg, var(--crimson), var(--orange)); }
.bar.sm i { background: var(--orange); }

.cand-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cand-row:last-child { border-bottom: 0; }
.thumb { width: 48px; height: 64px; object-fit: cover; border-radius: 5px; background: #dfe3e7; }
.thumb-lg { width: 120px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; margin-bottom: 14px; }

/* ---------- Cetak kartu ---------- */
.print-body { display: block; background: #fff; }
.print-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 20px; background: var(--dark); color: #fff; }
.print-bar .muted { color: #b8c1c8; flex: 1; font-size: .88rem; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0; max-width: 794px; margin: 16px auto; }
.vcard {
  border: 1px dashed #8a949c; margin: -.5px; padding: 0; height: 5.4cm; overflow: hidden;
  break-inside: avoid; page-break-inside: avoid; display: flex; flex-direction: column;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.vcard-head { background: var(--dark); border-bottom: 3px solid var(--red); display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; color: #fff; font-size: 9pt; font-weight: 700; }
.vcard-head img { height: 26px; width: auto; }
.vcard-body { padding: 6px 12px; text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.vcard-name { font-weight: 800; font-size: 11pt; line-height: 1.2; }
.vcard-class { font-size: 9pt; color: #555; }
.vcard-label { font-size: 7.5pt; color: #777; margin-top: 4px; }
.vcard-code { font: 800 20pt/1.1 ui-monospace, Consolas, monospace; letter-spacing: .12em; color: var(--red-dk); }
.vcard-foot { font-size: 6.5pt; color: #666; margin-top: 4px; line-height: 1.3; }

@page { size: A4; margin: 8mm; }
@media print {
  .no-print { display: none !important; }
  .cards { max-width: none; margin: 0; }
}

/* ---------- Responsif ---------- */
@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .site-title { text-align: left; }
  h1 { font-size: 1.4rem; }
  .card.hero h1 { font-size: 1.6rem; }
  .code-input { font-size: 1.7rem; }
  .bar-row img { width: 48px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.on { animation: none; }
  .bar i { transition: none; }
}
