.business-bill-open {
  overflow: hidden;
}

.business-bill-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  padding: 18px;
  overflow: auto;
  background: rgba(9, 18, 32, 0.82);
}

.business-bill-modal.hidden {
  display: none;
}

.business-bill-dialog {
  width: min(1500px, 100%);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #eef2f6;
}

.business-bill-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  color: #fff;
  background: #10253e;
}

.business-bill-dialog > header p,
.business-bill-dialog > header h2 {
  margin: 0;
}

.business-bill-dialog > header p {
  color: #79d7dd;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.business-bill-dialog > header button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  color: #10253e;
  background: #fff;
  font-size: 1.5rem;
}

.business-bill-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(650px, 1.22fr);
  gap: 18px;
  padding: 18px;
}

.business-bill-editor,
.business-bill-preview {
  min-width: 0;
}

.business-bill-editor {
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.business-bill-form {
  display: grid;
  gap: 12px;
}

.business-bill-form section {
  padding: 15px;
  border: 1px solid #d6dee7;
  border-radius: 12px;
  background: #fff;
}

.business-bill-form h3 {
  margin: 0 0 12px;
  color: #10253e;
  font-size: 0.9rem;
}

.business-bill-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.business-bill-fields label {
  display: grid;
  gap: 5px;
  color: #536271;
  font-size: 0.72rem;
  font-weight: 750;
}

.business-bill-fields input,
.business-bill-fields select,
.business-bill-fields textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  color: #13263a;
  background: #fff;
  font: inherit;
}

.bill-field-wide {
  grid-column: 1 / -1;
}

.business-bill-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 24px rgba(16, 37, 62, 0.08);
}

.business-bill-preview {
  overflow: auto;
}

.business-bill-sheet {
  width: 210mm;
  min-height: 297mm;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 7mm;
  color: #111;
  background: #fff;
  box-shadow: 0 10px 32px rgba(14, 30, 46, 0.17);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8px;
  line-height: 1.25;
}

.bill-company-header {
  display: grid;
  grid-template-columns: 25mm 1fr;
  align-items: center;
  min-height: 25mm;
  border: 1px solid #111;
  text-align: center;
}

.bill-company-mark {
  display: grid;
  place-items: center;
  height: 100%;
  color: #087b83;
  font-size: 22px;
  font-weight: 900;
}

.bill-company-header > div:last-child {
  padding: 3mm;
}

.bill-company-header h1 {
  margin: 0 0 1mm;
  font-size: 14px;
}

.bill-company-header p {
  margin: 0.7mm 0;
}

.bill-title {
  margin: 0;
  padding: 1.2mm;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  border-left: 1px solid #111;
  font-size: 9px;
  text-align: center;
}

.bill-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bill-grid th,
.bill-grid td {
  padding: 1.4mm;
  border: 1px solid #111;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.bill-grid th {
  background: #f2f2f2;
  font-weight: 700;
}

.bill-meta th,
.bill-meta td {
  width: 12.5%;
}

.bill-copy-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-right: 1px solid #111;
  border-left: 1px solid #111;
}

.bill-copy-row strong {
  padding: 1.2mm;
  border-right: 1px solid #111;
  text-align: center;
}

.bill-copy-row strong:last-child {
  border-right: 0;
}

.bill-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #111;
  border-right: 1px solid #111;
  border-left: 1px solid #111;
}

.bill-two-column > div {
  min-height: 25mm;
  padding: 2mm;
  border-right: 1px solid #111;
}

.bill-two-column > div:last-child {
  border-right: 0;
}

.bill-two-column h3,
.bill-two-column p {
  margin: 0 0 1mm;
}

.bill-two-column h3 {
  font-size: 8px;
}

.bill-invoice tbody td {
  height: 47mm;
}

.bill-invoice th:nth-child(1) { width: 15%; }
.bill-invoice th:nth-child(2) { width: 12%; }
.bill-invoice th:nth-child(3) { width: 14%; }
.bill-invoice th:nth-child(4) { width: 10%; }
.bill-invoice th:nth-child(5) { width: 34%; }
.bill-invoice th:nth-child(6) { width: 15%; }

.bill-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 28mm;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  border-left: 1px solid #111;
}

.bill-signatures > div {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2mm;
  border-right: 1px solid #111;
}

.bill-signatures > div:last-child {
  border-right: 0;
}

.bill-signatures p {
  margin: 0;
}

.bill-signatures span {
  color: #555;
  text-align: center;
}

.business-bill-sheet footer {
  padding: 1.5mm;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  border-left: 1px solid #111;
}

@media (max-width: 1000px) {
  .business-bill-modal {
    padding: 0;
  }

  .business-bill-dialog {
    min-height: 100vh;
    border-radius: 0;
  }

  .business-bill-workspace {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .business-bill-editor {
    max-height: none;
  }

  .business-bill-preview {
    padding-bottom: 20px;
  }

  .business-bill-sheet {
    width: 210mm;
    transform-origin: top left;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body.business-bill-open * {
    visibility: hidden !important;
  }

  body.business-bill-open .business-bill-sheet,
  body.business-bill-open .business-bill-sheet * {
    visibility: visible !important;
  }

  body.business-bill-open .business-bill-modal {
    position: static;
    display: block !important;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  body.business-bill-open .business-bill-dialog,
  body.business-bill-open .business-bill-workspace,
  body.business-bill-open .business-bill-preview {
    display: block;
    width: auto;
    min-height: 0;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  body.business-bill-open .business-bill-dialog > header,
  body.business-bill-open .business-bill-editor {
    display: none !important;
  }

  body.business-bill-open .business-bill-sheet {
    position: absolute;
    inset: 0;
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
