/* DBDON LPO — printable document, 3 templates, stamp & signatures */
.page {
  position: relative; width: 210mm; min-height: 297mm; padding: 0 14mm; background: #fff; color: #1d1d1d;
  box-shadow: 0 4px 30px rgba(43,27,16,.18); font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 10.5px; line-height: 1.45;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.page * { box-sizing: border-box; }
.pframe { width: 100%; border-collapse: collapse; }
.pframe > thead > tr > td, .pframe > tfoot > tr > td, .pframe > tbody > tr > td { padding: 0; border: 0; }
.pf-top { height: 7mm; }
.pf-bottom { height: 12mm; }
.sys-foot { position: absolute; left: 14mm; right: 14mm; bottom: 4mm; border-top: 1px solid #ccc; padding-top: 4px; font-size: 7.6px; color: #777; display: flex; justify-content: space-between; gap: 10px; }
.sys-foot b { color: #444; }
.doc h4 { margin: 9px 0 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.doc p { margin: 0 0 6px; }
.doc ol { margin: 0; padding-left: 16px; font-size: 9.3px; line-height: 1.35; }
.doc ol li { margin-bottom: 1px; }
.doc .muted { color: #777; }
.doc table { border-collapse: collapse; width: 100%; }
.doc .r { text-align: right; }
.doc .c { text-align: center; }
.doc .nowrap { white-space: nowrap; }
.doc .pre { white-space: pre-line; }
.doc .empty-v { color: #bbb; }

/* Items (shared) */
.items td, .items th { padding: 5px 6px; vertical-align: top; }
.items .desc2 { color: #555; font-size: 9.5px; }
.totals td { padding: 4px 6px; }
.words { margin: 8px 0; font-size: 10px; }
.words b { text-transform: uppercase; }

/* Signature zones */
.sig-zone { position: relative; height: 38px; }
.sig-img { position: absolute; z-index: 15; max-width: none; user-select: none; -webkit-user-drag: none; }
.sig-line { border-bottom: 1px dotted #777; height: 1px; }
.sig-date { font-size: 9.5px; }
.sig-meta { font-size: 7.5px; color: #8a8a8a; }

/* ---------- Template 1: Classic (DBDON) ---------- */
.tpl-classic .c-head { text-align: center; }
.tpl-classic .c-head img { width: 58px; height: auto; }
.tpl-classic .c-title { border-top: 1.5px solid #333; margin-top: 4px; padding-top: 5px; font-size: 15px; letter-spacing: 1px; font-weight: normal; color: #222; }
.tpl-classic .c-meta { margin-top: 10px; border: 1.2px solid #333; }
.tpl-classic .c-meta td { border: 1px solid #555; padding: 4px 6px; width: 25%; vertical-align: top; }
.tpl-classic .c-meta td.l { background: #f4cfae; font-weight: bold; color: #3E2415; }
.tpl-classic .c-parties { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #555; margin-top: 10px; }
.tpl-classic .c-parties > div { padding: 6px 8px; background: #f2f2f2; }
.tpl-classic .c-parties > div + div { border-left: 1px solid #555; }
.tpl-classic .c-parties .h { font-weight: bold; text-transform: uppercase; margin-bottom: 2px; }
.tpl-classic .intro { margin: 8px 0 4px; }
.tpl-classic .items { border: 1.2px solid #333; }
.tpl-classic .items th { background: #c4622d; color: #fff; text-align: left; border: 1px solid #8a4520; font-weight: bold; }
.tpl-classic .items td { border: 1px solid #777; }
.tpl-classic .items tr.grand td { background: #f4cfae; font-weight: bold; }
.tpl-classic .auth { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #555; }
.tpl-classic .auth .slot { border-right: 1px solid #555; border-bottom: 1px solid #555; }
.tpl-classic .auth .slot:nth-child(2n) { border-right: 0; }
.tpl-classic .auth .slot .h { background: #f4cfae; font-weight: bold; text-transform: uppercase; padding: 3px 7px; border-bottom: 1px solid #555; }
.tpl-classic .auth .slot .b { padding: 3px 7px 4px; }
.tpl-classic .ack { border: 1px solid #555; margin-top: 8px; }
.tpl-classic .ack .h { background: #f2f2f2; font-weight: bold; padding: 3px 7px; border-bottom: 1px solid #555; text-transform: uppercase; }
.tpl-classic .ack .b { padding: 5px 7px; }
.tpl-classic .ack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 6px; }
.tpl-classic .attach { text-align: center; font-style: italic; font-size: 9px; margin-top: 6px; color: #444; }

/* ---------- Template 2: Modern ---------- */
.tpl-modern::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 7px; background: linear-gradient(90deg, #3E2415 0 30%, #F7941D 30%); }
.tpl-modern .m-head { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 2px solid #F7941D; }
.tpl-modern .m-head img { width: 58px; }
.tpl-modern .m-org { flex: 1; }
.tpl-modern .m-org b { font-size: 13px; color: #3E2415; display: block; }
.tpl-modern .m-org div { font-size: 9px; color: #666; }
.tpl-modern .m-title { text-align: right; }
.tpl-modern .m-title h1 { margin: 0; font-size: 17px; color: #3E2415; letter-spacing: .5px; }
.tpl-modern .m-title .no { display: inline-block; margin-top: 5px; background: #F7941D; color: #fff; padding: 3px 10px; border-radius: 12px; font-weight: bold; font-size: 10px; }
.tpl-modern .m-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.tpl-modern .m-meta > div { background: #faf5ef; border-radius: 6px; padding: 5px 8px; }
.tpl-modern .m-meta .l { font-size: 7.8px; color: #8a7766; text-transform: uppercase; letter-spacing: .4px; }
.tpl-modern .m-meta .v { font-weight: bold; color: #2b1b10; }
.tpl-modern .m-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tpl-modern .m-parties > div { border: 1px solid #ecdccb; border-top: 3px solid #F7941D; border-radius: 6px; padding: 7px 9px; }
.tpl-modern .m-parties > div + div { border-top-color: #3E2415; }
.tpl-modern .m-parties .h { font-size: 8px; color: #8a7766; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.tpl-modern .intro { margin: 10px 0 6px; color: #444; }
.tpl-modern .items th { background: #3E2415; color: #fff; text-align: left; font-size: 9.5px; font-weight: bold; }
.tpl-modern .items th:first-child { border-radius: 5px 0 0 0; }
.tpl-modern .items th:last-child { border-radius: 0 5px 0 0; }
.tpl-modern .items td { border-bottom: 1px solid #efe5da; }
.tpl-modern .items tbody tr:nth-child(even) td { background: #fcf8f3; }
.tpl-modern .totals-wrap { display: flex; justify-content: flex-end; margin-top: 6px; }
.tpl-modern .totals { width: 46%; }
.tpl-modern .totals tr.grand td { background: #F7941D; color: #fff; font-weight: bold; font-size: 11.5px; }
.tpl-modern .totals tr.grand td:first-child { border-radius: 5px 0 0 5px; }
.tpl-modern .totals tr.grand td:last-child { border-radius: 0 5px 5px 0; }
.tpl-modern h4 { color: #3E2415; border-left: 3px solid #F7941D; padding-left: 6px; }
.tpl-modern .auth { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tpl-modern .auth .slot { border: 1px solid #ecdccb; border-radius: 6px; padding: 6px 9px; }
.tpl-modern .auth .slot .h { font-size: 8px; text-transform: uppercase; color: #F7941D; font-weight: bold; letter-spacing: .5px; }
.tpl-modern .ack { margin-top: 10px; background: #faf5ef; border-radius: 6px; padding: 7px 10px; }
.tpl-modern .ack .h { font-weight: bold; color: #3E2415; text-transform: uppercase; font-size: 9px; }
.tpl-modern .ack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 14px; margin-top: 6px; }
.tpl-modern .attach { font-size: 9px; color: #666; margin-top: 8px; }

/* ---------- Template 3: Formal ---------- */
.tpl-formal .f-head { text-align: center; }
.tpl-formal .f-head img { width: 50px; }
.tpl-formal .f-head .org { font-weight: bold; font-size: 13px; margin-top: 3px; }
.tpl-formal .f-head .addr { font-size: 9px; }
.tpl-formal .f-rule { border-top: 3px double #000; margin: 6px 0 4px; }
.tpl-formal .f-title { text-align: center; font-weight: bold; font-size: 13px; letter-spacing: 1px; text-decoration: underline; margin: 4px 0 8px; }
.tpl-formal .f-top { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.tpl-formal .f-top .kvs div { padding: 1px 0; display: grid; grid-template-columns: 44% 1fr; gap: 6px; }
.tpl-formal .f-top .kvs b { font-size: 9.5px; text-transform: uppercase; }
.tpl-formal .intro { margin: 8px 0 5px; font-style: italic; }
.tpl-formal .items th { background: #e6e6e6; border: 1px solid #000; text-transform: uppercase; font-size: 9px; text-align: left; }
.tpl-formal .items td { border: 1px solid #000; }
.tpl-formal .items tr.grand td { font-weight: bold; background: #f2f2f2; }
.tpl-formal .words { border-bottom: 1px solid #000; padding-bottom: 4px; }
.tpl-formal .auth table { border: 1px solid #000; }
.tpl-formal .auth th { background: #e6e6e6; border: 1px solid #000; padding: 3px 6px; text-align: left; font-size: 9px; text-transform: uppercase; }
.tpl-formal .auth td { border: 1px solid #000; padding: 3px 6px; vertical-align: middle; }
.tpl-formal .auth td.sigcell { width: 32%; }
.tpl-formal .auth .sig-zone { height: 32px; }
.tpl-formal .ack { border: 1px solid #000; padding: 6px 8px; margin-top: 8px; }
.tpl-formal .ack .h { font-weight: bold; text-transform: uppercase; }
.tpl-formal .ack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 6px; }
.tpl-formal .attach { font-size: 9px; margin-top: 6px; }

/* ---------- Auto "fit on one page" (added by the renderer only when needed) ---------- */
.page.fit-1 { font-size: 10px; line-height: 1.38; }
.page.fit-1 .doc ol { font-size: 8.8px; line-height: 1.3; }
.page.fit-1 .items td, .page.fit-1 .items th, .page.fit-1 .totals td { padding-top: 3px; padding-bottom: 3px; }
.page.fit-1 .c-meta td { padding-top: 2px; padding-bottom: 2px; }
.page.fit-1 .doc h4 { margin: 7px 0 3px; }
.page.fit-1 .doc p, .page.fit-1 .words { margin-top: 4px; margin-bottom: 4px; }
.page.fit-1 .c-parties > div, .page.fit-1 .m-parties > div { padding-top: 4px; padding-bottom: 4px; }
.page.fit-1 .ack { margin-top: 5px; }
.page.fit-2 { font-size: 9.4px; line-height: 1.3; }
.page.fit-2 .doc ol { font-size: 8.4px; }
.page.fit-2 .sig-zone { height: 30px; }
.page.fit-2 .tpl-classic .c-head img, .page.fit-2 .c-head img, .page.fit-2 .m-head img, .page.fit-2 .f-head img { width: 44px; }
.page.fit-2 .c-title { font-size: 13px; }
.page.fit-2 .items td, .page.fit-2 .items th, .page.fit-2 .totals td { padding-top: 2px; padding-bottom: 2px; }
.page.fit-2 .sig-meta { display: none; }

/* ---------- Stamp ---------- */
.stamp { position: absolute; z-index: 20; mix-blend-mode: multiply; transform-origin: 50% 50%; user-select: none; }
.stamp svg { width: 100%; height: 100%; display: block; overflow: visible; }
.page:not(.editable) .stamp { pointer-events: none; }

/* ---------- Editing affordances (screen only) ---------- */
.page.editable .stamp { cursor: move; }
.page.editable .stamp:hover, .page.editable .stamp.sel { outline: 1.5px dashed #F7941D; outline-offset: 4px; border-radius: 50%; }
.handle { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid #F7941D; border-radius: 50%; z-index: 25; display: none; }
.page.editable .stamp:hover .handle, .page.editable .stamp.sel .handle,
.page.editable .sig-img-wrap:hover .handle, .page.editable .sig-img-wrap.sel .handle { display: block; }
.h-resize { right: -6px; bottom: -6px; cursor: nwse-resize; }
.h-rot { left: 50%; top: -26px; margin-left: -8px; cursor: grab; background: #F7941D; }
.h-rot::after { content: ""; position: absolute; left: 5px; top: 14px; width: 2px; height: 12px; background: #F7941D; }
.sig-img-wrap { position: absolute; z-index: 15; }
.sig-img-wrap img { width: 100%; display: block; pointer-events: none; }
.page.editable .sig-img-wrap { cursor: move; }
.page.editable .sig-img-wrap:hover, .page.editable .sig-img-wrap.sel { outline: 1.5px dashed #F7941D; outline-offset: 2px; }
.page.editable .sig-zone.can-sign { cursor: pointer; }
.sig-ph { position: absolute; inset: 4px 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 9.5px; color: #c27a22; border: 1.5px dashed #f2c48c; border-radius: 6px; background: rgba(255,243,228,.6); transition: background .15s; }
.sig-zone.can-sign:hover .sig-ph { background: rgba(255,226,190,.9); }
.sig-ph.invited { color: #9a6a00; border-color: #f0d68a; background: rgba(255,248,225,.7); }
.sig-ph.declined { color: #c62828; border-color: #f3b3ad; background: rgba(253,236,234,.7); }
.sig-zone.target { animation: zonePulse 1.4s infinite; border-radius: 6px; }
@keyframes zonePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(247,148,29,.6); } 50% { box-shadow: 0 0 0 8px rgba(247,148,29,0); } }

@media screen and (max-width: 900px) { .page { margin: 0 auto; } }

/* ---------- Print ---------- */
@page { size: A4; margin: 0; }
@media print {
  html, body { width: 210mm; }
  .page { box-shadow: none !important; margin: 0 !important; min-height: 0; }
  .sys-foot { position: fixed; bottom: 4mm; left: 14mm; right: 14mm; }
  .sig-ph, .handle { display: none !important; }
  .stamp, .sig-img-wrap { outline: none !important; }
  .sig-zone.target { animation: none; box-shadow: none; }
  .items tr, .auth .slot, .ack, .totals tr { page-break-inside: avoid; break-inside: avoid; }
}
