:root {
  --green: #059669;
  --green-d: #047857;
  --red: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); padding-bottom: 32px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--green); color: #fff; position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 800; }
.brand span { font-weight: 400; opacity: .9; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.2); }
.pill.loading { background: #f59e0b; color: #fff; }
.pill.ready { background: #10b981; color: #fff; }
.pill.error { background: var(--red); color: #fff; }

.tabs {
  display: flex; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 52px; z-index: 9;
}
.tab {
  flex: 1; padding: 12px 4px; border: none; background: none; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); }

main { max-width: 560px; margin: 0 auto; padding: 12px; }
.screen { display: none; }
.screen.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
}
.card h2 { font-size: 15px; margin-bottom: 8px; }
.note { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; font-size: 13px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field-block { display: block; margin-bottom: 16px; }
.field-block > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink);
}
input[type=range] { width: 100%; accent-color: var(--green); }

.btn {
  padding: 12px 18px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer;
  border: none; transition: transform .1s, background .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-d); }
.btn-go { background: var(--green); color: #fff; flex: 1; justify-content: center; }
.btn-sec { background: #f1f5f9; color: #334155; border: 1px solid var(--line); }
.btn-danger { background: #fee2e2; color: var(--red); border: 1px solid #fecaca; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.file-btn { cursor: pointer; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* Pending enroll items */
.pending-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.pending {
  display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; align-items: flex-start;
}
.pending img, .pending canvas { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.pending .p-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pending .p-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pending .p-inputs .input { padding: 8px 10px; font-size: 14px; }
.pending .p-actions { display: flex; gap: 6px; }
.pending .p-actions .btn { padding: 8px 12px; font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; align-self: flex-start; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.wait { background: #fef9c3; color: #854d0e; }

/* People list */
.people-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.person {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px;
}
.person canvas, .person img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.person .info { flex: 1; min-width: 0; }
.person .nm { font-weight: 700; font-size: 14px; }
.person .sub { font-size: 12px; color: var(--muted); }
.person .del { background: none; border: none; color: var(--red); font-size: 18px; cursor: pointer; padding: 4px 8px; }

/* Video */
.video-wrap {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden;
  background: #000; aspect-ratio: 4/3; border: 3px solid var(--line); transition: border-color .2s;
}
.video-wrap.match { border-color: var(--green); }
.video-wrap.nomatch { border-color: var(--red); }
video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transform: scaleX(-1); }
.controls { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }

/* Candidate card */
.candidate { display: flex; gap: 12px; padding: 12px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line); align-items: center; margin-bottom: 10px; }
.candidate #refThumb { width: 72px; height: 72px; border-radius: 10px; border: 1px solid var(--line); flex-shrink: 0; background:#eee; }
.cand-body { flex: 1; min-width: 0; }
.cand-name { font-size: 20px; font-weight: 800; }
.cand-meta { font-size: 13px; color: var(--muted); }
.cand-score { font-size: 13px; margin-top: 4px; font-weight: 700; }
.cand-score.hi { color: var(--green); }
.cand-score.lo { color: var(--red); }
.live-hint { font-size: 12px; color: #b45309; margin-top: 2px; }
.action-row { display: flex; gap: 8px; margin-bottom: 8px; }
.manual-pick { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

.stat-line { text-align: center; font-size: 14px; color: var(--muted); margin: 8px 0; }
.stat-line b { color: var(--green); font-size: 18px; }
.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item { font-size: 13px; padding: 6px 10px; background: #f0fdf4; border-radius: 8px; color: #166534; }

/* Results table */
.summary { font-weight: 700; padding-top: 4px; }
.result-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag.hadir { background: #dcfce7; color: #166534; }
.tag.tidak { background: #fee2e2; color: #991b1b; }

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
