:root {
  --bg: #f3f6f9;
  --card: #fff;
  --ink: #1d2733;
  --muted: #6b7785;
  --line: #dfe5eb;
  --accent: #0e7490;
  --accent-ink: #fff;
  --sheet-head: #00e5ff;
  --wait: #b45309;  --wait-bg: #fef3c7;
  --recv: #1d4ed8;  --recv-bg: #dbeafe;
  --proc: #7c3aed;  --proc-bg: #ede9fe;
  --done: #15803d;  --done-bg: #dcfce7;
  --rev: #b91c1c;   --rev-bg: #fee2e2;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- tombol */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: #f1f5f9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; font-weight: 600; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0b5f76; }
.btn.danger { background: var(--rev); border-color: var(--rev); color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn.danger-ghost { color: var(--rev); border-color: #f3c4c4; }
.btn.danger-ghost:hover { background: var(--rev-bg); }
.btn.ghost { background: transparent; }

/* ---------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 20px; background: #0f2f3a; color: #fff; flex-wrap: wrap;
}
.topbar .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.topbar .btn:hover { background: rgba(255,255,255,.1); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.role-badge { background: var(--sheet-head); color: #003842; font-weight: 700; padding: 3px 10px; border-radius: 99px; font-size: 13px; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.1); }
.pill.on { background: #14532d; color: #bbf7d0; }
.pill.off { background: #7f1d1d; color: #fecaca; }
.pill.warn { background: #78350f; color: #fde68a; }

main { max-width: 1500px; margin: 0 auto; padding: 16px 20px 60px; }

/* ---------- judul ala spreadsheet */
.sheet-head { text-align: center; margin: 6px 0 14px; }
.sheet-head h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.sheet-head h2 { margin: 4px 0 0; font-size: 18px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.inline input[type=date], .inline select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.summary { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #e2e8f0; font-weight: 600; }

/* ---------- warna status */
.st-wait { --c: var(--wait); --cb: var(--wait-bg); }
.st-recv { --c: var(--recv); --cb: var(--recv-bg); }
.st-proc { --c: var(--proc); --cb: var(--proc-bg); }
.st-done { --c: var(--done); --cb: var(--done-bg); }
.st-rev  { --c: var(--rev);  --cb: var(--rev-bg); }
.chip[class*="st-"], .badge { background: var(--cb); color: var(--c); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }

/* ---------- alert */
.alert {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 10px; border: 2px solid;
}
.alert.danger { background: var(--rev-bg); border-color: var(--rev); color: #7f1d1d; }
.alert.warn { background: var(--wait-bg); border-color: #f59e0b; color: #78350f; display: block; }
.alert-note { margin-top: 4px; font-size: 15px; }
.alert-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.blink { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, .25); } }
.alert.warn.blink { animation-name: blinkWarn; }
@keyframes blinkWarn { 50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, .3); } }

/* ---------- kartu & form */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card.edit-mode { border: 2px solid var(--proc); background: #faf8ff; }
.form-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.form-head h3 { margin: 0; font-size: 16px; }
.grid { display: grid; grid-template-columns: 2fr 1.4fr 3fr 1fr 2fr; gap: 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.grid input, .grid select {
  padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 15px; font-weight: 400; color: var(--ink); background: #fff;
}
.grid input:focus, .grid select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.f-nik { position: relative; }
.nik-hint { position: absolute; right: 0; top: 0; font-size: 11px; }
.nik-hint.ok { color: var(--done); }
.nik-hint.bad { color: var(--rev); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr 1fr; } .f-alamat, .f-ket { grid-column: span 2; } }

/* ---------- tabel */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--sheet-head); color: #002a31; font-weight: 700; font-size: 13px; text-align: left;
  padding: 9px 10px; border-bottom: 1px solid #00b8cc; white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { border-left: 4px solid var(--c, transparent); }
tbody tr:hover { background: #f8fafc; }
tbody tr.fresh { background: #fffbeb; animation: fresh 1.6s ease-in-out infinite; }
@keyframes fresh { 50% { background: #fef3c7; } }
tbody tr.editing { background: #f5f3ff; }
.c-no { width: 48px; text-align: center; font-size: 16px; }
.c-nama { font-weight: 600; min-width: 150px; }
.c-nik { font-variant-numeric: tabular-nums; min-width: 160px; }
.c-alamat { min-width: 200px; }
.c-status { white-space: nowrap; }
.c-note { min-width: 170px; max-width: 260px; }
.c-act { width: 1%; }
.acts { display: flex; gap: 5px; flex-wrap: wrap; min-width: 150px; }
.tag { display: inline-block; margin-top: 3px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; }
.tag.rev { background: var(--proc-bg); color: var(--proc); }
.tag.warn { background: var(--rev-bg); color: var(--rev); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; margin: 0; }
.note-prev { font-size: 12px; margin-bottom: 4px; padding: 4px 7px; background: #f1f5f9; border-radius: 6px; }
.note-prev.rev { background: var(--rev-bg); color: #7f1d1d; }

/* tombol salin di sel (PC Pendaftaran) */
.copy {
  display: inline-flex; align-items: flex-start; gap: 6px; text-align: left; border: 1px dashed transparent;
  background: transparent; padding: 3px 5px; margin: -3px -5px; border-radius: 6px; cursor: copy; font-weight: inherit;
}
.copy i { font-style: normal; opacity: .35; font-size: 12px; }
.copy:hover { border-color: var(--accent); background: #ecfeff; }
.copy:hover i { opacity: 1; }
.copy:active { background: #cffafe; }

/* ---------- dialog catatan */
dialog { border: none; border-radius: 14px; padding: 18px; width: min(620px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; }
.dlg-head h3 { margin: 0; font-size: 17px; }
.note-info { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; padding: 10px; background: #f8fafc; border-radius: 8px; margin-bottom: 10px; }
.note-info small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.note-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 10px; }
.note { max-width: 85%; padding: 8px 11px; border-radius: 10px; background: #f1f5f9; align-self: flex-start; }
.note.mine { align-self: flex-end; background: #e0f2fe; }
.note.rev { background: var(--rev-bg); border: 1px solid #fca5a5; }
.note small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.log { align-self: center; font-size: 11px; color: var(--muted); }
textarea { width: 100%; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-btn { border: 1px solid #fca5a5; background: #fff; color: var(--rev); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip-btn:hover { background: var(--rev-bg); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- peran */
body:not(.role-tb) .tb-only { display: none; }
body:not(.role-daftar) .daftar-only { display: none; }

/* ---------- toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, 92vw); }
.toast { background: #1e293b; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .4s, transform .4s; }
.toast.ok { background: #14532d; }
.toast.info { background: #0e7490; }
.toast.warn { background: #991b1b; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- overlay & login */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15, 47, 58, .92); display: grid; place-items: center; padding: 20px; }
.unlock-card, .login-card { background: #fff; border-radius: 16px; padding: 28px; width: min(440px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.unlock-card h2 { margin: 6px 0; }
.login-logo { font-size: 42px; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0f2f3a, #0e7490); }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.role-pick input { position: absolute; opacity: 0; }
.role-pick span { display: block; border: 2px solid var(--line); border-radius: 12px; padding: 14px 10px; cursor: pointer; text-align: center; height: 100%; }
.role-pick span b { display: block; font-size: 15px; margin-bottom: 4px; }
.role-pick span small { color: var(--muted); font-size: 12px; }
.role-pick input:checked + span { border-color: var(--accent); background: #ecfeff; }
.role-pick input:focus-visible + span { outline: 2px solid var(--accent); }
.fld { display: flex; flex-direction: column; gap: 5px; text-align: left; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
.fld input { padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 18px; letter-spacing: 4px; text-align: center; }
.err { color: var(--rev); margin: 12px 0 0; font-weight: 600; }

/* ---------- cetak: hanya tabel ala spreadsheet */
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; font-family: Arial, sans-serif; color: #000; }
  #printArea h1, #printArea h2 { text-align: center; margin: 0 0 6px; font-size: 16pt; }
  #printArea h2 { margin-bottom: 14px; font-size: 14pt; }
  #printArea table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  #printArea th { background: #00ffff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea th, #printArea td { border: 1px solid #000; padding: 4px 6px; text-align: left; }
  #printArea td:first-child, #printArea th:first-child { text-align: center; width: 30px; }
}
