/* =========================================================
   CUSTOMER BILL — RAJMUDRA A4 DESIGN MATCHED WITH SELL BILL
   A4 only. No thermal bill UI.
========================================================= */

* { box-sizing: border-box; }

:root {
  --rm-black: #17120d;
  --rm-brown: #4a3424;
  --rm-gold: #b89146;
  --rm-gold-soft: #f4e2bd;
  --rm-cream: #fffaf1;
  --rm-paper: #fffdf8;
  --rm-border: #dccaa5;
  --rm-muted: #6d655b;
  --rm-faint: #948b7f;
}

body {
  background: #f3eee5 !important;
  color: var(--rm-black);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.rmbill-page {
  min-height: 100vh;
  padding: 26px 16px 36px;
  color: var(--rm-black);
  font-family: Arial, Helvetica, sans-serif;
}

.rmbill-page.a4-print {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.invoice-sheet {
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23,18,13,0.16);
}

.invoice-a4-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 10mm;
  border: 1px solid var(--rm-border);
  position: relative;
  overflow: hidden;
}

.invoice-a4-sheet::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  background: linear-gradient(90deg, var(--rm-black), var(--rm-gold), var(--rm-black));
}

/* Toolbar */
.print-actions {
  width: 210mm;
  max-width: calc(100vw - 28px);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.print-actions a,
.print-actions button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  border: 0;
  padding: 0 16px;
  background: var(--rm-black);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(23,18,13,0.16);
}

.print-actions a:hover,
.print-actions button:hover {
  transform: translateY(-1px);
}

.rmbill-toolbar-title {
  margin-right: auto;
  display: grid;
  gap: 2px;
}

.rmbill-toolbar-title span {
  color: var(--rm-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.rmbill-toolbar-title strong {
  color: var(--rm-black);
  font-size: 14px;
}

/* Empty state */
.rmbill-empty {
  width: min(620px, calc(100vw - 30px));
  margin: 60px auto;
  background: #fffdf8;
  border: 1px solid var(--rm-border);
  border-radius: 18px;
  padding: 34px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(23,18,13,0.12);
}

.rmbill-empty h1 {
  font-family: Georgia, serif;
  font-size: 36px;
  margin: 0 0 8px;
}

.rmbill-empty p {
  color: var(--rm-muted);
  font-weight: 800;
}

.rmbill-empty a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  padding: 0 16px;
  background: var(--rm-black);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  text-decoration: none;
}

/* Header */
.a4-header {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  align-items: stretch;
  padding: 10px 12px;
  border: 1px solid var(--rm-border);
  border-radius: 8px;
  background:
    radial-gradient(circle at top right, rgba(184,145,70,0.20), transparent 34%),
    linear-gradient(135deg, #fffdf8 0%, #fbf1df 100%);
}

.a4-brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.a4-logo,
.a4-logo-fallback {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border-radius: 8px;
  border: 1px solid rgba(184,145,70,0.35);
  background: #fff;
  object-fit: contain;
  padding: 5px;
}

.a4-logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rm-black);
  color: var(--rm-gold-soft);
  font-size: 30px;
  font-weight: 900;
}

.a4-brand-block h1 {
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.08;
  letter-spacing: 0.035em;
  color: var(--rm-black);
  text-transform: uppercase;
}

.a4-brand-block p {
  margin: 0 0 6px;
  color: var(--rm-brown);
  font-size: 11px;
  font-weight: 700;
}

.a4-brand-block span {
  display: block;
  margin: 2px 0;
  color: var(--rm-muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.a4-qr-card {
  width: 92px;
  min-height: 92px;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border-radius: 8px;
  border: 1px solid rgba(184,145,70,0.35);
  background: #fff;
}

.a4-qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Meta */
.a4-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.a4-meta-grid > div,
.a4-payment-card,
.a4-total-card,
.a4-terms-signature,
.a4-footer {
  border: 1px solid var(--rm-border);
  background: var(--rm-paper);
  border-radius: 8px;
}

.a4-meta-grid > div {
  padding: 12px;
  min-height: 112px;
}

.a4-meta-grid span,
.a4-payment-card h3,
.a4-terms-signature h3 {
  display: block;
  margin: 0 0 8px;
  color: var(--rm-gold);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.a4-meta-grid strong {
  display: block;
  margin-bottom: 5px;
  color: var(--rm-black);
  font-size: 14px;
}

.a4-meta-grid p {
  margin: 4px 0;
  color: var(--rm-muted);
  font-size: 11.5px;
  line-height: 1.45;
}

/* Items */
.a4-items-section {
  margin-top: 8px;
}

.a4-items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid var(--rm-border);
  border-radius: 8px;
}

.a4-items-table th {
  background: var(--rm-black);
  color: #fff;
  padding: 7px 3px;
  font-size: 8.2px;
  line-height: 1.1;
  font-weight: 900;
  text-align: left;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.a4-items-table td {
  padding: 7px 3px;
  border-bottom: 1px solid #eadfc7;
  background: #fff;
  color: var(--rm-black);
  font-size: 8.2px;
  line-height: 1.15;
  vertical-align: middle;
  word-break: normal;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.a4-items-table tbody tr:nth-child(even) td { background: #fffaf2; }
.a4-items-table tbody tr:last-child td { border-bottom: 0; }
.a4-items-table td strong { display: block; }

.a4-lot-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.a4-lot-image,
.a4-lot-image-fallback {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  border: 1px solid var(--rm-border);
  background: #fffaf2;
  object-fit: cover;
}

.a4-lot-image-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rm-faint);
  font-size: 7px;
  font-weight: 900;
  text-transform: uppercase;
}

.a4-lot-cell strong {
  margin: 0 !important;
  line-height: 1.2;
  font-size: 8.2px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.a4-center-cell { text-align: center !important; }
.a4-money-cell { text-align: right !important; }
.a4-nowrap { white-space: nowrap !important; }

.a4-money-cell,
.a4-money-cell strong {
  font-size: 7.6px;
  line-height: 1.12;
  letter-spacing: -0.075em;
  white-space: nowrap;
}

.a4-items-table th:nth-child(1), .a4-items-table td:nth-child(1) { width: 20px; text-align: center; }
.a4-items-table th:nth-child(2), .a4-items-table td:nth-child(2) { width: 105px; }
.a4-items-table th:nth-child(3), .a4-items-table td:nth-child(3) { width: 38px; }
.a4-items-table th:nth-child(4), .a4-items-table td:nth-child(4) { width: 36px; }
.a4-items-table th:nth-child(5), .a4-items-table td:nth-child(5) { width: 28px; text-align: center; }
.a4-items-table th:nth-child(6), .a4-items-table td:nth-child(6) { width: 49px; text-align: right; }
.a4-items-table th:nth-child(7), .a4-items-table td:nth-child(7) { width: 53px; text-align: right; }
.a4-items-table th:nth-child(8), .a4-items-table td:nth-child(8) { width: 76px; text-align: right; }
.a4-items-table th:nth-child(9), .a4-items-table td:nth-child(9) { width: 77px; text-align: right; }
.a4-items-table th:nth-child(10), .a4-items-table td:nth-child(10) { width: 67px; text-align: right; }
.a4-items-table th:nth-child(11), .a4-items-table td:nth-child(11) { width: 85px; text-align: right; }

/* Bottom */
.a4-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 285px;
  gap: 10px;
  margin-top: 14px;
  align-items: start;
}

.a4-payment-card,
.a4-total-card {
  padding: 12px;
}

.a4-payment-card p {
  margin: 5px 0;
  color: var(--rm-black);
  font-size: 11.5px;
  line-height: 1.45;
}

.a4-payment-card small {
  color: var(--rm-muted);
}

.a4-amount-words {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px dashed var(--rm-border);
}

.a4-amount-words span {
  display: block;
  margin-bottom: 5px;
  color: var(--rm-faint);
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.a4-amount-words strong {
  display: block;
  font-size: 11px;
  line-height: 1.45;
}

.a4-total-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #eadfc7;
  font-size: 11.5px;
}

.a4-total-card div:last-child {
  border-bottom: 0;
}

.a4-total-card span {
  color: var(--rm-muted);
}

.a4-total-card strong {
  text-align: right;
}

.a4-total-card .a4-grand {
  margin: 8px -6px;
  padding: 12px 8px;
  border: 0;
  border-radius: 8px;
  background: var(--rm-black);
  color: #fff;
}

.a4-total-card .a4-grand span,
.a4-total-card .a4-grand strong {
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.a4-terms-signature {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
}

.a4-terms-signature p {
  margin: 0;
  color: var(--rm-muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.a4-signature {
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  text-align: center;
  border-left: 1px dashed var(--rm-border);
  padding-left: 14px;
}

.a4-signature span {
  color: var(--rm-muted);
  font-size: 11.5px;
  margin-bottom: 26px;
}

.a4-signature strong {
  color: var(--rm-black);
  font-size: 11.5px;
  border-top: 1px solid var(--rm-black);
  padding-top: 6px;
  width: 100%;
}

.a4-footer {
  margin-top: 12px;
  padding: 10px 14px;
  text-align: center;
}

.a4-footer p {
  margin: 0;
  color: var(--rm-brown);
  font-size: 12px;
  font-weight: 700;
}

/* Toast */
.rmbill-toast {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 999999;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--rm-black);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 18px 44px rgba(23,18,13,0.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.rmbill-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive preview */
@media (max-width: 900px) {
  .rmbill-page.a4-print {
    align-items: flex-start;
    overflow-x: auto;
  }

  .invoice-a4-sheet,
  .print-actions {
    width: 210mm;
    max-width: none;
  }
}

/* Print/PDF */
@media print {
  body {
    background: #fff !important;
    width: 210mm;
  }

  .no-print,
  .print-actions,
  .rmbill-toast,
  .site-header,
  .main-header,
  .navbar,
  .site-footer,
  .footer {
    display: none !important;
  }

  .rmbill-page {
    padding: 0 !important;
    min-height: auto !important;
  }

  .invoice-sheet {
    margin: 0 !important;
    box-shadow: none !important;
  }

  .invoice-a4-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 9mm !important;
    border: 0 !important;
  }

  .a4-items-table th {
    font-size: 8px !important;
    padding: 6px 3px !important;
  }

  .a4-items-table td {
    font-size: 8px !important;
    padding: 6px 3px !important;
  }

  @page {
    size: A4;
    margin: 0;
  }
}
