/* /tools/ documents : invoices, receipts, payslips, calculator reports.
   Used by the live preview (in .tk-preview-page) AND copied into the PDF by tools/pdf/index.php,
   so the PDF looks exactly like the preview. A4 at 96 dpi = 794 px wide (US Letter 816). --accent comes from the document.
   Pages : the PDF has 48 px margins top and bottom (none on top of page 1, see tools/pdf/index.php). tools.js paginate()
   lays the document out on those pages and puts a spacer (.tk-doc-space) before .tk-doc-end (signature + footer),
   so that block always ends at the bottom of the last page.
   Font : Noto Sans JP, the font the PDF service has, so the preview measures pages exactly like the PDF. */

.tk-doc { --accent:#2563eb; box-sizing:border-box; display:flex; flex-direction:column; width:794px; padding:56px 60px 0; background:#fff; color:#1f2937; font-family:"Noto Sans JP","Hiragino Sans",Arial,sans-serif; font-size:13px; line-height:1.55; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
.tk-doc.size-letter { width:816px; }
.tk-doc-space { flex-shrink:0; }
.tk-doc > * { flex-shrink:0; }
.tk-doc-end { padding-top:26px; break-inside:avoid; page-break-inside:avoid; }
.tk-doc * { box-sizing:border-box; }
.tk-doc { -webkit-text-size-adjust:100%; text-size-adjust:100%; }   /* phones must not enlarge document text (pages are measured) */
/* the same in the preview (site page with Bootstrap) and in the PDF (no Bootstrap) : measured pages must match */
.tk-doc h1, .tk-doc h2, .tk-doc h3, .tk-doc h4 { margin-top:0; line-height:1.3; }
.tk-doc p { margin:0 0 10px; }
.tk-doc ul, .tk-doc ol { margin-top:0; }
.tk-doc img, .tk-doc svg { vertical-align:middle; }
.tk-doc .tk-svg-chart { display:block; }
.tk-doc b, .tk-doc strong { font-weight:700; }

/* head */
.tk-doc-head { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; margin:0 0 34px; }
.tk-doc-brand { max-width:55%; min-width:0; overflow-wrap:anywhere; }
.tk-doc-logo { display:block; max-width:200px; max-height:80px; margin:0 0 10px; object-fit:contain; }
.tk-doc-brand-name { font-size:18px; font-weight:800; color:#111827; }
.tk-doc-title-box { min-width:0; max-width:50%; text-align:right; overflow-wrap:anywhere; }
.tk-doc-title { font-size:30px; font-weight:800; letter-spacing:2px; color:var(--accent); text-transform:uppercase; }
.tk-doc-number { margin:4px 0 0; color:#6b7280; font-size:13px; }
.tk-doc-number b { color:#111827; }

/* parties + dates */
.tk-doc-parties { display:flex; gap:24px; margin:0 0 28px; }
.tk-doc-party { flex:1; min-width:0; overflow-wrap:anywhere; }
.tk-doc-party-name { margin:0 0 2px; font-size:14px; font-weight:700; color:#111827; }
.tk-doc-meta { flex:0 0 200px; min-width:0; }
.tk-doc-meta-row { display:flex; justify-content:space-between; gap:10px; padding:4px 0; border-bottom:1px solid #f1f5f9; }
.tk-doc-meta-row span { flex-shrink:0; color:#6b7280; }
.tk-doc-meta-row b { min-width:0; text-align:right; overflow-wrap:anywhere; }
.tk-doc-label { margin:0 0 6px; color:var(--accent); font-size:11px; font-weight:800; letter-spacing:1px; text-transform:uppercase; }

/* table */
.tk-doc-table { width:100%; margin:0 0 20px; border-collapse:collapse; }
.tk-doc-table th { padding:10px 12px; background:var(--accent); color:#fff; font-size:11.5px; font-weight:700; letter-spacing:.4px; text-align:left; text-transform:uppercase; }
.tk-doc-table td { padding:10px 12px; border-bottom:1px solid #e5e7eb; vertical-align:top; overflow-wrap:anywhere; }
.tk-doc-table .r { text-align:right; white-space:nowrap; }
.tk-doc-table tbody tr:nth-child(even) td { background:#f9fafb; }

/* totals */
.tk-doc-sum { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; margin:0 0 26px; }
.tk-doc-sum-left { flex:1; }
.tk-doc-totals { flex:0 0 290px; }
.tk-doc-total { display:flex; justify-content:space-between; gap:12px; padding:6px 12px; }
.tk-doc-total b { min-width:0; text-align:right; overflow-wrap:anywhere; }
.tk-doc-total.tk-long b, .tk-doc-total.tk-xlong b { font-size:13px; }
.tk-doc-total span { color:#4b5563; }
.tk-doc-total.strong { margin:6px 0 0; padding:11px 12px; border-radius:6px; background:var(--accent); color:#fff; font-size:15px; }
.tk-doc-total.strong span { color:#fff; font-weight:700; }
.tk-doc-stamp { display:inline-block; margin:8px 0 0 8px; padding:6px 18px; border:3px solid #16a34a; border-radius:8px; color:#16a34a; font-size:24px; font-weight:800; letter-spacing:3px; transform:rotate(-8deg); }

/* notes, signature, footer */
.tk-doc-block { margin:0 0 18px; padding:14px 16px; border-radius:8px; background:#f9fafb; overflow-wrap:anywhere; }
.tk-doc-sign { width:230px; margin:0 0 0 auto; text-align:center; overflow-wrap:anywhere; }
.tk-doc-sign-box { display:flex; align-items:flex-end; justify-content:center; height:70px; }
.tk-doc-sign-box img { max-width:200px; max-height:66px; object-fit:contain; }
.tk-doc-sign-line { padding:6px 0 0; border-top:1px solid #9ca3af; color:#6b7280; font-size:12px; }
.tk-doc-footer { margin:22px 0 0; padding:14px 0 0; border-top:1px solid #e5e7eb; color:#6b7280; font-size:12px; text-align:center; }

/* template : modern (colour band on top) */
.tk-doc.t-modern { padding-top:0; }
.tk-doc.t-modern .tk-doc-head { margin:0 -60px 34px; padding:40px 60px 30px; background:var(--accent); color:#fff; }
.tk-doc.t-modern .tk-doc-brand-name, .tk-doc.t-modern .tk-doc-title, .tk-doc.t-modern .tk-doc-number, .tk-doc.t-modern .tk-doc-number b { color:#fff; }
.tk-doc.t-modern .tk-doc-logo { padding:6px; border-radius:6px; background:#fff; }

/* template : minimal (no colour blocks, thin lines) */
.tk-doc.t-minimal .tk-doc-title { color:#111827; letter-spacing:4px; font-weight:300; }
.tk-doc.t-minimal .tk-doc-table th { background:none; border-bottom:2px solid #111827; color:#111827; }
.tk-doc.t-minimal .tk-doc-table tbody tr:nth-child(even) td { background:none; }
.tk-doc.t-minimal .tk-doc-total.strong { background:none; border-top:2px solid #111827; border-radius:0; color:#111827; }
.tk-doc.t-minimal .tk-doc-total.strong span { color:#111827; }
.tk-doc.t-minimal .tk-doc-label { color:#6b7280; }
.tk-doc.t-minimal .tk-doc-block { background:none; padding:0; }

/* calculator reports */
.tk-doc.t-report { padding:48px 56px 0; }
.tk-report-head { display:flex; justify-content:space-between; gap:20px; margin:0 0 26px; padding:0 0 18px; border-bottom:3px solid var(--accent); }
.tk-report-title { font-size:24px; font-weight:800; color:#111827; }
.tk-report-sub { margin:4px 0 0; color:#6b7280; }
.tk-report-brand { color:var(--accent); font-size:12px; font-weight:800; text-align:right; }
.tk-report-brand span { color:#6b7280; font-weight:500; }
.tk-report-section { margin:0 0 24px; }
.tk-report-section h2 { margin:0 0 10px; font-size:15px; font-weight:800; color:#111827; }
.tk-report-stats { display:flex; flex-wrap:wrap; gap:10px; }
.tk-report-stat { flex:1 1 30%; min-width:0; padding:12px 14px; border:1px solid #e5e7eb; border-radius:8px; }
.tk-report-stat span { display:block; color:#6b7280; font-size:11.5px; }
.tk-report-stat b { display:block; margin:2px 0 0; font-size:17px; line-height:1.3; color:#111827; overflow-wrap:anywhere; }
.tk-report-stat.tk-long b { font-size:14px; }
.tk-report-stat.tk-xlong b { font-size:12px; }
.tk-report-stat.main { border-color:var(--accent); background:var(--accent); }
.tk-report-stat.main span, .tk-report-stat.main b { color:#fff; }
.tk-report-table { font-size:12px; }
.tk-report-table th, .tk-report-table td { padding:7px 10px; }
.tk-report-chart { display:flex; align-items:center; gap:24px; }
.tk-report-chart .tk-svg-chart { width:100%; height:auto; }
.tk-report-legend { margin:0; padding:0; list-style:none; }
.tk-report-legend li { display:flex; align-items:center; gap:8px; margin:0 0 6px; }
.tk-report-legend i { display:inline-block; width:12px; height:12px; border-radius:3px; }
/* a long table continues on the next page (its heading row is repeated there) ; single rows and boxes are never cut */
.tk-doc tr, .tk-doc-sum, .tk-doc-block, .tk-doc-parties, .tk-doc-head, .tk-report-stats { page-break-inside:avoid; break-inside:avoid; }
.tk-doc thead { display:table-header-group; }
/* report sections : a heading stays with what follows it ; a section without a table is never cut */
.tk-report-section h2 { break-after:avoid; page-break-after:avoid; }
.tk-report-section:not(.has-table) { break-inside:avoid; page-break-inside:avoid; }

/* several documents in one PDF (rent receipts per month) : each on its own page ; the page margin is already above it */
.tk-doc + .tk-doc { break-before:page; page-break-before:always; padding-top:8px; }
.tk-doc.t-modern + .tk-doc.t-modern .tk-doc-head { margin-top:0; }
