:root {
  --bg: #0f1720;
  --panel: #17212b;
  --panel2: #1e2a36;
  --line: #2a3a48;
  --text: #e6edf3;
  --muted: #8ba3b6;
  --primary: #25d366;
  --primary-dark: #1da851;
  --danger: #e5484d;
  --ok: #25d366;
  --bad: #e5484d;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.mt { margin-top: 14px; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--panel); padding: 34px 28px; border-radius: 16px; width: 320px; text-align: center; border: 1px solid var(--line); }
.login-card .logo { font-size: 40px; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-card input { width: 100%; padding: 12px; text-align: center; font-size: 20px; letter-spacing: 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); margin-bottom: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* APP */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.pill-off { background: #3a2a2a; color: #ff8a8a; }
.pill-on { background: #113524; color: var(--primary); }
.pill-wait { background: #3a3320; color: #f0c674; }

.tabs { display: flex; gap: 4px; padding: 10px 14px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: transparent; border: none; color: var(--muted); padding: 10px 14px; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.content { max-width: 860px; margin: 0 auto; padding: 18px 14px 60px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card.center { text-align: center; }
.badge { font-size: 11px; background: #113524; color: var(--primary); padding: 2px 8px; border-radius: 10px; vertical-align: middle; margin-left: 6px; }

.lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea, select { font-family: inherit; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], textarea, input:not([type]) {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 14px;
}
textarea { resize: vertical; }
input[type=file] { color: var(--muted); font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.chk { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }

.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #05230f; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger.btn-ghost { background: var(--panel2); color: #ff8a8a; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.qr-box { width: 300px; height: 300px; margin: 10px auto; background: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; }
.qr-box .muted { color: #333; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: 12px; padding: 4px 10px; border-radius: 14px; cursor: pointer; }
.chip:hover { border-color: var(--primary); }
.chip .x { color: var(--danger); margin-left: 6px; cursor: pointer; }

.info-box { margin-top: 14px; padding: 12px; background: var(--panel2); border-radius: 8px; font-size: 14px; }
.table-wrap { margin-top: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }

.preview-box { margin-top: 12px; }
.preview-item { background: var(--panel2); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.preview-item .to { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.preview-item .msg { white-space: pre-wrap; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel2); border-radius: 10px; padding: 12px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lb { font-size: 12px; color: var(--muted); }
.stat.ok .num { color: var(--ok); }
.stat.bad .num { color: var(--bad); }

.progress { height: 10px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.progress .bar { height: 100%; width: 0%; background: var(--primary); transition: width .3s; }

/* contact manager */
.val-summary { font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.v-ok { color: var(--ok); }
.v-suspect { color: #f0c674; }
.v-empty { color: #ff8a8a; }
.contact-table input { width: 100%; min-width: 90px; padding: 6px 8px; border: 1px solid transparent; background: transparent; color: var(--text); border-radius: 6px; font-size: 13px; }
.contact-table input:hover { border-color: var(--line); }
.contact-table input:focus { border-color: var(--primary); background: var(--panel2); outline: none; }
.contact-table td { padding: 3px 4px; vertical-align: middle; }
.contact-table td.idx { color: var(--muted); text-align: center; font-size: 12px; }
.contact-table tr.st-empty td.idx { color: #ff8a8a; font-weight: 700; }
.contact-table tr.st-empty input[data-field="nomor"] { background: #3a2020; }
.contact-table tr.st-suspect input[data-field="nomor"] { background: #3a3320; }
.del-row { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.del-row:hover { background: #3a2020; color: #ff8a8a; }

.log-box { margin-top: 12px; background: #0b1016; border: 1px solid var(--line); border-radius: 8px; padding: 10px; height: 180px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 12px; }
.log-line { padding: 2px 0; border-bottom: 1px solid #16202a; }
.log-line.error { color: #ff8a8a; }
.log-line .t { color: var(--muted); margin-right: 6px; }
