:root {
  --red: #c8102e;
  --red-dark: #9d0b23;
  --gold: #f5b301;
  --gold-soft: #fff4d6;
  --navy: #1b2a6b;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e6e9f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ok: #138a4a;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(27, 42, 107, 0.08);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .6rem; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--navy));
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 46px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: .78rem; color: var(--muted); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; }
.userbox span { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Tombol & form ---------- */
.btn {
  font-family: inherit; font-weight: 700; font-size: .92rem;
  border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(200, 16, 46, .28); }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: #14205a; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover:not(:disabled) { background: #e3a500; }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #f1f3f9; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #f3c3cb; }
.btn-danger:hover:not(:disabled) { background: #fdecef; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 10px; }
.btn-lg { padding: 15px 38px; font-size: 1.1rem; border-radius: 16px; letter-spacing: .04em; }

label.field { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 12px; }
input[type="text"], input[type="password"], input[type="datetime-local"], input[type="search"], textarea, select {
  width: 100%; margin-top: 6px; padding: 11px 13px;
  font-family: inherit; font-size: .95rem; color: var(--ink);
  background: #fff; border: 1px solid #d5d9e4; border-radius: 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27, 42, 107, .12); }
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 60vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; text-align: center; padding: 32px 26px; }
.login-card img { height: 120px; margin-bottom: 8px; }
.login-card h1 { color: var(--navy); font-size: 1.35rem; }
.login-card form { text-align: left; margin-top: 18px; }
.login-card .btn { width: 100%; }
.err { color: var(--red); font-size: .85rem; font-weight: 600; min-height: 1.2em; margin: 4px 0 10px; }

/* ---------- Peserta ---------- */
.hello { margin-bottom: 14px; }
.hello h1 { color: var(--navy); }
.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--line); background: #fff; margin-bottom: 18px;
}
.statusbar.open { background: #eaf7f0; border-color: #bfe5cf; color: var(--ok); }
.statusbar.closed { background: #fdecef; border-color: #f3c3cb; color: var(--red-dark); }
.statusbar .count { font-variant-numeric: tabular-nums; font-weight: 800; }
.statusbar small { font-weight: 500; opacity: .85; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cat-card { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; min-height: 170px; }
.cat-card h3 { color: var(--navy); font-size: 1.15rem; }
.cat-card .btn { width: 100%; }
.closed-note { text-align: center; padding: 10px; border-radius: 12px; background: #f3f4f8; color: var(--muted); font-weight: 600; font-size: .88rem; }
.lot-badge {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, var(--gold-soft), #fff); border: 1px solid #f1d994;
  border-radius: 14px; padding: 10px 16px;
}
.lot-badge span { font-weight: 700; color: var(--navy); font-size: .85rem; }
.lot-badge strong { font-size: 2.2rem; line-height: 1; color: var(--red); }
.lot-note { font-size: .75rem; color: var(--muted); margin-top: 6px; }

/* ---------- Roda ---------- */
.back { margin-bottom: 14px; }
.wheel-page { text-align: center; }
.wheel-page h2 { color: var(--navy); font-size: 1.5rem; }
.wheel-wrap { max-width: 440px; margin: 14px auto 18px; }
.wheel-wrap canvas { display: block; margin: 0 auto; max-width: 100%; }
.result {
  max-width: 420px; margin: 22px auto 0; padding: 22px;
  border-radius: 20px; background: linear-gradient(135deg, #fff, var(--gold-soft));
  border: 2px solid var(--gold); box-shadow: var(--shadow);
  animation: pop .5s cubic-bezier(.2, 1.4, .4, 1);
}
.result small { display: block; color: var(--navy); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .75rem; }
.result strong { display: block; font-size: 5rem; line-height: 1.1; color: var(--red); }
.result p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti-layer i {
  position: absolute; top: -20px; width: 9px; height: 14px; opacity: .95;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  font-family: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 200px; }
.toolbar input, .toolbar select { margin-top: 0; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.row2 .card + .card { margin-top: 0; }

.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 18px; }
.sum-card h3 { color: var(--navy); }
.progress { height: 8px; background: #eceff6; border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 99px; transition: width .4s; }
.sum-card .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.acts { white-space: nowrap; text-align: right; }
td.acts .btn + .btn { margin-left: 6px; }
.num-pill { display: inline-grid; place-items: center; min-width: 38px; height: 30px; padding: 0 8px; border-radius: 99px; background: var(--red); color: #fff; font-weight: 800; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: #eef0f7; color: var(--navy); margin: 2px 4px 2px 0; }
.pill.warn { background: #fff4d6; color: #8a6200; }
.pill.auto { background: #e8ecff; color: var(--navy); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }
.cat-title { margin: 22px 0 8px; color: var(--navy); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: #fff; }
.checks input { accent-color: var(--red); }
.hint { font-size: .8rem; color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 8px 0 16px; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--red); }

/* ---------- Modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(20, 26, 50, .45); display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { padding: 11px 16px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 600; font-size: .88rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: slideIn .25s ease; }
.toast.error { background: var(--red-dark); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .5s; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } }

.notice { text-align: center; padding: 40px 20px; }
.notice h2 { color: var(--navy); }

/* ---------- Cetak kartu akun ---------- */
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  body { background: #fff; }
  #printArea { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0; }
  .pcard { border: 1.5px solid #1b2a6b; border-radius: 10px; padding: 12px 14px; page-break-inside: avoid; font-size: 12px; }
  .pcard header { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid #f5b301; padding-bottom: 6px; margin-bottom: 8px; }
  .pcard header img { height: 34px; }
  .pcard header b { color: #1b2a6b; font-size: 12px; line-height: 1.2; }
  .pcard .nm { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
  .pcard .kv { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; font-weight: 700; }
  .pcard small { color: #555; display: block; margin-top: 6px; word-break: break-all; }
}

@media (max-width: 520px) {
  .brand-text span { display: none; }
  .result strong { font-size: 4rem; }
  .container { padding-top: 16px; }
}
