:root {
  --green: #0f5c45;
  --green-2: #137a5b;
  --green-soft: #e3f2ec;
  --gold: #c99a2e;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --text: #1c2421;
  --muted: #6b7570;
  --line: #e2e6e3;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #a15c00;
  --amber-soft: #fff4e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--green-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
p { margin: .4rem 0; }
[hidden] { display: none !important; }

/* ---------- layout */
.container { max-width: 960px; margin: 0 auto; padding: 16px 16px 96px; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  justify-content: space-between; padding: 10px 16px; background: var(--green); color: #fff;
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; min-width: 0; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px;
  background: var(--gold); color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: .5px;
}
.active-event {
  flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(255,255,255,.15); color: #fff; text-decoration: none; font-size: .8rem;
  padding: 5px 10px; border-radius: 999px;
}
.active-event::before { content: "● "; color: #7ff0c0; }
.tabs {
  display: flex; gap: 4px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 8px; scrollbar-width: none; position: sticky; top: 52px; z-index: 9;
}
.tabs a {
  flex: none; padding: 12px 12px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem;
  border-bottom: 3px solid transparent;
}
.tabs a.on { color: var(--green); border-bottom-color: var(--green); }
@media (max-width: 640px) {
  .tabs {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; justify-content: space-around; border-top: 1px solid var(--line);
    border-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a { border-bottom: 0; border-top: 3px solid transparent; font-size: .82rem; padding: 12px 6px; }
  .tabs a.on { border-top-color: var(--green); }
}

/* ---------- elements */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; }
.stack > * + * { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); border-radius: 10px; padding: 10px 14px; font: inherit;
  font-weight: 600; text-decoration: none; cursor: pointer; min-height: 42px;
}
.btn:hover { border-color: #c7cfca; }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.primary:hover { background: var(--green-2); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }

label { display: block; font-size: .85rem; font-weight: 600; color: #3b4541; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px;
  border: 1px solid #cfd6d2; border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-2); outline-offset: 0; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { width: auto; margin-top: 3px; }
.error { color: var(--red); font-size: .9rem; min-height: 1.2em; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef0ef; color: #4a5450; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.muted { background: #eef0ef; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat b { display: block; font-size: 1.6rem; color: var(--green); }
.stat span { font-size: .8rem; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a.item { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.list .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: var(--green-soft); color: var(--green); font-weight: 700; font-size: .9rem;
}
.avatar.p { background: #f6e9f0; color: #8a3a62; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

dl.info { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.info dt { color: var(--muted); font-size: .9rem; }
dl.info dd { margin: 0; }
@media (max-width: 480px) { dl.info { grid-template-columns: 1fr; } dl.info dd { margin-bottom: 6px; } }

/* ---------- scanner */
.scan-result {
  border-radius: var(--radius); padding: 22px 16px; text-align: center; background: #eef0ef; color: var(--muted);
  min-height: 150px; display: flex; flex-direction: column; justify-content: center; transition: background .2s;
}
.scan-result .big { font-size: 1.5rem; font-weight: 800; color: inherit; }
.scan-result[data-kind="ok"] { background: var(--green); color: #fff; }
.scan-result[data-kind="already"] { background: var(--amber-soft); color: var(--amber); }
.scan-result[data-kind="error"] { background: var(--red-soft); color: var(--red); }
.scan-result .warn { margin-top: 8px; font-weight: 600; background: rgba(255,255,255,.9); color: var(--amber); border-radius: 8px; padding: 6px 8px; }
.counter { font-size: 2.4rem; font-weight: 800; color: var(--green); line-height: 1; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #1c2421; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: calc(100% - 32px); z-index: 50;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

/* ---------- login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login .brand-mark { width: 52px; height: 52px; font-size: 1.1rem; border-radius: 14px; margin: 0 auto 10px; }

/* ---------- halaman kartu (/c/:token) */
.card-page { background: linear-gradient(160deg, #0f5c45, #0a3f30); min-height: 100vh; }
.card-wrap { max-width: 420px; margin: 0 auto; padding: 32px 16px; }
.member-card {
  background: linear-gradient(145deg, #ffffff, #f3f7f4); border-radius: 20px; padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  border-top: 6px solid var(--gold);
}
.member-card.invalid { border-top-color: var(--red); }
.mc-head { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--green); }
.mc-logo { display: block; width: 34px; height: auto; flex: none; }
.mc-kicker { margin-top: 22px; font-size: .75rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.member-card h1 { font-size: 1.6rem; margin: 4px 0; }
.mc-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; color: var(--green); font-weight: 700; }
.mc-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 14px; color: var(--muted); font-size: .9rem; }
.staff-box { margin-top: 16px; background: #fff; border-radius: 16px; padding: 16px; }
.staff-box[data-state="ok"] { background: #d7f5e7; }
.staff-box[data-state="already"] { background: var(--amber-soft); }
.staff-box[data-state="error"] { background: var(--red-soft); }
.ci-label { font-size: .85rem; color: var(--muted); }
.ci-status { font-size: 1.1rem; font-weight: 700; margin: 6px 0 10px; }
.ci-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.self-box { margin-top: 16px; background: #fff; border-radius: 16px; padding: 18px; }
.self-box h2 { font-size: 1rem; margin: 0 0 6px; color: var(--green); }
.self-total { margin: 0 0 8px; color: var(--muted); }
.self-total b { font-size: 2rem; color: var(--text); margin-right: 4px; }
.self-list { list-style: none; margin: 0; padding: 0; }
.self-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .95rem; }
.self-list time { color: var(--muted); white-space: nowrap; font-size: .85rem; }
.self-note { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.staff-link { text-align: center; margin-top: 14px; }
.staff-link a { color: #cfe9de; }

/* ---------- logo masjid */
.brand-logo { width: 26px; height: auto; flex: none; }
.login-logo { width: 84px; height: auto; margin: 0 auto 12px; display: block; }
