/* The invoice as a paper document (app/views/doklad.py). Uses the tokens from base.css on screen;
   in print it is black on white on A4, with the app chrome hidden. Classes are prefixed dk- so the sheet can sit on any
   page next to desk.css or issue.css without clashing. */

.doklad { background: var(--sheet); color: var(--ink); border-radius: var(--r-sheet); box-shadow: var(--sheet-shadow);
  max-width: 820px; padding: var(--s-7); position: relative; font-size: var(--f-15); line-height: 22px; }
.doklad p { margin: 0; max-width: none; }
.doklad dl { margin: 0; }
.doklad dt { font-size: var(--f-13); line-height: 18px; color: var(--ink-2); font-weight: 500; }
.doklad dd { margin: 0; font-variant-numeric: tabular-nums; }
.dk-missing { color: var(--ink-2); font-style: italic; font-weight: 400; }

.dk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-5); flex-wrap: wrap;
  padding-bottom: var(--s-5); border-bottom: 2px solid var(--ink); }
.dk-kind { color: var(--ink-2); font-weight: 500; margin-bottom: var(--s-1) !important; }
.dk-number { font-size: var(--f-33); line-height: 40px; font-variant-numeric: tabular-nums; letter-spacing: -0.015em;
  overflow-wrap: anywhere; }
.dk-dates { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.dk-dates dd { font-weight: 550; }

.dk-parties { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); padding: var(--s-5) 0; }
.dk-party h3 { font-size: var(--f-13); line-height: 18px; color: var(--ink-2); font-weight: 500; margin-bottom: var(--s-2); }
.dk-name { font-size: var(--f-17); font-weight: 600; overflow-wrap: anywhere; }
.dk-trade { color: var(--ink-2); }
.dk-addr { display: grid; color: var(--ink-2); margin: 2px 0 var(--s-3) !important; }
.dk-ids { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); }
.dk-ids dd { overflow-wrap: anywhere; }
.dk-contact { margin-top: var(--s-2) !important; }
.dk-legal { margin-top: var(--s-2) !important; font-size: var(--f-13); color: var(--ink-2); }

.dk-payment { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s-4);
  padding: var(--s-4) 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.dk-pay { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); }
.dk-pay dd { font-weight: 550; }
.dk-iban { white-space: nowrap; letter-spacing: .02em; }
.dk-qr { margin: 0; display: grid; justify-items: center; gap: var(--s-1); }
.dk-qr svg, .dk-qr img { width: 112px; height: 112px; display: block; background: #fff; padding: 4px; border-radius: 2px; }
.dk-qr figcaption { font-size: 11px; line-height: 14px; color: var(--ink-2); }

.dk-table-wrap { overflow-x: auto; }
table.dk-items { width: 100%; border-collapse: collapse; margin-top: var(--s-5); }
table.dk-items th { text-align: left; font-size: var(--f-13); line-height: 18px; font-weight: 500; color: var(--ink-2);
  padding: 0 var(--s-3) var(--s-2) 0; border-bottom: 1px solid var(--rule); vertical-align: bottom; }
table.dk-items td { padding: var(--s-3) var(--s-3) var(--s-3) 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.dk-items th:last-child, table.dk-items td:last-child { padding-right: 0; }
table.dk-items .num { text-align: right; }
table.dk-items .dk-n { width: 2.2em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dk-desc { overflow-wrap: anywhere; }
.dk-sub { display: none; }
.dk-empty { padding: var(--s-5) 0; color: var(--ink-2); }

.dk-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-6); align-items: end; margin-top: var(--s-5); }
table.dk-rek { border-collapse: collapse; font-size: var(--f-13); width: 100%; max-width: 420px; }
table.dk-rek caption { text-align: left; font-weight: 500; color: var(--ink-2); padding-bottom: var(--s-1); }
table.dk-rek th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 2px var(--s-3) 2px 0; }
table.dk-rek tbody th { color: var(--ink); font-weight: 550; }
table.dk-rek td { padding: 2px var(--s-3) 2px 0; }
table.dk-rek th:last-child, table.dk-rek td:last-child { padding-right: 0; }
table.dk-rek .num { text-align: right; }
.dk-cat { display: block; font-weight: 400; color: var(--ink-2); }
.dk-totals { display: grid; justify-items: end; gap: var(--s-3); }
.dk-sums { display: grid; gap: 2px; min-width: 220px; }
.dk-sums div { display: flex; justify-content: space-between; gap: var(--s-5); }
.dk-sums dt { font-size: var(--f-15); line-height: 22px; }
.dk-due { display: grid; justify-items: end; gap: 2px; }
.dk-due-label { color: var(--ink-2); font-weight: 500; }
/* accounting's double rule under the final total — the most important number on the document */
.dk-due strong { font-size: var(--f-41); line-height: 48px; font-weight: 650; letter-spacing: -0.02em;
  border-bottom: 4px double var(--ink); padding-bottom: 2px; }
.dk-due-when { font-size: var(--f-13); color: var(--ink-2); margin-top: var(--s-1); }
.dk-notes { margin-top: var(--s-5); padding-top: var(--s-3); border-top: 1px solid var(--rule); font-size: var(--f-13);
  color: var(--ink-2); white-space: pre-line; display: grid; gap: var(--s-1); }

@media (max-width: 767px) {
  .doklad { padding: var(--s-5) var(--s-4); }
  .dk-number { font-size: var(--f-26); line-height: 32px; }
  .dk-parties { grid-template-columns: 1fr; gap: var(--s-4); }
  .dk-payment { grid-template-columns: 1fr; }
  .dk-qr { justify-items: start; }
  table.dk-items thead { display: none; }
  table.dk-items, table.dk-items tbody, table.dk-items tr, table.dk-items td { display: block; }
  table.dk-items tr { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s-3); padding: var(--s-3) 0;
    border-bottom: 1px solid var(--rule); }
  table.dk-items td { border: 0; padding: 0; }
  table.dk-items td.dk-n, table.dk-items td:nth-child(3), table.dk-items td:nth-child(4), table.dk-items td:nth-child(5) { display: none; }
  table.dk-items td.dk-desc { grid-column: 1; }
  table.dk-items td:last-child { grid-column: 2; grid-row: 1; font-weight: 550; }
  .dk-sub { display: block; font-size: var(--f-13); color: var(--ink-2); }
  .dk-foot { grid-template-columns: 1fr; gap: var(--s-4); }
  .dk-totals, .dk-due { justify-items: start; }
  .dk-sums { min-width: 0; width: 100%; }
  .dk-due strong { font-size: var(--f-33); line-height: 40px; }
}

/* ── print: A4, black on white, only the document ──────────────────────── */
@page { size: A4; margin: 14mm 13mm 16mm; }
@media print {
  :root, :root[data-theme="dark"] {
    --paper: #fff; --sheet: #fff; --ink: #000; --ink-2: #333; --rule: #999; --sheet-shadow: none; color-scheme: light;
  }
  html, body { background: #fff !important; color: #000 !important; }
  body { font-size: 10pt; line-height: 1.35; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .rail, .foot, .toast, .skip, nav, button { display: none !important; }
  .shell { display: block !important; background: none !important; padding: 0 !important; }
  .content, main, .page { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .doklad { box-shadow: none; border-radius: 0; padding: 0; max-width: none; width: 100%; font-size: 10pt; line-height: 1.35;
    color: #000; background: #fff; }
  .doklad dt { font-size: 8pt; line-height: 1.3; color: #333; }
  .dk-number { font-size: 20pt; line-height: 1.2; }
  .dk-name { font-size: 11.5pt; }
  .dk-head { padding-bottom: 4mm; border-bottom: 1.5pt solid #000; }
  .dk-parties { grid-template-columns: 1fr 1fr; gap: 8mm; padding: 4mm 0; }
  .dk-payment { grid-template-columns: 1fr auto; padding: 3mm 0; border-color: #000; }
  .dk-qr svg, .dk-qr img { width: 30mm; height: 30mm; padding: 0; }
  .dk-table-wrap { overflow: visible; }
  table.dk-items { margin-top: 4mm; font-size: 9.5pt; }
  table.dk-items thead { display: table-header-group; }
  table.dk-items, table.dk-items tbody { display: table; width: 100%; }
  table.dk-items tbody { display: table-row-group; }
  table.dk-items tr { display: table-row; break-inside: avoid; }
  table.dk-items td, table.dk-items td.dk-n, table.dk-items td:nth-child(3), table.dk-items td:nth-child(4),
  table.dk-items td:nth-child(5) { display: table-cell; padding: 1.6mm 2.5mm 1.6mm 0; border-bottom: .5pt solid #999; }
  table.dk-items th { font-size: 8pt; color: #333; border-bottom: 1pt solid #000; }
  .dk-sub { display: none !important; }
  .dk-foot { grid-template-columns: minmax(0, 1fr) auto; gap: 8mm; margin-top: 4mm; break-inside: avoid; }
  .dk-totals, .dk-due { justify-items: end; }
  .dk-due strong { font-size: 18pt; line-height: 1.25; border-bottom: 3pt double #000; }
  .dk-notes { break-inside: avoid; border-color: #999; color: #000; font-size: 8.5pt; }
  a { color: #000; text-decoration: none; }
}
