/**
 * Shared styles for invoices & acts
 * Built on the "Artem B" design system — Exo 2, warm paper, hairline rules,
 * orange accent used sparingly. No shadows, no gradients. Compact density.
 * @ artbels
 */

@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --primary: #0E0F11;       /* warm ink — text, headings */
  --neutral: #FCFBF7;       /* warm paper — canvas */
  --muted: #5E6065;         /* sub-text, meta, labels */
  --rule: #E5E0D5;          /* hairline borders, dividers */
  --accent: #E85A1A;        /* orange — used sparingly */
  --accent-quiet: #FFE6D5;  /* soft callout surface */
  --accent-ink: #FCFBF7;    /* text on accent */
  --accent-hover: #D44A0F;
  --pad-x: 44px;
  --pad-y: 40px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Exo 2', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 400;
  color: var(--primary);
  background: var(--neutral);
  padding: 36px 24px;
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sheet {
  max-width: 720px;
  margin: 0 auto;
  background: var(--neutral);
  border: 1px solid var(--rule);
  padding: var(--pad-y) var(--pad-x);
}

/* ---------- Header ---------- */

.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 22px;
  margin-bottom: 26px;
}

.doc-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.doc-meta {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.02em;
}

.doc-meta .label {
  color: var(--muted);
  font-weight: 500;
}

.doc-date {
  text-align: right;
  white-space: nowrap;
  line-height: 1.4;
}

.doc-date .cap {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.doc-date .value {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

/* ---------- Parties ---------- */

.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  margin-bottom: 26px;
}

.party {
  padding: 14px 16px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.party.full {
  grid-column: 1 / -1;
}

.party-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.party-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--primary);
}

.party-body strong {
  font-weight: 600;
}

/* ---------- Line-items table ---------- */

.items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 22px;
  font-size: 13.5px;
}

.items thead th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--primary);
}

.items tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.items .num {
  width: 1%;
  white-space: nowrap;
}

.items tbody .num {
  color: var(--muted);
}

.items .right {
  text-align: right;
  white-space: nowrap;
}

.items .amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.items tfoot td {
  padding: 9px 12px;
  text-align: right;
}

.items tfoot .sum-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.items tfoot .sum-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.items tfoot .grand td {
  border-top: 1px solid var(--primary);
  padding-top: 13px;
}

.items tfoot .grand .sum-label {
  color: var(--primary);
  font-size: 12.5px;
}

.items tfoot .grand .sum-value {
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ---------- Totals in words ---------- */

.in-words {
  background: var(--accent-quiet);
  padding: 13px 16px;
  font-size: 13.5px;
  margin-bottom: 24px;
}

.in-words .label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-hover);
  margin-bottom: 4px;
}

.in-words .value {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--primary);
}

/* ---------- Signature ---------- */

.signoff {
  font-size: 13.5px;
  color: var(--primary);
  font-weight: 500;
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.signoff img {
  display: block;
}

.note {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 18px;
}

/* ---------- Act-specific signature grid ---------- */

.sign-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  margin-top: 24px;
}

.sign-box {
  padding: 16px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 13.5px;
}

.sign-box .role {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 26px;
}

.sign-box .line {
  color: var(--primary);
}

/* ---------- Payment / QR ---------- */

.pay {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-top: 26px;
  flex-wrap: wrap;
}

.qr-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--neutral);
  border: 1px solid var(--rule);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color 220ms ease;
}

.qr-card:hover {
  border-color: var(--primary);
}

.qr-card #qrcode img,
.qr-card #qrcode canvas {
  display: block;
}

.qr-hint {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--muted);
}

/* ---------- Actions ---------- */

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--neutral);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--rule);
}

.btn-ghost:hover {
  border-color: var(--primary);
}

/* ---------- Print — fit one A4 page ---------- */

@page {
  size: A4;
  margin: 12mm;
}

@media print {
  body {
    background: #fff;
    padding: 0;
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
  }

  .sheet {
    max-width: none;
    border: 0;
    padding: 0;
  }

  /* tighten the vertical rhythm so everything stays on a single sheet */
  .doc-head {
    padding-bottom: 14px;
    margin-bottom: 16px;
  }

  .doc-meta {
    font-size: 25px;
  }

  .parties {
    margin-bottom: 16px;
  }

  .party {
    padding: 9px 14px;
  }

  .party-label {
    margin-bottom: 5px;
  }

  .items {
    margin-bottom: 14px;
  }

  .items thead th {
    padding-bottom: 8px;
  }

  .items tbody td {
    padding: 9px 12px;
  }

  .items tfoot td {
    padding: 7px 12px;
  }

  .items tfoot .grand td {
    padding-top: 10px;
  }

  .items tfoot .grand .sum-value {
    font-size: 19px;
  }

  .in-words {
    margin-bottom: 16px;
    padding: 10px 14px;
  }

  .signoff {
    gap: 12px;
  }

  .note {
    margin-top: 14px;
  }

  .sign-grid {
    margin-top: 16px;
  }

  .sign-box {
    padding: 12px 14px;
  }

  .sign-box .role {
    margin-bottom: 20px;
  }

  .pay {
    margin-top: 16px;
    gap: 18px;
  }

  .qr-card {
    padding: 10px;
    gap: 8px;
  }

  .qr-card #qrcode img,
  .qr-card #qrcode canvas {
    width: 150px !important;
    height: 150px !important;
  }

  /* keep structural blocks intact across the page edge */
  .parties,
  .items,
  .sign-grid,
  .pay,
  .signoff {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .in-words,
  .items tfoot .grand .sum-value {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print,
  .no-print * {
    display: none !important;
  }
}

@media (max-width: 600px) {
  :root {
    --pad-x: 20px;
    --pad-y: 26px;
  }

  body {
    padding: 20px 12px;
  }

  .parties {
    grid-template-columns: 1fr;
  }

  .doc-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .doc-date {
    text-align: left;
  }

  .doc-meta {
    font-size: 27px;
  }

  .sign-grid {
    grid-template-columns: 1fr;
  }
}
