/* Hirohiko POS — mobile-first, dipakai di HP saat bazar (sinar matahari: kontras tinggi, tombol besar). */
:root {
  --hijau: #2f6f4e;
  --hijau-tua: #1f4d36;
  --hijau-muda: #e3f1e8;
  --krem: #faf6ee;
  --kartu: #ffffff;
  --teks: #241f1a;
  --redup: #6b625a;
  --garis: #ddd3c4;
  --merah: #b3261e;
  --merah-muda: #fbe4e2;
  --kuning: #8a5a00;
  --kuning-muda: #fdf0d0;
  --biru: #1a5fb4;
  --biru-muda: #e0ecfb;
  --radius: 12px;
  --tinggi-tab: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--krem); color: var(--teks);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--biru); }
.teks-redup { color: var(--redup); }
.teks-kecil { font-size: .85rem; }
.tebal { font-weight: 700; }
.kanan { text-align: right; }

/* ---- kerangka ---- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; background: var(--hijau); color: #fff;
}
.topbar form { margin: 0; }
main { padding: 1rem 1rem calc(var(--tinggi-tab) + 5.5rem + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--kartu);
  border-top: 1px solid var(--garis); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; min-width: 0; min-height: var(--tinggi-tab); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: .7rem; text-decoration: none; color: var(--redup);
}
.tabbar a span { font-size: 1.35rem; line-height: 1; }
.tabbar a.aktif { color: var(--hijau-tua); font-weight: 700; background: var(--hijau-muda); }

/* ---- komponen ---- */
.kartu { background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--radius); padding: .9rem; margin-bottom: .75rem; }
.kartu.batal { opacity: .6; }
.baris { display: flex; align-items: center; gap: .6rem; }
.baris.antar { justify-content: space-between; }
.baris.bungkus { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.grid-tile { margin-top: .75rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: .75rem; }
.tile { background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--radius); padding: .8rem; }
.tile .angka { font-size: 1.4rem; font-weight: 800; }
.tile .label { color: var(--redup); font-size: .85rem; }
.tile.sorot { background: var(--hijau-muda); border-color: var(--hijau); }
.tile.awas { background: var(--merah-muda); border-color: var(--merah); }

label { display: block; font-weight: 600; margin: .8rem 0 .25rem; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=search], input[type=password], select, textarea {
  width: 100%; min-height: 48px; padding: .6rem .75rem; font: inherit; /* 16px: iOS tidak zoom saat fokus */
  border: 1.5px solid var(--garis); border-radius: 10px; background: #fff; color: var(--teks);
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--biru); outline-offset: 1px; }
input.salah { border-color: var(--merah); }

.tombol {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .6rem 1rem;
  font: inherit; font-weight: 700; border: 1.5px solid var(--garis); border-radius: 10px; background: #fff; color: var(--teks);
  cursor: pointer; touch-action: manipulation; text-decoration: none;
}
.tombol:active { transform: scale(.98); }
.tombol[disabled] { opacity: .5; cursor: not-allowed; }
.tombol-utama { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.tombol-bahaya { color: var(--merah); border-color: var(--merah); }
.tombol-hantu { background: transparent; border-color: rgba(255,255,255,.6); color: inherit; }
.tombol-besar { width: 100%; min-height: 56px; font-size: 1.05rem; margin-top: 1rem; }
.tombol-kecil { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.tombol-blok { flex: 1; }

/* pilihan segmen (QRIS/Cash, Lunas/Belum) */
.segmen { display: flex; gap: .5rem; }
.segmen input { position: absolute; opacity: 0; pointer-events: none; }
.segmen label {
  flex: 1; margin: 0; min-height: 52px; display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1.5px solid var(--garis); border-radius: 10px; background: #fff; font-weight: 700; cursor: pointer;
}
.segmen input:checked + label { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.segmen input:focus-visible + label { outline: 3px solid var(--biru); outline-offset: 1px; }

.chip { display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: .3rem .8rem; border: 1.5px solid var(--garis); border-radius: 999px; background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.chip.aktif { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }

.lencana { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #eee; color: var(--teks); }
.lencana.lunas { background: var(--hijau-muda); color: var(--hijau-tua); }
.lencana.belum { background: var(--merah-muda); color: var(--merah); }
.lencana.menunggu { background: var(--kuning-muda); color: var(--kuning); }
.lencana.qris { background: var(--biru-muda); color: var(--biru); }
.lencana.lewat { background: var(--merah); color: #fff; }

.pesan { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .75rem; }
.pesan-error { background: var(--merah-muda); color: var(--merah); border: 1px solid var(--merah); }
.pesan-info { background: var(--biru-muda); color: var(--biru); border: 1px solid var(--biru); }
.pesan-ok { background: var(--hijau-muda); color: var(--hijau-tua); border: 1px solid var(--hijau); }

/* ---- pilih produk (form order) ---- */
.produk { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--garis); }
.produk:last-child { border-bottom: 0; }
.produk .info { flex: 1; min-width: 0; }
.produk .nama { font-weight: 700; overflow-wrap: anywhere; }
.produk.habis { opacity: .5; }
.stepper { display: flex; align-items: center; gap: .3rem; }
.stepper button { width: 48px; height: 48px; min-height: 48px; padding: 0; font-size: 1.5rem; }
.stepper output { min-width: 2rem; text-align: center; font-size: 1.2rem; font-weight: 800; }

.bar-total {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tinggi-tab) + env(safe-area-inset-bottom)); z-index: 15;
  background: var(--kartu); border-top: 2px solid var(--hijau); padding: .6rem 1rem;
}
.bar-total .isi { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: .8rem; }
.bar-total .total { flex: 1; font-size: 1.25rem; font-weight: 800; }
.bar-total .tombol { min-height: 52px; min-width: 9rem; }

/* ---- kartu order ---- */
.order .nama { font-size: 1.2rem; font-weight: 800; overflow-wrap: anywhere; }
.order .id { font-size: .8rem; color: var(--redup); }
.order .jam { font-size: 1.3rem; font-weight: 800; }
.order .kulkas { display: inline-block; background: var(--kuning-muda); color: var(--kuning); font-weight: 800; padding: .15rem .6rem; border-radius: 8px; }
.order ul { margin: .4rem 0; padding-left: 1.2rem; }
.order .aksi { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.order .aksi .tombol { flex: 1 1 9rem; }

/* ---- tabel stok ---- */
.baris-stok { display: grid; grid-template-columns: 1fr; gap: .4rem; padding: .7rem 0; border-bottom: 1px solid var(--garis); }
.baris-stok:last-child { border-bottom: 0; }
.baris-stok .isian { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; align-items: end; }
.baris-stok label { margin: 0 0 .15rem; font-size: .8rem; color: var(--redup); font-weight: 600; }
.baris-stok .nonaktif { opacity: .55; }
.sakelar { display: flex; align-items: center; gap: .4rem; min-height: 48px; font-weight: 600; margin: 0; }
.sakelar input { width: 24px; height: 24px; }

details.kartu summary { cursor: pointer; font-weight: 700; min-height: 32px; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(var(--tinggi-tab) + 5rem + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 520px; margin: 0 auto; padding: .8rem 1rem; border-radius: 10px; background: var(--teks); color: #fff; font-weight: 600;
}
#toast.error { background: var(--merah); }

/* ---- login ---- */
.halaman-login { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.kartu-login { width: 100%; max-width: 380px; background: var(--kartu); border: 1px solid var(--garis); border-radius: 16px; padding: 1.5rem; }

@media (min-width: 720px) {
  .tabbar a { flex-direction: row; gap: .4rem; font-size: .9rem; }
  .baris-stok { grid-template-columns: 1fr 2fr; align-items: end; }
}

/* ---- invoice thermal 58mm (MP-58N: area cetak ±48mm) ---- */
:root { --kertas: 58mm; }
/* Ukuran halaman (lebar = --kertas, tinggi = isi) dipasang invoice.js saat Cetak: Chrome menolak `size: 58mm auto`. */
@page { margin: 0; }
#invoice-layer {
  position: fixed; inset: 0; z-index: 50; overflow: auto; display: flex; padding: 1rem;
  background: rgba(20, 16, 12, .88);
}
.invoice-panel { margin: auto; display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.invoice-kertas { background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); zoom: 1.5; }
.invoice-petunjuk { color: #fff; text-align: center; max-width: 22rem; margin: 0; }
.invoice-aksi { display: flex; gap: .6rem; }
.invoice {
  width: var(--kertas); padding: 3mm 5mm 5mm; box-sizing: border-box; background: #fff; color: #000;
  font: 11px/1.35 "Courier New", Courier, monospace;
}
.inv-brand { text-align: center; font-size: 18px; font-weight: 900; letter-spacing: .18em; }
.inv-garis { border-top: 1px dashed #000; margin: 2mm 0; }
.inv-baris { display: flex; justify-content: space-between; gap: 2mm; }
.inv-baris span:last-child { text-align: right; overflow-wrap: anywhere; }
.inv-nama { font-weight: 700; overflow-wrap: anywhere; }
.inv-item { margin-bottom: 1mm; }
.inv-total { font-size: 14px; font-weight: 900; }
.inv-status { font-weight: 900; }
.inv-terima { text-align: center; }

@media print {
  html, body { background: #fff !important; }
  body > *:not(#invoice-layer) { display: none !important; }
  #invoice-layer { position: static; display: block; padding: 0; overflow: visible; background: none; }
  .invoice-panel { display: block; margin: 0; }
  .invoice-panel > :not(.invoice-kertas) { display: none !important; }
  .invoice-kertas { zoom: 1; box-shadow: none; }
}
