/* Editor chrome only. The print window still loads the original invoice stylesheet. */
.invoice-editor-page .main { min-width: 0; min-height: 0; }
.invoice-editor-page .topbar { flex-shrink: 0; min-height: 64px; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
.invoice-editor-page .topbar-title { align-items: center; }
.invoice-editor-page .content-area { min-height: 0; min-width: 0; }
.invoice-editor-page .invoice-layout { min-height: 0; grid-template-columns: minmax(340px,400px) minmax(0,1fr); }
.invoice-editor-page .invoice-form-panel { min-width: 0; min-height: 0; }
.invoice-editor-page .form-section { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.invoice-editor-page .form-group,.invoice-editor-page input,.invoice-editor-page select { min-width: 0; }
.invoice-editor-page .form-section-title { letter-spacing: 0; }
.invoice-editor-page .item-row { grid-template-columns: minmax(0,1fr) minmax(95px,120px) 32px; }
.invoice-editor-page .prev-pay-row { grid-template-columns: minmax(125px,140px) minmax(0,1fr) 32px; }
.invoice-editor-page .item-row input,.invoice-editor-page .prev-pay-row input { width: 100%; }
.invoice-editor-page .editor-money { position: relative; min-width: 0; }
.invoice-editor-page .editor-money input { width: 100%; padding-right: 27px; }
.invoice-editor-page .editor-money span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.invoice-editor-page input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.invoice-editor-page input::-webkit-inner-spin-button,.invoice-editor-page input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.invoice-editor-page .payment-summary { flex-wrap: wrap; gap: 10px 20px; padding-left: 0; padding-right: 0; }
.invoice-editor-page .proposal-source-row { grid-template-columns: minmax(0,1fr) minmax(90px,110px) 32px; }
.invoice-editor-page .invoice-preview-panel { display: flex; min-width: 0; min-height: 0; align-items: stretch; overflow: auto; }
.invoice-editor-page .editor-preview-toolbar { display: flex; flex-shrink: 0; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.invoice-editor-page .editor-preview-toolbar .invoice-preview-label { margin: 0; letter-spacing: 0; align-self: auto; }
.invoice-editor-page .editor-preview-toolbar label { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); }
.invoice-editor-page #editorPreviewZoom { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 6px; }
.invoice-editor-page .editor-preview-stage { position: relative; flex-shrink: 0; align-self: center; }
.invoice-editor-page .editor-preview-stage .invoice-doc { position: absolute; left: 0; top: 0; width: 210mm; max-width: none; flex-shrink: 0; transform-origin: top left; }
.invoice-editor-page .editor-navigation,.invoice-editor-page .editor-view-tabs { display: none; }
.invoice-editor-page button:focus-visible,.invoice-editor-page a:focus-visible,.invoice-editor-page summary:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; }

@media screen and (max-width: 1100px) {
  .invoice-editor-page { height: 100dvh; }
  .invoice-editor-page .sidebar { display: none; }
  .invoice-editor-page .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .invoice-editor-page .topbar-title { flex: 1; }
  .invoice-editor-page .topbar-actions { max-width: none; overflow: visible; }
  .invoice-editor-page .topbar .btn,.invoice-editor-page .back-btn { min-height: 44px; }
  .invoice-editor-page .back-btn { min-width: 32px; justify-content: center; }
  .invoice-editor-page .editor-navigation { display: block; position: relative; }
  .invoice-editor-page .editor-navigation summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; list-style: none; font-size: 12px; }
  .invoice-editor-page .editor-navigation summary::-webkit-details-marker { display: none; }
  .invoice-editor-page .editor-navigation nav { position: absolute; left: 0; top: 100%; width: 210px; padding: 8px; display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); z-index: 50; }
  .invoice-editor-page .editor-navigation nav a,.invoice-editor-page .editor-navigation nav button { display: flex; align-items: center; min-height: 44px; padding: 8px; text-align: left; font: inherit; color: var(--text); background: none; border: 0; }
  .invoice-editor-page .editor-view-tabs { display: flex; flex-shrink: 0; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .invoice-editor-page .editor-view-tabs button { min-height: 44px; flex: 1; font: inherit; font-size: 13px; background: none; color: var(--text-muted); border: 0; border-bottom: 2px solid transparent; }
  .invoice-editor-page .editor-view-tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--text); }
  .invoice-editor-page .content-area { overflow: auto !important; padding: 12px !important; overscroll-behavior: contain; }
  .invoice-editor-page .invoice-layout { height: auto; display: block; max-width: none; }
  .invoice-editor-page .invoice-form-panel { height: auto; overflow: visible; padding: 0; gap: 4px; }
  .invoice-editor-page .form-section { padding: 16px 4px; }
  .invoice-editor-page .form-section input,.invoice-editor-page .form-section select,.invoice-editor-page .form-section textarea { min-height: 44px; }
  .invoice-editor-page .form-section button { min-height: 44px; }
  .invoice-editor-page .item-remove,.invoice-editor-page .proposal-source-row .btn { width: 44px; height: 44px; justify-content: center; }
  .invoice-editor-page .item-row { grid-template-columns: minmax(0,1fr) minmax(100px,140px) 44px; gap: 8px; margin-bottom: 12px; }
  .invoice-editor-page .prev-pay-row { grid-template-columns: minmax(140px,1fr) minmax(0,1fr) 44px; gap: 8px; margin-bottom: 12px; }
  .invoice-editor-page .proposal-source-row { grid-template-columns: minmax(0,1fr) minmax(100px,150px) 44px; }
  .invoice-editor-page .invoice-preview-panel { height: auto; min-height: 250px; padding: 12px; overflow: auto; border-radius: 4px; }
  .invoice-editor-page #editorPreviewZoom { min-height: 44px; }
  /* Keep the A4 DOM measurable for print while only the form is on screen. */
  .invoice-editor-page[data-invoice-view=details] .invoice-preview-panel { position: fixed; left: -10000px; top: 0; width: 850px; visibility: hidden; pointer-events: none; }
  .invoice-editor-page[data-invoice-view=preview] .invoice-form-panel { display: none; }
}

@media screen and (max-width: 600px) {
  .invoice-editor-page .topbar-actions { width: 100%; }
  .invoice-editor-page .topbar-actions .btn { flex: 1; justify-content: center; padding: 8px; font-size: 13px; }
  .invoice-editor-page .form-grid { grid-template-columns: minmax(0,1fr); }
  .invoice-editor-page .form-section input,.invoice-editor-page .form-section select,.invoice-editor-page .form-section textarea { font-size: 16px; }
  .invoice-editor-page .item-row { grid-template-columns: minmax(0,1fr) 44px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .invoice-editor-page .item-row .item-desc { grid-column: 1 / -1; }
  .invoice-editor-page .prev-pay-row { grid-template-columns: minmax(0,1fr) 44px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
  .invoice-editor-page .prev-pay-row .pay-date { grid-column: 1 / -1; }
  .invoice-editor-page .proposal-source-row { grid-template-columns: minmax(0,1fr) 44px; }
  .invoice-editor-page .proposal-source-row select { grid-column: 1 / -1; }
  .invoice-editor-page .proposal-source-row a { overflow-wrap: anywhere; }
  .invoice-editor-page #f_vat_rate { min-width: 75px; }
}
