body {
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: #eef2f7;
  margin: 0;
  padding: 0;
}

h1 {
  text-align: center;
  font-size: 2.3em;
  font-weight: 700;
  color: #284c6e;
  letter-spacing: 1px;
  margin-top: 30px;
  margin-bottom: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

#controls {
  background: #f7faff;
  border-radius: 22px;
  box-shadow: 0 4px 24px #bcc7d9b0, 0 1.5px 8px #ffffff60 inset;
  margin: 0 auto;
  margin-top: 24px;
  width: 97%;
  max-width: 1100px;
  padding: 28px 22px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#headerControls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 1.09em;
  font-weight: 500;
  color: #2d445d;
}

#headerControls label {
  font-weight: 600;
  color: #234;
  font-size: 1.07em;
  margin-right: 0;
  flex: 1 1 230px;
}

#headerControls input {
  font-size: 1em;
  padding: 6px 12px;
  border-radius: 5px;
  border: 1px solid #ccd5e1;
  margin-left: 5px;
  min-width: 95px;
  width: auto;
  max-width: 170px;
  background: #f9fafe;
}

#rawInput {
  width: 100%;
  min-height: 80px;
  font-size: 1.12em;
  border-radius: 9px;
  border: 1.5px solid #e0e6ed;
  padding: 10px 12px;
  margin-bottom: 5px;
  resize: vertical;
  background: #f5f8fc;
  box-shadow: 0 1.5px 6px #dde7f780 inset;
  color: #223;
}

#buttonRow {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-start;
  margin-bottom: 0;
}

#buttonRow button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 23px;
  border-radius: 11px;
  font-size: 1.17em;
  border: none;
  background: #f6f9fd;
  box-shadow: 0 4px 20px #bcc7d980, 0 1px 8px #fff9 inset;
  color: #294e77;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: 
    background 0.17s, 
    color 0.15s, 
    box-shadow 0.18s;
}

#buttonRow button:hover,
#buttonRow button:focus {
  background: #e8f3fe;
  color: #2565b8;
  box-shadow: 0 4px 32px #b3cffe, 0 2.5px 12px #e6f1ff inset;
}

#outputArea {
  margin: 32px auto 40px auto;
  width: 97%;
  max-width: 1100px;
  min-height: 120px;
}

/* === PAGE & BOX FOR PDF/PRINT === */
#outputArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.page {
  display: flex;
  flex-wrap: wrap;
  width: 7.15in;
  height: 10.8in;
  margin: 0.25in auto 0.25in auto;
  box-sizing: border-box;
  align-items: center;         /* vertical center */
  justify-content: center;     /* horizontal center */
  gap: 0.3in 0.4in;
  background: #fff !important;
  padding: 0;
}



.box {
  position: relative;
  width: 3.35in;
  height: 2.3in;
  margin: 0 0 0.12in 0;
  border-radius: 0.25in;
  border: 1.2px solid #e2e8f0;
  background: #fbfcfe;
  box-shadow: 0 2.5px 15px #e5ebf3;
  padding: 0.09in 0.13in;
  box-sizing: border-box;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
  break-inside: avoid;
  page-break-inside: avoid;
}

.box .header,
.box .content {
  color: #223 !important;
  background: none !important;
}

.box .header {
  font-weight: bold;
  text-align: center;
  font-size: 14px;
  margin-bottom: 20px;
  color: #234e87 !important;
  letter-spacing: 0.01em;
  background: none;
  border: none;
  box-shadow: none;
}
.box .content {
  white-space: pre-line;
  line-height: 1.3;
  flex-grow: 1;
  font-size: 12px;
}

.company-logo-invoice {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 70px;
  height: 45px;
  max-height: 50px;
  opacity: 0.89;
  object-fit: contain;
  z-index: 2;
  pointer-events: none;
}

/* Responsive */
@media (max-width: 800px) {
  #controls,
  #outputArea,
  .page {
    width: 99vw !important;
    min-width: 0 !important;
    padding: 7px !important;
  }
  .box {
    width: 98vw !important;
    min-width: 0 !important;
    margin-left: 0 !important;
  }
}

/* PRINT/PDF OVERRIDES: Perfect 8-per-page, no splits */
@media print {
  h1, #controls, #buttonRow {
    display: none !important;
  }
  body {
    background: #fff !important;
  }
  .page {
    width: 7.27in !important;
    height: 10.5in !important;
    display: flex !important;
    flex-wrap: wrap !important;
    box-sizing: border-box !important;
    padding: 0.25in 0 0.25in 0 !important;
    margin: 0 auto !important;
    gap: 0.3in 0.4in !important;
    page-break-after: always !important;
    align-items: center !important;
    background: #fff !important;
  }
  .box {
    width: 3.35in !important;
    height: 2.3in !important;
    border: 1px solid #000 !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 0.08in 0.1in !important;
    margin: 0 0 0.12in 0 !important;
    border-radius: 0.25in !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    overflow: hidden !important;
  }
}

