*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ---------- Butang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  padding: .62em 1.05em; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--btn-bg); color: var(--ink); font-weight: 650; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible, .chip:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.green { background: #2f7a46; border-color: #2f7a46; color: #fff; }
.btn.wa { background: #1c9e50; border-color: #1c9e50; color: #fff; }
.btn.danger { background: #b23b3b; border-color: #b23b3b; color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost-red { background: transparent; border-color: #e0b4b0; color: #a33a35; }
.btn.ghost-red:hover { border-color: #a33a35; background: #fbeceb; }
.btn.sm { padding: .42em .75em; font-size: .86rem; border-radius: 8px; }
.btn.big { padding: .95em 1.3em; font-size: 1.06rem; width: 100%; border-radius: 12px; }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

/* ---------- Medan borang ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 650; font-size: .9rem; margin-bottom: 6px; }
.field > span small { font-weight: 500; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=file]), .field select, .field textarea {
  width: 100%; padding: .72em .85em; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--input-bg); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring);
}
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; background: rgba(24, 14, 6, .58); display: grid; place-items: center;
  padding: 14px; z-index: 100; animation: fadeIn .15s ease;
}
.modal {
  position: relative; background: var(--modal-bg); color: var(--ink); border-radius: 18px;
  padding: 24px; width: min(540px, 100%); max-height: calc(100dvh - 28px); overflow: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38); animation: popIn .18s ease;
}
.modal.wide { width: min(1000px, 100%); }
.modal.small { width: min(420px, 100%); }
.modal-x {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); z-index: 2;
}
.modal-x:hover { background: rgba(0, 0, 0, .06); }
.modal h3 { margin: 0 0 6px; padding-right: 34px; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.ask-msg { white-space: pre-line; color: var(--muted); }
body.modal-open { overflow: hidden; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column;
  gap: 8px; z-index: 300; align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: #2b1e12; color: #fff; padding: .75em 1.15em; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: toastIn .2s ease; transition: opacity .3s, transform .3s;
}
.toast.err { background: #9f2d2d; }
.toast.ok { background: #2a6d40; }
.toast.out { opacity: 0; transform: translateY(8px); }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
