.invoice-paper {
  --invoice-blue: #1f4e79;
  box-sizing: border-box;
  max-width: 900px;
  min-height: 1120px;
  margin: 0 auto 24px;
  padding: 46px 52px;
  color: #101828;
  background: #fff;
  border: 1px solid #d7dce3;
  border-left: 6px solid #173a5e;
  box-shadow: 0 14px 38px rgb(15 23 42 / 10%);
  font-size: 13px;
}

.invoice-blue,
.invoice-title,
.payment-title {
  color: var(--invoice-blue);
}

.invoice-brand-row {
  display: flex;
  min-height: 90px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.invoice-brand-row > img:first-child {
  width: 235px;
  max-height: 90px;
  object-fit: contain;
  object-position: left top;
}

.seller-block {
  width: 245px;
  line-height: 1.5;
  text-align: left;
}

.seller-block strong {
  display: block;
  margin-bottom: 4px;
  color: #173a5e;
  text-transform: uppercase;
}

.invoice-editor-qr {
  display: flex;
  width: 92px;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #64748b;
  font-size: 7px;
  font-weight: 700;
  text-align: center;
}

.invoice-editor-qr img {
  width: 76px;
  height: 76px;
}

.invoice-title {
  margin: 10px 0 22px;
  font-size: 31px;
  letter-spacing: .03em;
  text-align: left;
}

.invoice-parties {
  display: grid;
  min-height: 145px;
  grid-template-columns: minmax(0, 1fr) 315px;
  gap: 42px;
}

.invoice-parties > section {
  padding: 17px 19px;
  background: #f4f8fb;
  border: 1px solid #d8e2eb;
  border-radius: 8px;
}

.invoice-parties > section:first-child {
  border-left: 5px solid #2ba9c9;
}

.invoice-parties > .invoice-meta {
  background: #fff;
}

.invoice-parties h3 {
  margin: 5px 0;
  color: #101828;
  font-size: 15px;
}

.invoice-meta label {
  display: grid;
  min-height: 31px;
  align-items: center;
  grid-template-columns: 105px 1fr;
  gap: 8px;
  font-weight: 700;
}

.invoice-meta input,
.invoice-control-row input,
.invoice-control-row select,
.inline-currency,
.inline-rate {
  min-width: 0;
  padding: 4px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #f8fafc;
  font: inherit;
}

.invoice-meta input[name="currency"] {
  width: 75px;
  text-transform: uppercase;
}

.conversion-pair {
  color: var(--invoice-blue);
  font-weight: 700;
}

.invoice-lines {
  margin-top: 12px;
  overflow-x: auto;
  border-bottom: 1px solid #344054;
}

.invoice-line-row {
  display: grid;
  min-width: 850px;
  grid-template-columns: 58px minmax(250px, 1fr) 90px 125px 105px 78px;
}

.invoice-line-row > * {
  box-sizing: border-box;
  min-width: 0;
  padding: 8px 7px;
  border-top: 1px solid #344054;
  border-left: 1px solid #344054;
}

.invoice-line-row > :last-child {
  border-right: 1px solid #344054;
}

.invoice-line-head > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  color: #fff;
  background: #173a5e;
  border-color: #fff;
  font-weight: 700;
}

.invoice-line-row > input,
.invoice-line-row > div > input,
.invoice-line-row > div > textarea {
  width: 100%;
  border-radius: 0;
  background: transparent;
}

.invoice-line-row > div > textarea {
  min-height: 54px;
  line-height: 1.35;
  resize: vertical;
}

.invoice-line-row output,
.invoice-line-row > input[type="number"] {
  text-align: right;
}

.line-number {
  text-align: center;
}

.line-order,
.line-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.line-drag-handle,
.clone-line,
.remove-line {
  width: 30px;
  height: 32px;
  padding: 0;
  border-radius: 5px;
}

.line-drag-handle {
  flex: 0 0 24px;
  width: 24px;
  color: #64748b;
  background: transparent;
  cursor: grab;
  font-size: 15px;
  letter-spacing: -3px;
}

.line-drag-handle:active {
  cursor: grabbing;
}

.line-drag-handle:hover,
.line-drag-handle:focus-visible {
  color: #173a5e;
  background: #e8f1f8;
}

.line-row.is-dragging {
  opacity: .48;
}

.line-row.drop-target > * {
  border-top-color: #22a9c9;
  box-shadow: inset 0 2px #22a9c9;
}

.line-options {
  display: flex;
  margin-top: 7px;
  gap: 5px;
  color: #667085;
  font-size: 10px;
}

.line-options select,
.line-options input {
  min-width: 0;
  padding: 3px;
  font-size: 10px;
}

.line-options > input {
  width: 70px !important;
}

.line-options label {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.line-options label input {
  width: 52px !important;
}

.remove-line {
  color: #9b1c1c;
  background: #fff;
  font-size: 18px;
}

.clone-line {
  color: #175cd3;
  background: #eef5ff;
  font-size: 17px;
}

.clone-line:hover {
  background: #dbeafe;
}

.remove-line:hover {
  background: #fef2f2;
}

.add-invoice-line {
  margin: 9px 0 14px;
  padding: 6px 11px;
  color: var(--invoice-blue);
  background: #eef5fb;
  border: 1px solid #b8cee2;
}

.invoice-totals {
  width: 50%;
  margin-left: auto;
  border-top: 1px solid #344054;
}

.invoice-totals > label {
  display: grid;
  min-height: 35px;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 130px;
  border-right: 1px solid #344054;
  border-bottom: 1px solid #344054;
  border-left: 1px solid #344054;
}

.invoice-totals > label > span,
.invoice-totals > label > output,
.invoice-totals > label > input {
  box-sizing: border-box;
  height: 100%;
  padding: 8px;
}

.invoice-totals > label > span {
  text-align: right;
  border-right: 1px solid #344054;
}

.invoice-totals output,
.invoice-totals > label > input {
  text-align: right;
}

.invoice-totals > label:has(> output[data-preview="total"]),
.invoice-totals > label[data-rounded-converted-row]:not(.hidden) {
  font-weight: 700;
  color: #fff;
  background: #173a5e;
}

.conversion-round-control {
  padding: 8px 10px;
  border-right: 1px solid #344054;
  border-bottom: 1px solid #344054;
  border-left: 1px solid #344054;
  background: #f3f8fc;
}

.conversion-round-control .check {
  display: flex;
  min-height: auto;
  align-items: center;
  grid-template-columns: none;
  gap: 7px;
  border: 0;
  color: #344054;
  font-size: 11px;
}

.conversion-round-control .check input {
  width: auto;
  margin: 0;
}

.conversion-round-control .check span {
  padding: 0;
  text-align: left;
  border: 0;
}

.inline-rate {
  width: 52px;
  text-align: right;
}

.inline-currency {
  width: 48px;
  text-transform: uppercase;
}

.invoice-words {
  margin-top: 27px;
  line-height: 1.75;
}

.payment-title {
  margin: 18px 0 6px;
  text-align: center;
}

.payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.payment-grid section {
  min-height: 135px;
  padding: 8px 10px;
  border: 1px solid #d8e2eb;
  border-radius: 8px;
  line-height: 1.45;
}

.payment-grid section + section {
  margin-left: 8px;
}

.payment-grid strong {
  display: block;
  margin: -8px -10px 8px;
  padding: 8px 10px;
  color: #173a5e;
  background: #e8f7fb;
  border-radius: 8px 8px 0 0;
}

.editor-notes {
  display: block;
  margin-top: 24px;
  padding-top: 15px;
  border-top: 1px dashed #b8c2cf;
  color: #667085;
}

.editor-notes textarea {
  width: 100%;
  margin-top: 6px;
}

.editor-actions {
  justify-content: center;
  margin-bottom: 30px;
}

.preview-error {
  min-height: 20px;
  margin-top: 8px;
  color: #b42318;
  text-align: right;
}

.hidden {
  display: none !important;
}

@media (max-width: 800px) {
  .invoice-paper {
    min-height: auto;
    padding: 28px 22px;
  }

  .invoice-parties {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .invoice-totals {
    width: 100%;
  }
}

@media print {
  .topbar,
  .editor-heading,
  .editor-actions,
  .add-invoice-line,
  .line-drag-handle,
  .clone-line,
  .remove-line,
  .editor-notes,
  .preview-error {
    display: none !important;
  }

  .invoice-paper {
    border: 0;
    box-shadow: none;
  }
}
