/* Phapur – editor + A4 sheet */
.editor-page { background: var(--paper-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar { background: var(--white); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.topbar-left, .topbar-right { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
.logo-sm { font-size: 20px; gap: 8px; }
.divider { width: 1px; height: 24px; background: var(--line); }
.doc-title { font: 600 16px var(--body); letter-spacing: 0; }
.saved { font-size: 13px; color: var(--ink-2); }
.saved::before { content: "✓ "; color: #0F766E; font-weight: 700; }

.editor { display: flex; flex-wrap: wrap; align-items: flex-start; }
.panel { flex: 1 1 380px; max-width: 520px; min-width: 0; background: var(--white); border-right: 1px solid var(--line); padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.panel fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel legend { font: 700 18px var(--head); margin-bottom: 12px; padding: 0; }
.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; min-width: 0; }
.panel input:not([type=checkbox]):not([type=radio]):not([type=file]), .panel textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #A9A595; border-radius: 8px; font: 400 15px var(--body); color: var(--ink); background: var(--white); }
.panel textarea { resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; }
.check { flex-direction: row !important; align-items: center; gap: 10px !important; font-size: 14px !important; font-weight: 500 !important; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }

.swatches { display: flex; gap: 10px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--white); box-shadow: 0 0 0 2px transparent; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.logo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; flex-direction: row !important; font-size: 14px !important; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.item { display: grid; grid-template-columns: minmax(0, 1fr) 64px 96px 44px; gap: 8px; align-items: end; margin-bottom: 10px; }
.item input { padding-left: 8px !important; padding-right: 8px !important; }
.remove { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--white); border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; color: var(--ink-2); }
.remove:hover { border-color: var(--ink); color: var(--ink); }
.add { align-self: flex-start; border-style: dashed; }
.privacy-note { margin: 0; font-size: 13px; color: var(--ink-2); }

.preview { flex: 999 1 560px; min-width: 0; padding: 32px 24px 64px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* The A4 sheet. Sized in mm so print matches screen. */
.sheet { --doc: #2747D6; width: 210mm; min-height: 297mm; background: var(--white); box-shadow: 0 20px 50px -20px rgba(21,23,28,.4); padding: 18mm 16mm; display: flex; flex-direction: column; font-size: 10pt; line-height: 1.45; color: var(--ink); transform-origin: top center; }
.pre { white-space: pre-line; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 6mm; border-bottom: 1.2mm solid var(--doc); }
.inv-from img { max-height: 18mm; max-width: 60mm; object-fit: contain; margin-bottom: 3mm; }
.inv-biz { font: 700 16pt var(--head); }
.inv-muted { color: var(--ink-3); }
.inv-meta { text-align: right; }
.inv-word { font: 700 22pt var(--head); color: var(--doc); letter-spacing: .02em; }
.inv-meta dl { margin: 2mm 0 0; display: grid; grid-template-columns: auto auto; gap: 1mm 4mm; justify-content: end; color: var(--ink-3); }
.inv-meta dt { font-weight: 600; }
.inv-meta dd { margin: 0; color: var(--ink); }
.inv-to { margin: 8mm 0; }
.inv-label { font-size: 8pt; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.inv-client { font-weight: 600; font-size: 12pt; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { text-align: left; font-weight: 600; padding: 2.5mm 0; border-bottom: .6mm solid var(--ink); }
.inv-table td { padding: 2.5mm 0; border-bottom: .2mm solid var(--line-2); vertical-align: top; }
.inv-table .num { text-align: right; padding-left: 4mm; white-space: nowrap; }
.inv-totals { margin: 5mm 0 0 auto; width: 70mm; display: flex; flex-direction: column; gap: 1.5mm; }
.inv-totals div { display: flex; justify-content: space-between; color: var(--ink-2); }
.inv-totals .grand { color: var(--ink); font-weight: 700; font-size: 13pt; padding-top: 2mm; border-top: .6mm solid var(--ink); }
.inv-foot { margin-top: auto; padding-top: 8mm; display: flex; flex-direction: column; gap: 2mm; color: var(--ink-2); }
.inv-foot > div:empty { display: none; }
#p-bank { padding: 3mm 4mm; background: #F3F2EE; color: var(--ink); }
.inv-reg { font-size: 8pt; color: var(--ink-3); }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(21,23,28,.5); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 20; }
.dialog-backdrop[hidden] { display: none; }
.dialog { background: var(--white); border-radius: 14px; padding: 28px; max-width: 480px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { font-size: 24px; }
.dialog p { margin: 0; color: var(--ink-2); }

@media (max-width: 900px) {
  .panel { max-width: none; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #FFFFFF !important; }
  .no-print { display: none !important; }
  .editor, .preview { display: block; padding: 0; margin: 0; }
  .sheet { box-shadow: none; transform: none !important; margin: 0; width: 210mm; height: 297mm; min-height: 0; overflow: hidden; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
