.wysiwyg-scroll {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 16px 0 32px;
}

.wysiwyg-container {
  width: 100%;
  max-width: 210mm;
}

.invoice-doc--wysiwyg {
  position: relative;
}

.invoice-doc--wysiwyg .inv-page {
  min-height: 277mm;
}

.wysiwyg-workspace {
  position: relative;
}

.editor-side-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: 260px;
  background: var(--bg-panel, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 8px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  padding: 12px;
}

.editor-side-panel.is-collapsed .side-panel-body {
  display: none;
}

.side-panel-tabs {
  display: flex;
  width: 100%;
  margin-bottom: 12px;
  gap: 6px;
}

.side-panel-tabs .view-tab-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
}

.side-panel-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
}

.side-field select,
.side-field input[type="color"] {
  width: 100%;
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  background: var(--bg-elevated, #fff);
  color: var(--text, #111);
}

.side-field input[type="color"] {
  height: 32px;
  padding: 2px;
  cursor: pointer;
}

.side-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #111);
  user-select: none;
}

.side-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.side-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: #d1d5db;
  border-radius: 10px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.side-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.side-toggle input:checked + .side-toggle-track {
  background: var(--accent, #3b82f6);
}

.side-toggle input:checked + .side-toggle-track::after {
  transform: translateX(16px);
}

.side-toggle-label {
  flex: 1;
}

.wysiwyg-logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wysiwyg-logo-preview {
  width: 48px;
  height: 36px;
  border: 1px dashed #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 9px;
  color: #999;
}

.wysiwyg-logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.inv-ed-label {
  outline: none;
  cursor: text;
  border-radius: 2px;
  padding: 0 2px;
  margin: -1px -2px;
}

.inv-ed-label:hover {
  background: rgba(37, 99, 235, 0.08);
}

.inv-ed-label:focus {
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.inv-ed-label:empty:not([data-label-cleared])::before {
  content: attr(data-placeholder);
  color: #bbb;
}

.inv-bill-to h2,
.inv-add-block h3 {
  min-height: 1.2em;
}

.inv-ed-label[data-label-cleared]:empty {
  display: inline-block;
  min-height: 1em;
}

.wysiwyg-input,
.wysiwyg-textarea {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 2px;
  resize: vertical;
  box-sizing: border-box;
}

.wysiwyg-input:hover,
.wysiwyg-textarea:hover {
  background: rgba(37, 99, 235, 0.05);
}

.wysiwyg-input:focus,
.wysiwyg-textarea:focus {
  outline: none;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.wysiwyg-textarea {
  min-height: 4.5em;
  line-height: 1.5;
}

.wysiwyg-party {
  min-height: 6em;
  font-size: 10pt;
  color: #444;
  line-height: 1.5;
  width: 100%;
  border: none;
  background: transparent;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 2px;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.wysiwyg-party:hover {
  background: rgba(37, 99, 235, 0.05);
}

.wysiwyg-party:focus {
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.wysiwyg-party:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
  font-weight: 400;
}

.wysiwyg-party strong {
  font-weight: 700;
}

.invoice-doc--wysiwyg.invoice-doc--no-tax .col-tax {
  display: none;
}

.invoice-doc--wysiwyg.invoice-doc--no-discount .col-disc {
  display: none;
}

.inv-vis-toggle {
  appearance: none;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: #666;
  line-height: 0;
  flex-shrink: 0;
  margin-top: 2px;
}

.inv-vis-toggle:hover {
  color: #333;
  border-color: #bbb;
  background: #f8f9fb;
}

.inv-vis-toggle[aria-pressed="true"] .inv-vis-icon--off {
  display: none;
}

.inv-vis-toggle[aria-pressed="false"] .inv-vis-icon--on {
  display: none;
}

.inv-header-balance.is-invoice-hidden {
  visibility: hidden;
  pointer-events: none;
}

.invoice-doc--wysiwyg .inv-header-balance-wrap .inv-vis-toggle {
  visibility: visible;
  pointer-events: auto;
}

.invoice-doc--wysiwyg .inv-title.inv-ed-label {
  display: block;
  text-align: right;
}

.invoice-doc--wysiwyg .inv-meta th {
  padding-right: 8px;
}

.invoice-doc--wysiwyg .inv-meta td {
  min-width: 100px;
}

.invoice-doc--wysiwyg .inv-meta tr {
  min-height: 1.6em;
}

.invoice-doc--wysiwyg .inv-meta .wysiwyg-input {
  text-align: right;
  font-weight: 600;
  min-height: 1.5em;
}

.invoice-doc--wysiwyg .inv-items .wysiwyg-input {
  font-size: 10pt;
  padding: 6px 4px;
  text-align: left;
}

.invoice-doc--wysiwyg .inv-items .col-qty .wysiwyg-input,
.invoice-doc--wysiwyg .inv-items .col-price .wysiwyg-input,
.invoice-doc--wysiwyg .inv-items .col-tax .wysiwyg-input,
.invoice-doc--wysiwyg .inv-items .col-disc .wysiwyg-input {
  text-align: right;
}

.invoice-doc--wysiwyg .inv-items th .inv-ed-label {
  font-size: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.invoice-doc--wysiwyg .inv-bill-to h2 .inv-ed-label {
  font-size: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.wysiwyg-row-actions {
  white-space: nowrap;
  width: 72px;
}

.wysiwyg-row-actions .btn-icon {
  min-width: 22px;
  padding: 0 4px;
  font-size: 11px;
  border-color: #ddd;
  background: #fff;
  color: #666;
}

.wysiwyg-add-item {
  margin-top: 10px;
  text-align: center;
}

.wysiwyg-add-item .btn {
  font-size: 10pt;
  border-color: var(--inv-accent, #2563eb);
  color: var(--inv-accent, #2563eb);
  background: #fff;
}

.invoice-doc--wysiwyg .inv-summary .wysiwyg-input--amount {
  width: 72px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.invoice-doc--wysiwyg .inv-add-block .wysiwyg-textarea {
  font-size: 9.5pt;
  color: #444;
  min-height: 3em;
}

.invoice-doc--wysiwyg .inv-add-block h3 {
  margin-bottom: 6px;
}

.invoice-doc--wysiwyg .inv-footer .wysiwyg-input {
  text-align: center;
  font-size: 9pt;
  color: #888;
}

.invoice-doc--wysiwyg .inv-logo {
  cursor: pointer;
}

.invoice-doc--wysiwyg .inv-logo-slot {
  min-height: 56px;
  margin-bottom: 12px;
}

.invoice-doc--wysiwyg .inv-logo-slot.is-empty {
  border: 1px dashed #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9pt;
  color: #aaa;
  cursor: pointer;
  max-width: 180px;
  padding: 8px;
}

.invoice-doc--wysiwyg .line-total-display {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.invoice-doc--wysiwyg .inv-sum-row .sum-value {
  font-variant-numeric: tabular-nums;
}

.invoice-doc--wysiwyg .inv-sum-row {
  min-height: 1.6em;
}

.invoice-doc--wysiwyg .wysiwyg-discount-type {
  width: 52px;
  font-size: 9pt;
  padding: 2px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
}

@media (max-width: 640px) {
  .editor-side-panel {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
    max-width: 260px;
  }
}
