/* ============================================================
   Mặt phiếu in — dùng cho cả xem trước trong app lẫn cửa sổ in riêng.
   Giấy quầy casino thường là khổ hẹp (80mm) hoặc A5; đặt bề rộng cố định để
   con số không nhảy chỗ giữa các máy in khác nhau.
   ============================================================ */
.phieu {
  position: relative;
  background: #fff;
  color: #111;
  padding: 16px 18px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: ui-sans-serif, system-ui, "Noto Sans", sans-serif;
  font-size: 12px;
  line-height: 1.45;
  max-width: 520px;
  box-sizing: border-box;
}
.phieu-preview {
  overflow-x: auto;
  padding: 12px;
  margin-top: 10px;
  border: 1px solid var(--line, #ddd);
  border-radius: 8px;
  background: #e9e9ec;
}
.phieu-preview .phieu { margin: 0 auto; max-width: none; }
.phieu[data-paper="a5"] { width: 132mm; }
.phieu[data-paper="thermal80"] { width: 72mm; padding: 10px; font-size: 10px; }
.phieu[data-paper="thermal80"] .phieu-hd { gap: 6px; flex-wrap: wrap; }
.phieu[data-paper="thermal80"] .phieu-hd .mono { font-size: 12px !important; }
.phieu[data-paper="thermal80"] .tbl th,
.phieu[data-paper="thermal80"] .tbl td { padding: 3px; font-size: 9px; }
.phieu[data-paper="thermal80"] .phieu-ky { gap: 6px; }
.phieu[data-paper="a4"] { width: 190mm; }
.print-setup { align-items: end; }
.phieu .cn { color: #666; font-size: 11px; }
.phieu .muted { color: #666; }
.phieu b { color: #000; }

.phieu-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 10px;
}

/* Dấu đóng trên MẶT GIẤY, không phải nhãn ở góc màn hình — tờ giấy rời khỏi
   máy tính thì chỉ còn mực nói hộ. */
.phieu-dau {
  position: absolute; top: 44%; left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  font-size: 34px; font-weight: 800; letter-spacing: 3px;
  padding: 6px 20px; border: 4px solid currentColor; border-radius: 8px;
  opacity: .28; pointer-events: none; white-space: nowrap;
}
.phieu-dau.sao { color: #b8860b; }
.phieu-dau.huy { color: #c0392b; opacity: .34; }

.phieu .calc { display: flex; flex-direction: column; gap: 2px; }
.phieu .calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.phieu .calc-row.total {
  border-top: 1px solid #111; margin-top: 4px; padding-top: 6px; font-weight: 700; font-size: 13px;
}
.phieu .tbl { width: 100%; border-collapse: collapse; }
.phieu .tbl th, .phieu .tbl td { border-bottom: 1px solid #e3e3e3; padding: 4px 6px; text-align: left; }
.phieu .tbl th { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: #555; }
.phieu .tbl .r, .phieu .r { text-align: right; }
.phieu .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.phieu .hint-box { border: 1px solid #c0392b; color: #c0392b; padding: 6px 8px; border-radius: 4px; font-size: 11px; }

.phieu-ky {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 26px; padding-top: 8px;
}
.phieu-ky > div {
  border-top: 1px solid #999; padding-top: 6px; font-size: 11px; min-height: 42px;
}
.phieu-ft {
  margin-top: 12px; padding-top: 6px; border-top: 1px dashed #bbb;
  font-size: 10px; color: #666;
}

.print-body { margin: 0; padding: 0; background: #fff; }
.print-body .phieu {
  width: var(--receipt-content-width, 132mm);
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
}

@media (max-width: 680px) {
  .print-setup { grid-template-columns: 1fr; }
}

@media print {
  /* Ctrl+P trong app chỉ in mặt phiếu. Popup in riêng vốn chỉ chứa phiếu nên
     giữ document flow để phiếu dài còn phân trang, không bị absolute cắt mất. */
  body:not(.print-body) * { visibility: hidden; }
  body:not(.print-body) .phieu,
  body:not(.print-body) .phieu * { visibility: visible; }
  body:not(.print-body) .phieu {
    position: absolute; left: 0; top: 0;
    border: none; border-radius: 0; max-width: none; width: 100%;
  }
  .print-body .phieu { position: static; }
  .phieu-dau { opacity: .3; }        /* mực nhạt vẫn phải đọc được */
  .btn, .modal-hd, .modal-ft { display: none !important; }
  @page { size: A5 portrait; margin: 8mm; }
}
