:root { --green:#0b6b4f; --ink:#1a1a1a; --bg:#f4f6f5; }
* { box-sizing:border-box; font-family:system-ui,Segoe UI,Roboto,sans-serif; }
body { margin:0; background:var(--bg); color:var(--ink); }
header { background:var(--green); color:#fff; padding:12px 16px; display:flex; justify-content:space-between; align-items:center; }
header h1 { font-size:18px; margin:0; }
.badge { background:#fff2; padding:4px 10px; border-radius:999px; font-size:12px; }
main { max-width:560px; margin:16px auto; padding:0 12px; display:grid; gap:12px; }
.card { background:#fff; border-radius:12px; padding:14px; box-shadow:0 1px 3px rgba(0,0,0,.08); }
label { display:block; margin:6px 0; font-size:13px; }
input, select { width:100%; padding:8px; border:1px solid #ccc; border-radius:8px; margin-top:3px; }
h2 { font-size:15px; margin:0 0 8px; }
.line { display:grid; grid-template-columns:1fr 60px 90px; gap:6px; margin-bottom:6px; }
button { border:0; border-radius:8px; padding:10px 14px; cursor:pointer; font-size:14px; }
button.primary { background:var(--green); color:#fff; width:100%; margin-top:8px; }
#add { background:#eee; width:100%; }
#status { font-size:13px; color:#0b6b4f; min-height:18px; }
.line select { width:100%; padding:8px; border:1px solid #ccc; border-radius:8px; margin-top:3px; }
#fresult, #presult { font-size:13px; color:#0b6b4f; min-height:18px; margin-top:8px; }
#toggleDash { background:var(--green); color:#fff; margin-top:8px; font-size:12px; }
#pdrugs .line { grid-template-columns:1fr 1fr 110px; }
#padd { background:#eee; width:100%; margin-top:6px; }

/* ---- Product grid + cart lines ---- */
.cart-controls { display:flex; gap:6px; }
.cart-controls input { flex:1; }
.scan-btn { background:var(--green); color:#fff; font-size:18px; padding:8px 12px; border:0; border-radius:8px; cursor:pointer; }
.muted { color:#888; font-size:13px; }
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(96px, 1fr)); gap:8px; margin:8px 0; max-height:280px; overflow-y:auto; }
.ptile { background:#eef7f2; border:1px solid #d6e9e0; display:flex; flex-direction:column; align-items:flex-start; gap:2px; padding:8px; text-align:left; min-height:56px; }
.ptile .pn { font-size:12px; font-weight:600; line-height:1.2; }
.ptile .pp { font-size:12px; color:var(--green); font-weight:600; }
.ptile.outofstock { opacity:.5; }
#toggleManual, #madd { background:#eee; width:100%; margin-top:6px; }
#cartlines { margin-top:8px; }
.cartline { display:grid; grid-template-columns:1fr auto auto auto; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid #eee; font-size:13px; }
.cartline .cq { display:flex; align-items:center; gap:6px; }
.cartline .cq button { padding:2px 8px; background:#eee; font-size:14px; }
.cartline .cp { font-weight:600; min-width:64px; text-align:right; }
.cartline .rm { background:#fde; color:#a00; padding:2px 8px; }
#carttotal { font-weight:700; text-align:right; margin:6px 0 0; }

/* ---- Utang picker (on the payment method) ---- */
#utangPicker { grid-template-columns:1fr 1fr auto; margin-top:6px; }
#ucustadd { background:#eee; }

/* ---- Utang ledger tab ---- */
#usearch { margin-bottom:8px; }
.uline { border-bottom:1px solid #eee; padding:8px 0; }
.urow { display:flex; justify-content:space-between; align-items:center; font-size:13px; }
.un { font-weight:600; }
.ub { font-weight:700; color:#b3361c; }
.upay { display:grid; grid-template-columns:1fr auto auto; gap:6px; margin-top:6px; }
.upay button { background:#eee; font-size:12px; padding:6px 10px; }
.uledger { margin-top:6px; font-size:12px; }
.uentry { padding:2px 0; }

/* ---- Receipt (58mm thermal / Save-as-PDF) ---- */
#closeReceipt { background:#eee; width:100%; margin-top:6px; }

/* ---- Dashboard ---- */
.dash-grid { display:grid; grid-template-columns:repeat(2, 1fr); gap:8px; margin-bottom:10px; }
.dcard { background:var(--green); color:#fff; border-radius:8px; padding:10px; text-align:center; }
.dcard .dn { display:block; font-size:20px; font-weight:700; }
.dcard .dl { display:block; font-size:11px; opacity:.8; margin-top:2px; }
h3 { font-size:13px; margin:10px 0 6px; color:#555; }
.pmix { display:grid; grid-template-columns:repeat(2, 1fr); gap:4px; font-size:12px; }
.eis-row { display:flex; gap:10px; font-size:12px; }
.eis-ok { color:#0b6b4f; }
.eis-pend { color:#b8860b; }
.eis-fail { color:#b3361c; }
.barchart { display:flex; align-items:flex-end; gap:4px; height:100px; }
.bar-col { display:flex; flex-direction:column; align-items:center; flex:1; }
.bar { background:var(--green); border-radius:4px 4px 0 0; width:100%; min-height:2px; }
.bar-label { font-size:9px; color:#888; margin-top:2px; }
.exp-item { font-size:12px; padding:2px 0; color:#b3361c; }

/* ---- QR Payment ---- */
#qrDisplay { text-align:center; }
#qrDisplay svg { max-width:200px; margin:10px auto; display:block; }
#qrAmount { font-size:16px; font-weight:700; margin:8px 0; }
#cancelQr { background:#eee; width:100%; margin-top:6px; }

/* ---- Pharmacy ---- */
.pharm-alert { background:#fde; color:#a00; padding:8px; border-radius:8px; font-size:13px; margin-bottom:6px; }
.pharm-warn { background:#ffd; color:#880; padding:8px; border-radius:8px; font-size:13px; margin-bottom:6px; }
#pscanSub { background:#eee; width:100%; margin-top:6px; }

/* ---- Purchase Orders ---- */
.po-grid { display:grid; gap:6px; }
.po-item { display:flex; flex-wrap:wrap; gap:6px; align-items:center; font-size:13px; padding:6px 0; border-bottom:1px solid #eee; }
.po-qty { width:60px; padding:4px; border:1px solid #ccc; border-radius:4px; }
.po-line { display:grid; grid-template-columns:1fr 60px 80px; gap:6px; margin-bottom:6px; }
.po-row { display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid #eee; font-size:13px; }
.po-row button { background:#eee; font-size:12px; padding:4px 8px; }
.po-table { width:100%; border-collapse:collapse; font-size:12px; margin:8px 0; }
.po-table th, .po-table td { padding:4px 6px; border-bottom:1px solid #eee; text-align:left; }
.po-table button { background:#eee; font-size:11px; padding:2px 6px; }

/* ---- Shipments ---- */
.ship-row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:8px 0; border-bottom:1px solid #eee; font-size:13px; }
.ship-row button { background:#eee; font-size:12px; padding:4px 8px; }
.ship-booked { border-left:3px solid #888; padding-left:8px; }
.ship-in_transit { border-left:3px solid #b8860b; padding-left:8px; }
.ship-delivered { border-left:3px solid #0b6b4f; padding-left:8px; }
.ship-overdue { border-left:3px solid #b3361c; padding-left:8px; background:#fff8f6; }
.receipt { font-family:'Courier New',monospace; font-size:12px; max-width:58mm; margin:0 auto; }
.rcenter { text-align:center; }
.rmono { font-family:'Courier New',monospace; font-size:10px; text-align:center; word-break:break-all; }
.ritems { width:100%; border-collapse:collapse; }
.ritems td { padding:2px 0; vertical-align:top; }
.ritems .rqty { text-align:center; width:20%; }
.ritems .ramt { text-align:right; width:35%; }
.rline { display:flex; justify-content:space-between; }
.rtotal { font-weight:700; font-size:14px; }
.receipt hr { border:none; border-top:1px dashed #999; margin:6px 0; }
.receipt svg { width:100px; height:100px; }

@media print {
  body * { visibility:hidden; }
  #receiptView, #receiptView * { visibility:visible; }
  #receiptView { position:absolute; top:0; left:0; width:58mm; box-shadow:none; }
  #printReceipt, #closeReceipt, #receiptView h2 { display:none; }
}
