/* Portal penduduk. Tema merah jambu seperti portal admin. Token warna di :root sahaja. */
:root {
  --bg: #fdf6f6;
  --surface: #ffffff;
  --surface-2: #fbeeee;
  --text: #2b1a1d;
  --muted: #6d5a5e;
  --border: #f0dcdd;
  --border-strong: #e4c4c7;
  --primary: #c4434f;
  --primary-ink: #ffffff;
  --primary-soft: #fbe6e8;
  --hero-1: #b02d3a;
  --hero-2: #c4434f;
  --ok: #1d7a4d; --ok-soft: #e3f4ea;
  --warn: #8a5800; --warn-soft: #fdf0d5;
  --bad: #b3261e; --bad-soft: #fde8e6;
  --info: #2a5db0; --info-soft: #e6eefb;
  --mute: #5f5558; --mute-soft: #f1eaea;
  --shadow: 0 1px 2px rgba(60, 20, 25, .06), 0 6px 20px rgba(60, 20, 25, .06);
  --radius: 16px;
  --sidebar-w: 264px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171012;
  --surface: #221719;
  --surface-2: #2b1d20;
  --text: #f6ebec;
  --muted: #c3a9ad;
  --border: #3a2a2d;
  --border-strong: #55393e;
  --primary: #e2646f;
  --primary-ink: #1a0d0f;
  --primary-soft: #3a2024;
  --hero-1: #7a2430;
  --hero-2: #a1303d;
  --ok: #6fd39b; --ok-soft: #14301f;
  --warn: #f0c36a; --warn-soft: #3a2d12;
  --bad: #ff9a92; --bad-soft: #40201e;
  --info: #8db4f5; --info-soft: #18263d;
  --mute: #c9b8bb; --mute-soft: #33272a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 18px; height: 18px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: 10px; z-index: 100; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Rangka ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 14px; }
.logo { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; }
.brand-n { font-weight: 800; line-height: 1.2; }
.brand-s { font-size: .8rem; color: var(--muted); }
.nav-h { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 24px;
}
.spacer { flex: 1; }
.demo-pill { font-size: .8rem; background: var(--warn-soft); color: var(--warn); padding: 4px 10px; border-radius: 999px; font-weight: 600; }
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px; outline: none; }
.footer { padding: 18px 24px 28px; color: var(--muted); font-size: .82rem; max-width: 1180px; margin: 0 auto; width: 100%; }
.scrim { display: none; }
.icon-btn.mobile-only { display: none; }

/* ---------- Butang dan kawalan ---------- */
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.btn {
  border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); padding: 10px 18px;
  border-radius: 12px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); text-decoration: underline; cursor: pointer; font-weight: 600; }
.profile { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 800; }
.pname { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 40;
}
.menu-h { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-h b { display: block; }
.menu-h span { color: var(--muted); font-size: .85rem; word-break: break-all; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; background: none; border: 0; padding: 10px; border-radius: 10px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }

/* ---------- Kad dan grid ---------- */
.hero {
  background: linear-gradient(120deg, var(--hero-1), var(--hero-2)); color: #fff; border-radius: 20px; padding: 22px 26px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; box-shadow: var(--shadow);
}
.eyebrow { font-size: .85rem; opacity: .92; }
.hero h1 { font-size: 1.55rem; line-height: 1.25; margin: 2px 0; }
.hero-s { opacity: .95; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .55); color: #fff; padding: 8px 14px; border-radius: 999px; text-decoration: none; font-size: .9rem; font-weight: 600; }
.pill:hover { background: rgba(255, 255, 255, .28); }
.stack > * + * { margin-top: 18px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.05rem; margin-bottom: 10px; }
.stat-l { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat-v { font-size: 1.85rem; font-weight: 800; line-height: 1.2; margin: 4px 0; font-variant-numeric: tabular-nums; }
.stat-s { font-size: .85rem; color: var(--muted); }
.stat.accent { background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff; border: 0; }
.stat.accent .stat-l, .stat.accent .stat-s { color: rgba(255, 255, 255, .92); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.err { text-align: center; }
.err p { margin-bottom: 12px; }
.note { font-size: .85rem; color: var(--muted); }
.note.warn { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 12px; }
.note.safe { background: var(--info-soft); color: var(--info); padding: 12px 14px; border-radius: 12px; }

/* ---------- Lencana ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge .ico { width: 14px; height: 14px; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-mute { background: var(--mute-soft); color: var(--mute); }

/* ---------- Borang ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .lbl { font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 12px; padding: 10px 12px;
}
textarea { min-height: 110px; resize: vertical; }
.field-err { color: var(--bad); font-size: .83rem; min-height: 1.1em; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.inline-pw { position: relative; }
.inline-pw input { padding-right: 76px; }
.inline-pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.rules { list-style: none; padding: 0; margin: 0 0 14px; font-size: .85rem; color: var(--muted); }
.rules li::before { content: "○ "; }
.rules li.ok { color: var(--ok); }
.rules li.ok::before { content: "● "; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.chip-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Jadual ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- Carta ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-l { stroke: var(--border); stroke-width: 1; }
.chart .bar-b { fill: var(--border-strong); }
.chart .bar-p { fill: var(--primary); }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.strip { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.strip li { border-radius: 12px; padding: 8px 6px; text-align: center; font-size: .8rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.strip .ico { width: 16px; height: 16px; }
details.tbl-d { margin-top: 12px; }
details.tbl-d summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.meter-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }
progress.meter { width: 100%; height: 12px; border: 0; border-radius: 99px; overflow: hidden; background: var(--border); appearance: none; -webkit-appearance: none; }
progress.meter::-webkit-progress-bar { background: var(--border); }
progress.meter::-webkit-progress-value { background: var(--primary); border-radius: 99px; }
progress.meter::-moz-progress-bar { background: var(--primary); }

/* ---------- Pengumuman ---------- */
.ann { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface); }
.ann + .ann { margin-top: 12px; }
.ann-h { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: .85rem; }
.ann h3 { font-size: 1.02rem; margin-bottom: 6px; }
.ann p { color: var(--text); }
.ann.pinned { border-color: var(--primary); }
.mini-ann { list-style: none; padding: 0; margin: 0; }
.mini-ann li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.mini-ann li:last-child { border-bottom: 0; }
.mini-ann span { display: block; font-size: .82rem; color: var(--muted); }

/* ---------- Bayaran dan kalkulator ---------- */
.steps { padding-left: 22px; margin: 0; }
.steps li + li { margin-top: 8px; }
.copy-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.copy-row:last-child { border-bottom: 0; }
.copy-row span.k { color: var(--muted); font-size: .85rem; display: block; }
.copy-row b { word-break: break-word; }
.big-total { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.calc-row.total { border-bottom: 0; font-weight: 800; font-size: 1.1rem; }
.result-list { list-style: none; padding: 0; margin: 12px 0 0; }
.result-list li { padding: 6px 0; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 90px; text-align: center; }

/* ---------- Resit ---------- */
.receipt { border: 1px dashed var(--border-strong); border-radius: 14px; padding: 18px; background: var(--surface); }
.receipt h3 { font-size: 1.1rem; }
.receipt .rc-no { font-weight: 800; font-size: 1.15rem; }
.receipt .void-b { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-weight: 600; }

/* ---------- Modal dan toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(20, 8, 10, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal { background: var(--surface); border-radius: 20px; max-width: 480px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 620px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal-h h2 { font-size: 1.15rem; }
.modal-b { padding: 8px 18px 18px; }
body.modal-open { overflow: hidden; }
#toastRoot { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); text-align: center; }

/* ---------- Log masuk ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 12px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.login-tools { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.gbtn { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); padding: 11px; border-radius: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; }
.gbtn:hover { background: var(--surface-2); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 14px 0; font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.links { display: flex; justify-content: space-between; margin-top: 12px; font-size: .9rem; }

/* ---------- Responsif ---------- */
@media (max-width: 900px) {
  .icon-btn.mobile-only { display: inline-grid; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 8, 10, .5); z-index: 45; }
  .topbar { padding: 0 14px; }
  main { padding: 16px 14px; }
  .pname { display: none; }
  .demo-pill { display: none; }
}
@media (max-width: 720px) {
  .tbl.stack-m thead { display: none; }
  .tbl.stack-m, .tbl.stack-m tbody, .tbl.stack-m tr, .tbl.stack-m td { display: block; width: 100%; }
  .tbl.stack-m tr { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 12px; background: var(--surface); }
  .tbl.stack-m td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .tbl.stack-m td::before { content: attr(data-label); color: var(--muted); text-align: left; font-size: .8rem; font-weight: 600; }
  .hero h1 { font-size: 1.3rem; }
  .meter-row { grid-template-columns: 90px 1fr auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Cetak resit ---------- */
@media print {
  body.printing * { visibility: hidden !important; }
  body.printing #receiptPrint, body.printing #receiptPrint * { visibility: visible !important; }
  body.printing #receiptPrint { position: absolute; left: 0; top: 0; width: 100%; border: 0; color: #000; background: #fff; }
}

.btn.full { width: 100%; }
.pad { padding: 24px; }
.legend .lg-b { background: var(--border-strong); }
.legend .lg-p { background: var(--primary); }

.google-box { display: flex; justify-content: center; min-height: 0; }
.notice-actions { display: grid; gap: 10px; margin-top: 16px; }
