/* Printable documents (offer, internal sheet, contract, PV, warranty). A4 on print, scrollable on phone. */
.doc { background: #fff; color: #1B1230; max-width: 794px; margin: 0 auto 16px; padding: 22px 18px; font: 13px/1.5 'Manrope', system-ui, sans-serif; border: 1px solid #DDD3EE; border-radius: 12px; }
.doc h1 { font: 700 1.3rem 'Sora', sans-serif; margin: 0 0 4px; color: #6D28D9; }
.doc h2 { font: 700 .95rem 'Sora', sans-serif; margin: 16px 0 6px; }
.d-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 3px solid #6D28D9; margin-bottom: 14px; }
.d-firm { display: flex; gap: 10px; }
.d-logo { width: 40px; height: 40px; border-radius: 10px; background: #140C2A; color: #F5A524; display: grid; place-items: center; font: 700 1.2rem 'Sora', sans-serif; flex: none; }
.d-title { margin-left: auto; text-align: right; }
.d-muted, .d-code { color: #4F4566; font-size: .85em; }
.d-client { background: #F6F3FB; border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.d-client h2 { margin: 0 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: #4F4566; }
.d-note { background: #F6F3FB; border-left: 3px solid #C4B5FD; padding: 8px 10px; font-size: .92em; }
.d-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.d-table th, .d-table td { border-bottom: 1px solid #ECE6F7; padding: 6px 5px; text-align: left; vertical-align: top; }
.d-table thead th { background: #140C2A; color: #fff; font-weight: 600; font-size: .85em; }
.d-table tbody th { width: 38%; color: #4F4566; font-weight: 600; }
.d-table .n, .d-totals .n { text-align: right; white-space: nowrap; }
.d-small { font-size: .88em; }
.d-disc td { color: #B42318; }
.d-edited td { background: #FFF4DE; }
.d-totals { margin: 8px 0 0 auto; min-width: 60%; border-collapse: collapse; }
.d-totals td { padding: 4px 6px; }
.d-grand td { font: 700 1.1em 'Sora', sans-serif; border-top: 2px solid #140C2A; color: #6D28D9; }
.d-terms ul, .doc ul { padding-left: 18px; margin: 4px 0; }
.d-foot { margin-top: 18px; padding-top: 8px; border-top: 1px solid #ECE6F7; color: #4F4566; font-size: .8em; text-align: center; }
.d-internal-band { background: #B42318; color: #fff; font: 700 .85rem 'Sora', sans-serif; letter-spacing: .1em; text-align: center; padding: 6px; margin: -22px -18px 14px; border-radius: 12px 12px 0 0; }
.d-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.d-tiles div { background: #F6F3FB; border-radius: 8px; padding: 8px 10px; }
.d-tiles span { display: block; font-size: .8em; color: #4F4566; }
.d-tiles strong { font: 700 1.05em 'Sora', sans-serif; }
.d-draft { background: #FFF4DE; border: 1px dashed #F5A524; padding: 6px 10px; font-size: .85em; }
.d-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 22px; }
.d-sigbox { height: 80px; border-bottom: 1px solid #1B1230; display: flex; align-items: flex-end; padding-bottom: 4px; }
.d-sigbox img { max-height: 76px; max-width: 100%; }
.doc-bar { display: flex; gap: 8px; justify-content: space-between; max-width: 794px; margin: 0 auto 12px; }
@media (min-width: 600px) { .d-tiles { grid-template-columns: repeat(4, 1fr); } .doc { padding: 32px 36px; } .d-internal-band { margin: -32px -36px 16px; } }

/* Phone screens: line tables become stacked rows. Print keeps the A4 table. */
@media screen and (max-width: 599px) {
  .doc { overflow-wrap: anywhere; }
  .d-firm > div:last-child { min-width: 0; }
  .d-title { margin-left: 0; text-align: left; }
  .d-lines thead, .d-lines-int thead { display: none; }
  .d-lines, .d-lines tbody, .d-lines-int, .d-lines-int tbody { display: block; }
  .d-lines tr, .d-lines-int tr { display: grid; border-bottom: 1px solid #ECE6F7; padding: 8px 0; }
  .d-lines td, .d-lines-int td { border: 0; padding: 1px 2px; }
  .d-lines td:empty { display: none; }
  .d-lines td[data-l]::before, .d-lines-int td[data-l]::before { content: attr(data-l) " "; color: #4F4566; font-weight: 400; }

  .d-lines tr { grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
  .d-lines td:nth-child(1) { display: none; }
  .d-lines td:nth-child(2) { grid-column: 1; grid-row: 1; }
  .d-lines td:nth-child(5) { grid-column: 2; grid-row: 1; font-weight: 700; }
  .d-lines td:nth-child(3), .d-lines td:nth-child(4) { grid-column: 1 / -1; text-align: left; font-size: .88em; }

  .d-lines-int tr { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
  .d-lines-int td:nth-child(1), .d-lines-int td:nth-child(2) { grid-column: 1 / -1; }
  .d-lines-int td:nth-child(2) { font-weight: 700; }
  .d-lines-int td.n { display: flex; justify-content: space-between; gap: 6px; }
}

@page { size: A4; margin: 14mm; }
@media print {
  body { background: #fff; padding: 0; }
  .no-print, .top, .nav, .toast, .doc-bar { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .doc { border: 0; border-radius: 0; padding: 0; max-width: none; font-size: 11pt; }
  .d-internal-band { margin: 0 0 12px; border-radius: 0; }
  .d-tiles { grid-template-columns: repeat(4, 1fr); }
  .d-table thead th, .d-internal-band, .d-logo, .d-edited td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { page-break-inside: avoid; }
}

.doc-bar { flex-wrap: wrap; }
/* Off-screen A4 sheet for the signed PDF */
.pdf-stage { position: fixed; left: -10000px; top: 0; width: 718px; }
.pdf-stage td[data-l]::before { content: none !important; } /* html2canvas copies ::before from the phone layout */
.pdf-stage .doc { width: 718px; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; }

/* Contract */
.doc-contract h2 { margin-top: 14px; }
.doc-contract p, .doc-contract li { margin: 0 0 4px; }
.d-blank { color: #B42318; }
.d-annex { margin-top: 28px; padding-top: 8px; border-top: 1px solid #ECE6F7; }
@page contract { size: A4; margin: 14mm 14mm 18mm; @bottom-center { content: "Pagina " counter(page) " din " counter(pages); font: 9pt system-ui, sans-serif; } }
@media print {
  .doc-contract, .doc-attach, .doc-next { page: contract; }
  .doc-attach, .doc-next { break-before: page; }
  .doc-contract h2 { break-after: avoid; }
  .doc-contract p, .doc-contract li, .doc-contract .d-sign { break-inside: avoid; }
  .doc-contract { font-size: 10pt; line-height: 1.4; }
  .doc-contract .d-sign { break-before: avoid; }
  .d-annex { break-before: page; border: 0; margin: 0; }
}
