:root {
  --bg: #f6f3ee;
  --kad: #ffffff;
  --teks: #1f1b16;
  --kelabu: #6b645b;
  --garis: #e4ddd2;
  --utama: #c2410c;
  --utama-gelap: #9a3412;
  --hijau: #15803d;
  --merah: #b91c1c;
  --kuning: #fef3c7;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--teks); font-size: 17px;
  overscroll-behavior: none; user-select: none;
}
input { user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }

.jalur { background: var(--kuning); color: #78350f; text-align: center; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.jalur.merah { background: #fee2e2; color: var(--merah); }

.skrin { min-height: 100vh; }
.skrin-tengah { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.kad-login { background: var(--kad); border-radius: 20px; padding: 28px; width: 100%; max-width: 440px; box-shadow: 0 6px 30px rgba(0,0,0,.06); text-align: center; }
.logo { font-weight: 800; color: var(--utama); font-size: 22px; letter-spacing: .3px; }
.logo.kecil { font-size: 18px; }
h1 { font-size: 22px; margin: 10px 0 20px; }
h2 { font-size: 19px; margin: 0; }
.mesej { color: var(--merah); min-height: 1.4em; margin: 12px 0 0; font-weight: 600; }
.kelabu { color: var(--kelabu); }

.senarai-staf { display: grid; gap: 12px; }
.senarai-staf button { background: var(--bg); border: 2px solid var(--garis); border-radius: var(--radius); padding: 18px; font-size: 19px; font-weight: 600; text-align: left; display: flex; justify-content: space-between; align-items: center; }
.senarai-staf button:active { border-color: var(--utama); }
.senarai-staf small { color: var(--kelabu); font-weight: 500; font-size: 14px; }

.btn-teks { color: var(--utama); font-weight: 600; padding: 8px 4px; }
.pin-titik { display: flex; justify-content: center; gap: 14px; height: 22px; margin-bottom: 22px; }
.pin-titik i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--garis); }
.pin-titik i.isi { background: var(--utama); border-color: var(--utama); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button { background: var(--bg); border-radius: var(--radius); height: 68px; font-size: 26px; font-weight: 600; }
.pad button:active { background: var(--garis); }
.pad .pad-kecil { font-size: 17px; }
.pad .pad-ok { background: var(--utama); color: #fff; font-size: 18px; }

.atas { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: var(--kad); border-bottom: 1px solid var(--garis); }
.atas-kanan { display: flex; gap: 14px; align-items: center; }
.lencana { background: var(--bg); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 15px; }

.jual { display: grid; grid-template-columns: 1fr 400px; height: calc(100vh - 57px); }
body.ada-jalur .jual { height: calc(100vh - 57px - 31px); }
.kiri { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.btn-scan { background: var(--utama); color: #fff; border-radius: var(--radius); padding: 18px; font-size: 21px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 12px; }
.btn-scan:active { background: var(--utama-gelap); }
.btn-scan svg { width: 30px; height: 30px; }
.cari { width: 100%; padding: 15px 16px; font-size: 18px; border: 2px solid var(--garis); border-radius: var(--radius); background: var(--kad); outline: none; }
.cari:focus { border-color: var(--utama); }
.hasil { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-content: start; flex: 1; padding-bottom: 12px; }
.produk { background: var(--kad); border: 1px solid var(--garis); border-radius: var(--radius); padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 104px; }
.produk:active { border-color: var(--utama); background: #fff7ed; }
.produk .nama { font-weight: 600; font-size: 15px; line-height: 1.25; flex: 1; }
.produk .bawah { display: flex; justify-content: space-between; align-items: end; font-size: 14px; }
.produk .harga { font-weight: 700; color: var(--utama); font-size: 16px; }
.produk .stok { color: var(--kelabu); }
.produk .stok.rendah { color: var(--merah); font-weight: 600; }
.kosong { color: var(--kelabu); text-align: center; padding: 30px 10px; grid-column: 1 / -1; }

.kanan { background: var(--kad); border-left: 1px solid var(--garis); display: flex; flex-direction: column; padding: 16px; min-height: 0; }
.troli-atas { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.troli { flex: 1; overflow-y: auto; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--garis); }
.item .nama { font-weight: 600; font-size: 15px; line-height: 1.25; }
.item .sub { font-weight: 700; text-align: right; }
.item .harga-unit { color: var(--kelabu); font-size: 14px; }
.kuantiti { display: flex; align-items: center; gap: 4px; justify-self: end; }
.kuantiti button { width: 40px; height: 40px; border-radius: 10px; background: var(--bg); font-size: 22px; font-weight: 700; }
.kuantiti span { min-width: 34px; text-align: center; font-weight: 700; font-size: 17px; }
.jumlah-baris { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-top: 2px solid var(--teks); font-size: 19px; }
.jumlah-baris strong { font-size: 30px; }
.btn-utama { background: var(--utama); color: #fff; border-radius: var(--radius); padding: 18px; font-size: 21px; font-weight: 700; width: 100%; }
.btn-utama:active:not(:disabled) { background: var(--utama-gelap); }
.btn-kedua { border: 2px solid var(--utama); color: var(--utama-gelap); border-radius: var(--radius); padding: 15px; font-size: 18px; font-weight: 700; width: 100%; margin-bottom: 10px; background: #fff; }
.btn-kedua:active { background: #fff7ed; }
.kecil { font-size: 14px; margin: 6px 0 0; }
.mesej.hijau { color: var(--hijau); }

.lapisan { position: fixed; inset: 0; background: rgba(20,16,12,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.lapisan.gelap { background: #000; flex-direction: column; }
.modal { background: var(--kad); border-radius: 20px; padding: 24px; width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; }
.modal.tengah { text-align: center; }
.modal-atas { display: flex; justify-content: space-between; align-items: center; }
.besar { font-size: 40px; font-weight: 800; margin: 12px 0 18px; }
.cara { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.cara button { border: 2px solid var(--garis); border-radius: var(--radius); padding: 18px 8px; font-weight: 700; font-size: 18px; background: var(--bg); }
.cara button.pilih { border-color: var(--utama); background: #fff7ed; color: var(--utama-gelap); }
#tunai-blok label { font-weight: 600; display: block; margin-bottom: 6px; }
#tunai { width: 100%; font-size: 28px; padding: 12px 14px; border: 2px solid var(--garis); border-radius: var(--radius); outline: none; }
#tunai:focus { border-color: var(--utama); }
.cepat { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.cepat button { background: var(--bg); border-radius: 10px; padding: 12px 16px; font-weight: 700; }
.baki { font-size: 20px; margin: 8px 0 4px; }
.tanda { width: 76px; height: 76px; border-radius: 50%; background: #dcfce7; color: var(--hijau); font-size: 44px; line-height: 76px; margin: 0 auto 10px; font-weight: 800; }
.baki-besar { font-size: 24px; font-weight: 700; color: var(--hijau); margin-bottom: 10px; }

video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.sasaran { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.sasaran span { width: min(78vw, 560px); height: min(32vh, 240px); border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.kamera-mesej { position: absolute; top: 24px; left: 16px; right: 16px; text-align: center; color: #fff; font-size: 19px; font-weight: 700; text-shadow: 0 1px 4px #000; }
.kamera-butang { position: absolute; bottom: 24px; left: 16px; right: 16px; display: flex; gap: 12px; justify-content: center; }
.kamera-butang .btn-utama { max-width: 320px; }
.btn-bulat { background: rgba(255,255,255,.2); color: #fff; border-radius: var(--radius); padding: 18px 22px; font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1f1b16; color: #fff; padding: 14px 22px; border-radius: 12px; font-weight: 600; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.toast.merah { background: var(--merah); }
.toast.hijau { background: var(--hijau); }

/* Menu Pengurus */
.btn-pengurus { background: var(--teks); color: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 15px; }
.urus { padding: 16px; max-width: 1100px; margin: 0 auto; }
.urus-alat { display: flex; gap: 10px; margin-bottom: 10px; }
.kecil-btn { width: auto; margin: 0; padding: 0 18px; font-size: 16px; white-space: nowrap; }
.cip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.cip button { border: 2px solid var(--garis); border-radius: 999px; padding: 8px 14px; font-weight: 600; background: var(--kad); font-size: 15px; }
.cip button.pilih { border-color: var(--teks); background: var(--teks); color: #fff; }
.urus-senarai { display: grid; gap: 8px; margin-top: 8px; }
.baris-produk { background: var(--kad); border: 1px solid var(--garis); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; width: 100%; }
.baris-produk:active { border-color: var(--utama); }
.baris-produk .nama { font-weight: 600; }
.baris-produk .info { color: var(--kelabu); font-size: 14px; }
.baris-produk .kanan-info { text-align: right; font-size: 14px; }
.baris-produk .harga { font-weight: 700; color: var(--utama); font-size: 16px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.tag.sembunyi { background: #e5e7eb; color: #374151; }
.tag.lengkap { background: #fee2e2; color: var(--merah); }
.modal.lebar { max-width: 720px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 14px; }
.grid2 label { font-weight: 600; font-size: 15px; display: flex; flex-direction: column; gap: 6px; }
.grid2 .penuh { grid-column: 1 / -1; }
.grid2 .cari { padding: 12px 14px; font-size: 17px; }
.grid2 .cari:read-only { background: var(--bg); color: var(--kelabu); }
.baris-input { display: flex; gap: 8px; }
.baris-input .cari { flex: 1; min-width: 0; }
.suis { flex-direction: row !important; align-items: center; gap: 10px !important; font-size: 17px !important; }
.suis input { width: 24px; height: 24px; accent-color: var(--utama); }
.stok-blok { margin-top: 20px; padding-top: 16px; border-top: 2px solid var(--garis); }
.stok-blok h3 { margin: 0; font-size: 18px; }

/* Laporan */
.tab-urus { display: flex; gap: 4px; padding: 10px 16px 0; max-width: 1132px; margin: 0 auto; border-bottom: 1px solid var(--garis); }
.tab-urus button { padding: 12px 18px; font-weight: 700; color: var(--kelabu); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab-urus button.pilih { color: var(--teks); border-bottom-color: var(--utama); }
.lap-tarikh { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 6px 0 14px; }
.lap-tarikh label { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; gap: 4px; color: var(--kelabu); }
.lap-tarikh input { font: inherit; padding: 9px 10px; border: 2px solid var(--garis); border-radius: 10px; background: var(--kad); color: var(--teks); }
.lap-tarikh .kecil-btn { height: 44px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--kad); border: 1px solid var(--garis); border-radius: 14px; padding: 14px 16px; }
.tile .lbl { color: var(--kelabu); font-size: 14px; font-weight: 600; }
.tile .nilai { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--kelabu); font-size: 13px; margin-top: 2px; }
.lap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lap-kad { background: var(--kad); border: 1px solid var(--garis); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.lap-kad h3 { margin: 0 0 10px; font-size: 17px; }
.bar-baris { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 15px; }
.bar-baris .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-trek { height: 14px; display: flex; align-items: center; }
.bar { height: 14px; background: var(--utama); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar.kosong { background: var(--garis); }
.bar-baris .nilai { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bar-baris .nilai small { color: var(--kelabu); font-weight: 500; }
.jadual { width: 100%; border-collapse: collapse; font-size: 15px; }
.jadual th { text-align: left; color: var(--kelabu); font-size: 13px; font-weight: 700; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--garis); }
.jadual td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--garis); vertical-align: top; }
.jadual .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jadual .merah { color: var(--merah); font-weight: 700; }
.jadual-bungkus { max-height: 420px; overflow-y: auto; }

.lap-eksport { display: flex; gap: 8px; margin-left: auto; }
#lap-mesej { margin: -6px 0 10px; }

/* Cetak laporan: sembunyikan skrin POS, cetak #cetak sahaja */
#cetak { display: none; }
@media print {
  body.mod-cetak > *:not(#cetak) { display: none !important; }
  body.mod-cetak #cetak { display: block !important; }
  body.mod-cetak { background: #fff; }
  @page { margin: 12mm; }
}

/* Tablet potret / telefon */
@media (max-width: 860px) {
  .jual { grid-template-columns: 1fr; height: auto; }
  body.ada-jalur .jual { height: auto; }
  .kanan { border-left: 0; border-top: 1px solid var(--garis); position: sticky; bottom: 0; max-height: 55vh; }
  .hasil { max-height: 45vh; }
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .lap-grid { grid-template-columns: 1fr; }
}
