/* =========================================================
   Mẫu chứng từ (báo giá / hoá đơn / phiếu nhập) — luôn nền trắng
   ========================================================= */
.paper {
  --acc: #0e7490;
  --acc-soft: #e7f1f4;
  --acc-mid: #c9e0e6;
  --acc-dark: #1e1b4b;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --rule: #e2e8f0;
  width: 794px;
  min-height: 1123px;
  background: #fff;
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  padding: 0 0 36px;
  position: relative;
  overflow: hidden;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.paper.auto-h { min-height: 0; }
.paper * { box-sizing: border-box; }
.paper .pad { padding: 0 44px; }
.paper table { width: 100%; border-collapse: collapse; }
.paper .num { font-variant-numeric: tabular-nums; }
.paper .r { text-align: right; } .paper .c { text-align: center; }
.paper .muted { color: var(--ink-2); }
.paper .pre { white-space: pre-line; }

/* ---- header ---- */
.paper .hdr { display: flex; gap: 18px; align-items: center; }
.paper .logo { width: 72px; height: 72px; border-radius: 16px; object-fit: contain; flex: none; background: #fff; }
.paper .logo-ph { width: 64px; height: 64px; border-radius: 16px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 26px; color: #fff; background: var(--acc); }
.paper .co-name { font-size: 22px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.paper .co-slogan { font-size: 12px; opacity: .85; margin-top: 2px; }
.paper .co-line { font-size: 12px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 14px; }

.paper .title-blk { text-align: center; margin: 26px 0 6px; }
.paper .doc-title { font-size: 26px; font-weight: 800; letter-spacing: 1.5px; color: var(--acc); text-transform: uppercase; }
.paper .doc-sub { font-size: 14px; font-weight: 600; margin-top: 4px; }
.paper .doc-meta { display: flex; justify-content: center; gap: 22px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.paper .doc-meta b { color: var(--ink); }
.paper .intro { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); white-space: pre-line; }

.paper .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.paper .party { border-radius: 12px; padding: 12px 14px; background: var(--acc-soft); }
.paper .party h5 { margin: 0 0 6px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--acc); }
.paper .party .nm { font-weight: 700; font-size: 14px; }
.paper .party .ln { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ---- items ---- */
.paper .items { margin-top: 18px; }
.paper .items th { background: var(--acc); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 9px 8px; font-weight: 700; text-align: left; }
.paper .items th:first-child { border-radius: 8px 0 0 8px; }
.paper .items th:last-child { border-radius: 0 8px 8px 0; }
.paper .items td { padding: 9px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.paper .items tbody tr:nth-child(even) td { background: #f8fafc; }
.paper .items .nm { font-weight: 600; white-space: pre-line; line-height: 1.35; }
.paper .items .sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.paper .items .im { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; display: block; border: 1px solid var(--rule); }
.paper .items.big .im { width: 104px; height: 104px; border-radius: 10px; }
.paper .items .stt { width: 34px; color: var(--ink-3); font-weight: 600; }

/* ---- totals ---- */
.paper .sum-wrap { display: flex; gap: 22px; margin-top: 16px; align-items: flex-start; }
.paper .sum-left { flex: 1; min-width: 0; }
.paper .sum { width: 320px; flex: none; }
.paper .sum .tr { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.paper .sum .tr span { color: var(--ink-2); }
.paper .sum .grand { margin-top: 6px; padding: 12px 14px; border-radius: 12px; background: var(--acc); color: #fff; align-items: center; }
.paper .sum .grand span { color: rgba(255,255,255,.85); font-weight: 600; }
.paper .sum .grand b { font-size: 20px; }
.paper .words { font-size: 12.5px; font-style: italic; color: var(--ink-2); margin-top: 8px; }
.paper .bank { display: flex; gap: 14px; align-items: center; border: 1px dashed var(--acc-mid); border-radius: 12px; padding: 12px; }
.paper .bank .qr { width: 104px; height: 104px; flex: none; }
.paper .bank .qr img, .paper .bank .qr canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.paper .bank h6 { margin: 0 0 4px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--acc); }
.paper .bank .ln { font-size: 12.5px; margin-top: 1px; }
.paper .note { margin-top: 16px; font-size: 12.5px; color: var(--ink-2); white-space: pre-line; border-left: 3px solid var(--acc-mid); padding: 4px 0 4px 12px; }
.paper .perks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.paper .perk { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; background: var(--acc-soft); color: var(--acc); font-weight: 600; font-size: 12px; }
.paper .signs { display: grid; grid-template-columns: 1fr 1fr; text-align: center; margin-top: 30px; }
.paper .signs b { display: block; font-size: 13px; }
.paper .signs i { font-size: 11.5px; color: var(--ink-3); }
.paper .signs .sp { height: 70px; }
.paper .foot { margin-top: 26px; text-align: center; font-size: 13px; font-weight: 600; color: var(--acc); }
.paper .stamp { position: absolute; right: 40px; top: 142px; transform: rotate(-14deg); border: 3px solid; border-radius: 10px; padding: 4px 14px; font-weight: 800; font-size: 20px; letter-spacing: 2px; opacity: .8; text-transform: uppercase; }
.paper .stamp.paid { color: #059669; }
.paper .stamp.cancel { color: #dc2626; }
.paper .stamp.debt { color: #d97706; font-size: 15px; }

/* ---- Mẫu HIỆN ĐẠI ---- */
.paper.tpl-modern .band {
  color: #fff; padding: 28px 44px 26px;
  background: linear-gradient(120deg, var(--acc), var(--acc-dark));
  position: relative; overflow: hidden;
}
.paper.tpl-modern .band::after { content: ""; position: absolute; right: -80px; top: -120px; width: 320px; height: 320px; border-radius: 50%; background: rgba(255,255,255,.08); }
.paper.tpl-modern .band::before { content: ""; position: absolute; right: 90px; bottom: -150px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255,255,255,.06); }
.paper.tpl-modern .logo, .paper.tpl-modern .logo-ph { background: rgba(255,255,255,.95); color: var(--acc); }
.paper.tpl-modern .co-line { color: rgba(255,255,255,.9); }

/* ---- Mẫu CỔ ĐIỂN ---- */
.paper.tpl-classic { padding-top: 30px; }
.paper.tpl-classic .hdr { padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.paper.tpl-classic .co-name { color: var(--acc); text-transform: uppercase; }
.paper.tpl-classic .co-line { color: var(--ink-2); }
.paper.tpl-classic .doc-title { color: var(--ink); }
.paper.tpl-classic .party { background: transparent; border: 1px solid var(--ink-3); border-radius: 4px; }
.paper.tpl-classic .party h5 { color: var(--ink); }
.paper.tpl-classic .items th { background: #f1f5f9; color: var(--ink); border: 1px solid #94a3b8; border-radius: 0 !important; }
.paper.tpl-classic .items td { border: 1px solid #cbd5e1; }
.paper.tpl-classic .items tbody tr:nth-child(even) td { background: transparent; }
.paper.tpl-classic .sum .grand { background: transparent; color: var(--ink); border: 2px solid var(--ink); border-radius: 4px; }
.paper.tpl-classic .sum .grand span { color: var(--ink); }
.paper.tpl-classic .perk { border-radius: 4px; }

/* ---- Mẫu TỐI GIẢN ---- */
.paper.tpl-minimal { padding-top: 40px; }
.paper.tpl-minimal .hdr { justify-content: space-between; }
.paper.tpl-minimal .co-line { color: var(--ink-2); }
.paper.tpl-minimal .title-blk { text-align: left; }
.paper.tpl-minimal .doc-meta { justify-content: flex-start; }
.paper.tpl-minimal .doc-title { font-size: 32px; letter-spacing: -.5px; text-transform: none; color: var(--ink); }
.paper.tpl-minimal .party { background: transparent; padding: 0; }
.paper.tpl-minimal .party h5 { color: var(--ink-3); }
.paper.tpl-minimal .items th { background: transparent; color: var(--ink-3); border-bottom: 2px solid var(--ink); border-radius: 0 !important; }
.paper.tpl-minimal .items tbody tr:nth-child(even) td { background: transparent; }
.paper.tpl-minimal .sum .grand { background: transparent; color: var(--ink); border-top: 2px solid var(--ink); border-radius: 0; padding: 12px 0 0; }
.paper.tpl-minimal .sum .grand span { color: var(--ink); }
.paper.tpl-minimal .perk { background: transparent; border: 1px solid var(--rule); color: var(--ink-2); }

/* ---- In ấn ---- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .paper { width: 210mm; min-height: 297mm; box-shadow: none; margin: 0 auto; }
  #print-root .paper.a5 { width: 148mm; min-height: 210mm; }
}
