/* =========================================================
   Ayam Golek Almari Pasir Puteh – Program Kesetiaan
   Palet: merah, jingga, krim, hitam
   ========================================================= */
:root {
  --red: #b3261e;
  --red-dark: #8c1d17;
  --orange: #e8710a;
  --orange-soft: #ffe2c2;
  --cream: #fff6e8;
  --cream-2: #fbead0;
  --black: #1d1412;
  --ink: #2b201d;
  --muted: #6b5a53;
  --line: #ead8bf;
  --white: #ffffff;
  --green: #1e7a3c;
  --green-soft: #dcf3e3;
  --amber-soft: #fff1c9;
  --red-soft: #fde2df;
  --radius: 16px;
  --shadow: 0 6px 22px rgba(60, 25, 10, .10);
  --tap: 52px;
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: var(--black); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--red); }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Kerangka ---------- */
.app-header {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--white);
  padding: 14px 16px 14px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.app-header .brand { flex: 1; min-width: 0; }
.app-header .brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: .2px; line-height: 1.2; }
.app-header .brand-sub { font-size: .8rem; opacity: .9; }
.logo-slot {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: rgba(255,255,255,.15); border: 2px dashed rgba(255,255,255,.45);
  display: grid; place-items: center; overflow: hidden; font-size: .6rem; text-align: center; line-height: 1.1;
}
.logo-slot img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-slot.has-logo { border: 0; background: #fff; }
.header-btn { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 12px; padding: 10px 12px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 44px; }

main:focus { outline: none; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; }
.wide main, main.wide { max-width: 1100px; }

.banner { padding: 10px 16px; font-size: .9rem; text-align: center; font-weight: 600; }
.banner.offline { background: var(--black); color: #ffd9a8; }
.banner.test { background: var(--amber-soft); color: #6a4a00; border-bottom: 1px solid #ecd48a; }

/* ---------- Navigasi bawah (pelanggan) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--white); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(60,25,10,.06);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabbar a .ico { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--red); }
.tabbar a.active .ico { transform: scale(1.1); }

/* ---------- Kad ---------- */
.card {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px; border: 1px solid #f3e4cc;
}
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }

.loyalty-card {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(circle at 110% -10%, rgba(255,190,90,.55) 0, transparent 45%),
    linear-gradient(140deg, var(--red) 0%, #9b1f18 55%, var(--black) 100%);
  border-radius: 22px; padding: 20px; box-shadow: 0 12px 30px rgba(140,29,23,.35);
  margin-bottom: 16px;
}
.loyalty-card .lc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.loyalty-card .lc-shop { font-weight: 800; font-size: .95rem; letter-spacing: .3px; }
.loyalty-card .lc-label { font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; opacity: .85; }
.loyalty-card .lc-name { font-size: 1.3rem; font-weight: 800; margin-top: 14px; }
.loyalty-card .lc-phone { opacity: .9; font-size: .95rem; letter-spacing: .5px; }
.loyalty-card .lc-points { font-size: 3rem; font-weight: 900; line-height: 1; margin-top: 16px; }
.loyalty-card .lc-points small { font-size: 1rem; color: #ffe2c2; font-weight: 700; margin-left: 6px; }
.loyalty-card .lc-pending { margin-top: 6px; font-size: .88rem; color: #ffe2c2; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: rgba(255,255,255,.18); }

.qr-box { background: #fff; border-radius: 18px; padding: 16px; text-align: center; box-shadow: var(--shadow); margin-bottom: 16px; border: 3px solid var(--orange); }
.qr-box svg { width: min(72vw, 260px); height: auto; display: block; margin: 0 auto 8px; }
.qr-box .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 2px; }
.qr-box.bright { position: fixed; inset: 0; z-index: 90; border: 0; border-radius: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; }
.qr-box.bright svg { width: min(86vw, 420px); }

/* ---------- Butang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px; border-radius: 14px; border: 2px solid transparent;
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none;
  background: var(--red); color: #fff; transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: grayscale(.2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--orange); outline-offset: 2px;
}
.btn.block { width: 100%; }
.btn.secondary { background: var(--white); color: var(--red); border-color: var(--red); }
.btn.orange { background: var(--orange); color: #1d1412; }
.btn.dark { background: var(--black); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.success { background: var(--green); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.sm { min-height: 42px; padding: 8px 14px; font-size: .9rem; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }

/* ---------- Borang ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.field .err { font-size: .85rem; color: var(--red); margin-top: 4px; font-weight: 600; }
input:not([type]), input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], input[type=date], input[type=url], select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px; font: inherit; font-size: 1.05rem;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input.invalid, textarea.invalid { border-color: var(--red); background: #fff8f7; }
input.big { font-size: 1.6rem; font-weight: 800; text-align: center; letter-spacing: 1px; }
.pin-input { letter-spacing: 8px; text-align: center; font-size: 1.5rem !important; font-weight: 800; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--cream); border-radius: 12px; border: 2px solid var(--line); cursor: pointer; }
.check input { width: 26px; height: 26px; flex: none; margin: 0; accent-color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Senarai ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 700; }
.list .sub { font-size: .85rem; color: var(--muted); }
.list a.row { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; width: 100%; min-height: 48px; }
.pts { font-weight: 800; white-space: nowrap; }
.pts.plus { color: var(--green); }
.pts.minus { color: var(--red); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--orange-soft); color: var(--red-dark); display: grid; place-items: center; font-weight: 800; flex: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.pending { background: var(--amber-soft); color: #7a5600; }
.badge.approved, .badge.completed, .badge.active { background: var(--green-soft); color: var(--green); }
.badge.rejected, .badge.suspended, .badge.void { background: var(--red-soft); color: var(--red-dark); }
.badge.cancelled, .badge.inactive { background: #eee6de; color: #6b5a53; }
.badge.test { background: #1d1412; color: #ffd9a8; }
.badge.sample { background: #e8e1ff; color: #43349a; }

/* ---------- Ganjaran ---------- */
.reward { display: flex; gap: 14px; align-items: center; }
.reward .ico { width: 56px; height: 56px; flex: none; border-radius: 14px; background: var(--orange-soft); display: grid; place-items: center; font-size: 1.7rem; }
.reward .need { font-weight: 800; color: var(--red); }
.reward .ico.has-img { padding: 0; border: 0; overflow: hidden; cursor: zoom-in; background: var(--cream-2); }
.reward .ico img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster { display: block; position: relative; width: calc(100% + 36px); margin: -18px -18px 14px; padding: 0; border: 0; cursor: zoom-in;
  background: var(--cream-2); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.poster img { display: block; width: 100%; max-height: 340px; object-fit: contain; background: var(--cream-2); }
.poster .zoom { position: absolute; right: 10px; bottom: 10px; background: rgba(29,20,18,.75); color: #fff; font-size: .75rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
dialog.poster-view { width: min(96vw, 640px); }
dialog.poster-view img { display: block; width: 100%; max-height: 72vh; object-fit: contain; border-radius: 12px; background: var(--cream-2); }
.thumb { width: 64px; height: 64px; flex: none; border-radius: 12px; overflow: hidden; background: var(--orange-soft); display: grid; place-items: center; font-size: 1.6rem; border: 1px solid var(--line); }
.bonus-banner { background: linear-gradient(135deg, var(--orange) 0%, #f39a2c 100%); color: #1d1412; border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; text-align: center; font-size: 1.05rem; font-weight: 600; box-shadow: 0 6px 18px rgba(232,113,10,.25); }
.bonus-hero { text-align: center; background: var(--cream); border-radius: 16px; padding: 16px; margin: 6px 0 14px; }
.bonus-hero .big { font-size: 3rem; font-weight: 900; color: var(--green); line-height: 1; }
.progress { height: 8px; background: var(--cream-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--red)); border-radius: 99px; }

/* ---------- Keadaan ---------- */
.state { text-align: center; padding: 34px 16px; color: var(--muted); }
.state .ico { font-size: 2.6rem; margin-bottom: 8px; }
.state h3 { color: var(--ink); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--cream-2); border-top-color: var(--red); animation: spin .8s linear infinite; margin: 0 auto 10px; }
.btn .spinner { width: 20px; height: 20px; border-width: 3px; margin: 0; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.btn.secondary .spinner, .btn.ghost .spinner { border-color: var(--cream-2); border-top-color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #f6e7d2 25%, #fbf1e2 50%, #f6e7d2 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; font-size: .95rem; border: 1px solid transparent; }
.alert.error { background: var(--red-soft); color: var(--red-dark); border-color: #f5b8b1; }
.alert.success { background: var(--green-soft); color: var(--green); border-color: #a9dcb9; }
.alert.info { background: var(--orange-soft); color: #7a3b00; border-color: #f8c48d; }
.alert.warn { background: var(--amber-soft); color: #6a4a00; border-color: #ecd48a; }

/* ---------- Toast & dialog ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); z-index: 100; width: min(92vw, 480px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--black); color: #fff; padding: 14px 16px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; animation: pop .2s ease-out; pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red-dark); }
@keyframes pop { from { transform: translateY(-10px); opacity: 0; } }

dialog.modal { border: 0; border-radius: 20px; padding: 0; width: min(94vw, 480px); box-shadow: 0 20px 60px rgba(0,0,0,.35); color: var(--ink); }
dialog.modal::backdrop { background: rgba(29,20,18,.55); }
dialog.modal .m-body { padding: 22px 20px 8px; max-height: 70vh; overflow: auto; }
dialog.modal .m-actions { padding: 12px 20px 20px; display: flex; gap: 10px; flex-wrap: wrap-reverse; }
dialog.modal .m-actions .btn { flex: 1 1 140px; }
.confirm-figure { background: var(--cream); border-radius: 14px; padding: 14px; margin: 10px 0; }
.confirm-figure .row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.confirm-figure .row strong { font-size: 1.05rem; }
.confirm-figure .total { border-top: 2px dashed var(--line); margin-top: 6px; padding-top: 8px; font-size: 1.1rem; }

/* ---------- Umum ---------- */
.hero { text-align: center; padding: 18px 8px 8px; }
.hero .big-logo { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 14px; background: #fff; border: 3px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: .72rem; overflow: hidden; }
.hero .big-logo img { width: 100%; height: 100%; object-fit: contain; }
.hero h1 { font-size: 1.6rem; color: var(--red-dark); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 14px; padding: 14px; border: 1px solid #f3e4cc; }
.stat .v { font-size: 1.3rem; overflow-wrap: anywhere; font-weight: 900; color: var(--black); }
.stat .l { font-size: .8rem; color: var(--muted); font-weight: 600; }
.info-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row .ico { font-size: 1.3rem; width: 28px; text-align: center; flex: none; }
.pre { white-space: pre-line; }
.promo { border-left: 5px solid var(--orange); }
.section-title { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 22px 4px 10px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.segmented { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.segmented button { flex: none; min-height: 42px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--ink); }
.segmented button.active { background: var(--black); color: #fff; border-color: var(--black); }
.footer-note { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 24px; }
.link-btn { background: none; border: 0; color: var(--red); font: inherit; font-weight: 700; cursor: pointer; padding: 8px 0; text-decoration: underline; min-height: 44px; }

/* ---------- Admin ---------- */
.admin-nav { background: var(--black); position: sticky; top: 0; z-index: 19; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a { display: inline-flex; align-items: center; gap: 6px; color: #e9d8c7; text-decoration: none; padding: 0 14px; min-height: 50px; font-weight: 700; font-size: .9rem; border-bottom: 3px solid transparent; }
.admin-nav a.active { color: #fff; border-bottom-color: var(--orange); }
.admin-nav .count { background: var(--orange); color: var(--black); border-radius: 99px; padding: 1px 7px; font-size: .75rem; }
.scanner { position: relative; background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 1 / 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 4px solid var(--orange); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.customer-head { display: flex; gap: 14px; align-items: center; }
.customer-head .avatar { width: 56px; height: 56px; font-size: 1.3rem; }
.balance-pill { background: var(--black); color: #fff; border-radius: 16px; padding: 12px 16px; text-align: center; }
.balance-pill .v { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.balance-pill .l { font-size: .72rem; opacity: .8; }
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
