:root {
  --green-900: #06371a;
  --green-800: #0b4d26;
  --green-700: #0b5d2a;
  --green-600: #1a7a3a;
  --green-100: #e5f3e8;
  --green-50: #f3faf4;
  --lime: #8cc63f;
  --yellow: #ffd400;
  --red: #c62828;
  --red-50: #fdecec;
  --amber: #b26a00;
  --amber-50: #fff5e0;
  --blue: #1d5fa8;
  --blue-50: #e8f0fb;
  --ink: #17221b;
  --ink-2: #4b5a50;
  --ink-3: #7a877e;
  --line: #dbe4dd;
  --surface: #ffffff;
  --bg: #f2f5f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(6,55,26,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--green-700); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .75rem; }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(100deg, var(--green-900), var(--green-700) 60%, var(--green-600));
  color: #fff; padding: .7rem 1rem; display: flex; align-items: center; gap: .75rem;
  border-bottom: 4px solid var(--lime); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; letter-spacing: .02em; font-style: italic; font-size: 1.15rem; }
.brand small { display: block; font-style: normal; font-weight: 500; font-size: .72rem; opacity: .85; letter-spacing: .03em; }
.topbar .who { font-size: .85rem; opacity: .9; }
.topbar .btn { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); white-space: nowrap; }
.brand, #live { white-space: nowrap; }

/* ---------- Togol bahasa ---------- */
.lang-toggle { display: inline-flex; flex: none; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 2px; gap: 2px; }
.lang-toggle button { appearance: none; border: 0; background: transparent; color: #fff; font: inherit; font-weight: 700; font-size: .76rem; letter-spacing: .02em;
  padding: .25rem .55rem; border-radius: 999px; display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; min-height: 30px; }
.lang-toggle button:hover { background: rgba(255,255,255,.12); }
.lang-toggle button[aria-pressed=true] { background: #fff; color: var(--green-800); }
.lang-toggle button:focus-visible { outline: 3px solid var(--lime); outline-offset: 1px; }
.lang-toggle .flag { width: 20px; height: 10px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.18); display: block; flex: none; }
.hero-top { display: flex; justify-content: flex-end; margin: -.4rem -.2rem .6rem; position: relative; z-index: 1; }
.btn-del { color: var(--red); border-color: #f0c4c4; }
.btn-del:hover { background: var(--red-50); border-color: var(--red); }

/* ---------- Layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 520px; margin: 0 auto; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .queue > .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .55rem .9rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; min-height: 40px;
}
.btn:hover { border-color: var(--green-600); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.btn-primary:hover { background: var(--green-800); }
.btn-lg { padding: .85rem 1.2rem; font-size: 1.05rem; min-height: 52px; width: 100%; justify-content: center; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn-ghost { background: transparent; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .3rem; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=search], input[type=number], select {
  width: 100%; padding: .7rem .8rem; border: 1px solid #c4d0c7; border-radius: 10px; font: inherit; background: #fff; min-height: 46px;
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid rgba(140,198,63,.6); outline-offset: 1px; border-color: var(--green-600); }
.field + .field { margin-top: .8rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-PENDING { background: #eef0ef; color: #59645d; }
.st-CHECKED_IN { background: var(--blue-50); color: var(--blue); }
.st-KIT_READY { background: var(--amber-50); color: var(--amber); }
.st-ISSUED { background: #f1e8fb; color: #6a3aa8; }
.st-RECEIVED { background: var(--green-100); color: var(--green-700); }
.b-run { background: #fff7cc; color: #6d5800; }
.b-ride { background: #e3f1fb; color: #155c8a; }
.b-sent { background: var(--green-100); color: var(--green-700); }
.b-pending { background: var(--amber-50); color: var(--amber); }
.b-failed { background: var(--red-50); color: var(--red); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .7rem 1rem; border: 0; background: none; font: inherit; font-weight: 700; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab[aria-selected=true] { color: var(--green-700); border-bottom-color: var(--green-700); }
.tab .count { background: var(--green-700); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-left: .3rem; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(6,30,15,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100; }
.modal { background: #fff; border-radius: 16px; max-width: 440px; width: 100%; padding: 1.4rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; max-height: 90vh; overflow: auto; }
.modal .icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; margin-bottom: .6rem; }
.modal .icon.err { background: var(--red-50); color: var(--red); }
.modal .icon.ok { background: var(--green-100); color: var(--green-700); }
.modal .icon.warn { background: var(--amber-50); color: var(--amber); }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--green-900); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 200; box-shadow: var(--shadow); max-width: calc(100% - 2rem); }
.toast.err { background: var(--red); }

/* ---------- Participant (mobile) ---------- */
.hero { background: linear-gradient(160deg, var(--green-900), var(--green-700)); color: #fff; padding: 1.4rem 1rem 2.6rem; text-align: center; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; left: -10%; right: -10%; bottom: -22px; height: 44px; background: var(--bg); border-radius: 50% 50% 0 0; }
.hero .qr-code { display: inline-block; background: var(--yellow); color: var(--green-900); font-weight: 800; padding: .2rem .7rem; border-radius: 999px; font-size: .8rem; letter-spacing: .05em; }
.hero h1 { font-size: 1.5rem; margin: .5rem 0 .2rem; font-style: italic; }
.hero p { margin: 0; opacity: .9; }
.p-main { max-width: 520px; margin: -1.2rem auto 0; padding: 0 1rem 2rem; position: relative; z-index: 1; }
.status-big { text-align: center; padding: 1.3rem 1rem; }
.status-big .emoji { font-size: 2.6rem; }
.status-big h2 { font-size: 1.2rem; margin-top: .4rem; }
.steps { display: flex; justify-content: space-between; margin: 1rem 0 .4rem; position: relative; }
.steps::before { content: ""; position: absolute; left: 8%; right: 8%; top: 13px; height: 3px; background: var(--line); }
.step { flex: 1; text-align: center; font-size: .68rem; color: var(--ink-3); position: relative; }
.step .dot { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 3px solid var(--line); margin: 0 auto .25rem; display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.step.done { color: var(--green-700); font-weight: 700; }
.step.done .dot { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.step.now .dot { border-color: var(--green-700); color: var(--green-700); }
.namelist { list-style: none; padding: 0; margin: 0; }
.namelist li { padding: .55rem 0; border-bottom: 1px dashed var(--line); }
.namelist li:last-child { border-bottom: 0; }
.check-item { display: flex; align-items: center; gap: .75rem; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; margin: 0; }
.check-item + .check-item { margin-top: .5rem; }
.check-item input { width: 24px; height: 24px; accent-color: var(--green-700); flex: none; }
.check-item.locked { background: var(--green-50); cursor: default; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; font-size: .92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Staff ---------- */
.queue { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.gcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; display: flex; flex-direction: column; gap: .55rem; }
.gcard .head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.gcard .names { margin: 0; padding-left: 1.1rem; }
.gcard .names li { font-weight: 700; }
.gcard .p2 li { font-weight: 500; color: var(--ink-2); }
.sizes { display: flex; flex-wrap: wrap; gap: .35rem; }
.size { border: 2px solid var(--green-700); border-radius: 8px; padding: .15rem .5rem; font-weight: 800; font-size: .95rem; }
.size small { font-weight: 600; color: var(--ink-2); }
.size.ride { border-color: #155c8a; }
.size.none { border-style: dashed; border-color: var(--ink-3); color: var(--ink-2); }
.wait { font-size: .78rem; font-weight: 700; }
.wait.late { color: var(--red); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }

/* ---------- Admin ---------- */
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .78rem; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--ink-2); }
.kpi.alert { border-color: #f0b4b4; background: #fffafa; }
.kpi.alert .value { color: var(--red); }
.pipeline { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: #eef0ef; gap: 2px; }
.pipeline > div { height: 100%; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .5rem; font-size: .82rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bar-row { display: grid; grid-template-columns: 74px 1fr 92px; gap: .5rem; align-items: center; font-size: .85rem; padding: .18rem 0; }
.bar-track { height: 14px; background: #eef0ef; border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--green-600); border-radius: 0 4px 4px 0; }
.bar-fill.soft { background: #a9d4b4; position: absolute; left: 0; top: 0; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #edf1ee; vertical-align: top; }
th { background: var(--green-50); position: sticky; top: 0; z-index: 1; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fbf8; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; font-size: .85rem; }
.feed li { padding: .4rem 0; border-bottom: 1px solid #eef2ef; display: grid; grid-template-columns: 58px 1fr; gap: .5rem; }
.feed time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.daybar { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 700; }
.daybar.kit { background: var(--blue-50); color: var(--blue); }
.daybar.event { background: #fff7cc; color: #6d5800; }
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c7d0ca; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--green-600); }
.switch input:checked + span::before { transform: translateX(22px); }
.qrbox { display: grid; grid-template-columns: 120px 1fr; gap: 1rem; align-items: center; }
.qrbox img { width: 120px; height: 120px; border: 1px solid var(--line); border-radius: 8px; }
.note { background: var(--amber-50); color: #6b4300; border-radius: 10px; padding: .7rem .9rem; font-size: .88rem; }
.note.info { background: var(--blue-50); color: #17406e; }
.note.ok { background: var(--green-100); color: var(--green-800); }

@media (min-width: 1100px) {
  .span-2 { grid-column: span 2; }
}
@media (max-width: 600px) {
  .wrap { padding: .75rem; }
  .topbar { padding: .6rem .75rem; gap: .45rem; }
  .brand { font-size: 1rem; }
  .topbar .btn-sm { padding: .3rem .5rem; }
  .lang-toggle button { padding: .25rem .4rem; }
  .queue { grid-template-columns: 1fr; }
  .qrbox { grid-template-columns: 90px 1fr; }
  .qrbox img { width: 90px; height: 90px; }
  .hide-sm { display: none; }
  .kpi .value { font-size: 1.5rem; }
}
@media print {
  .topbar, .no-print { display: none !important; }
}

/* QR01: langkah seterusnya & status ikut nama */
.next-step { display: flex; gap: .7rem; align-items: center; text-align: left; background: #fff7d6; border: 2px solid #f2c200; color: #5a4300; border-radius: 12px; padding: .8rem .9rem; margin: .8rem 0 .4rem; font-size: .95rem; animation: ns-pulse 2s ease-in-out 3; }
.next-step .ns-icon { font-size: 1.8rem; line-height: 1; }
@keyframes ns-pulse { 50% { box-shadow: 0 0 0 6px rgba(242, 194, 0, .25); } }
.namelist li.pname { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.badge.b-issued { background: #fff1c2; color: #6b4a00; }
.badge.b-wait { background: #eef0ee; color: #5d6b62; }

/* Kotak "langkah seterusnya" boleh ditekan -> pengimbas QR */
button.next-step.tap { width: 100%; font: inherit; cursor: pointer; box-shadow: 0 3px 0 #d9a900; transition: transform .08s, box-shadow .08s; }
button.next-step.tap:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9a900; }
.next-step .ns-text { flex: 1; }
.next-step .ns-cta { display: inline-block; margin-top: .45rem; background: #0b5d2a; color: #fff; font-weight: 700; border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; }
.next-step .ns-go { font-size: 2rem; font-weight: 700; color: #0b5d2a; line-height: 1; }
.check-item.tick-all { background: #f3f7f4; border-style: dashed; }
/* Pengimbas */
.scan-box { max-width: 420px; }
.scan-view { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; margin: .6rem 0; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 15%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scan-err { background: #fdecea; color: #8a1c12; border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; margin: .4rem 0; }

/* Label persona SUPERADMIN: menyala terang */
.brand small.persona-badge { display: table; margin-top: .25rem; padding: .08rem .55rem; border-radius: 999px; font-style: normal; font-weight: 900; font-size: .78rem; letter-spacing: .12em; opacity: 1;
  background: #ff2bd6; color: #fff; text-shadow: 0 0 6px #fff, 0 0 12px #ff2bd6; box-shadow: 0 0 8px #ff2bd6, 0 0 18px #ff2bd6, 0 0 30px rgba(255,43,214,.7); animation: sa-glow 1.8s ease-in-out infinite alternate; }
@keyframes sa-glow { from { box-shadow: 0 0 6px #ff2bd6, 0 0 14px #ff2bd6; } to { box-shadow: 0 0 12px #ff2bd6, 0 0 26px #ff2bd6, 0 0 44px rgba(255,43,214,.85); } }
@media (prefers-reduced-motion: reduce) { .brand small.persona-badge { animation: none; } }

/* Kotak kata laluan dengan ikon mata */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 3rem; width: 100%; }
.pw-eye { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; border-radius: 10px; color: #5d6b62; cursor: pointer; }
.pw-eye:hover { color: var(--green-700, #0b5d2a); background: rgba(11, 93, 42, .08); }
.pw-eye:focus-visible { outline: 3px solid #f2c200; outline-offset: -2px; }
