<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cetak Marker PMG</title>
<style>
@page { size: 5cm 3cm; margin: 0; }
html, body { margin: 0; padding: 0; }
.mk{
	width:5cm; height:3cm; box-sizing:border-box; border:1px solid #000;
	overflow:hidden; font-family:Arial,Helvetica,sans-serif; text-align:center;
	page-break-after:always; position:relative; background:#fff;
}
.mk .nm{font-size:8.5pt;font-weight:bold;line-height:1.05;padding-top:1mm;}
.mk .cd{font-size:9pt;font-weight:bold;line-height:1.1;}
.mk .mid{display:flex;border-top:1px solid #000;border-bottom:1px solid #000;margin-top:0.6mm;height:8mm;}
.mk .num{width:1.1cm;border-right:1px solid #000;font-size:11pt;font-weight:bold;display:flex;align-items:center;justify-content:center;}
.mk .pr{flex:1;font-size:7.5pt;font-weight:bold;display:flex;flex-direction:column;justify-content:center;line-height:1.15;}
.mk .nt{font-size:6.8pt;font-weight:bold;line-height:1.15;padding:0.6mm 1mm;}
.mk .pmgcode{position:absolute;bottom:0.5mm;left:0;right:0;font-size:6.5pt;font-weight:bold;}
@media print { .screen-only{display:none !important;} .mk{border:1px solid #000;} }
</style>
</head>
<body>
<?php if (!empty($msg)): ?>
	<div style="font-family:Arial;padding:20px;font-size:14px;"><?php echo htmlspecialchars($msg); ?></div>
<?php else: ?>
	<div class="screen-only" style="font-family:Arial;padding:10px;background:#eee;font-size:12px;">
		<button onclick="window.print()" style="padding:8px 14px;font-size:13px;">🖨 Cetak Sekarang</button>
		&nbsp;Kertas: <b>5 × 3 cm</b>. Halaman ini sudah dikunci sebagai <b>DICETAK</b> — menutup/membatalkan print tidak membuka kunci.
	</div>
	<?php foreach ($markers as $m): ?>
	<div class="mk">
		<div class="nm"><?php echo htmlspecialchars($m['customer']); ?></div>
		<div class="cd"><?php echo htmlspecialchars($m['code5']); ?> - <?php echo htmlspecialchars($m['outlet']); ?></div>
		<div class="mid">
			<div class="num"><?php echo $m['num']; ?>/<?php echo $m['tot']; ?></div>
			<div class="pr">
				<span><?php echo htmlspecialchars($m['product']); ?></span>
				<span><?php echo htmlspecialchars($m['duedate']); ?></span>
			</div>
		</div>
		<div class="nt"><?php echo htmlspecialchars($m['notes']); ?></div>
		<div class="pmgcode">PMG: <?php echo htmlspecialchars($m['pmg_marker_code']); ?></div>
	</div>
	<?php endforeach; ?>
	<script>window.onload = function(){ setTimeout(function(){ window.print(); }, 500); };</script>
<?php endif; ?>
</body>
</html>