/* Balenton — the printed document.
 *
 * Built to letter, at the proportions of Noukoua Auto's form, because the customer compares the
 * two. Print rules are first-class here, not an afterthought: this is read on paper far more
 * often than on screen.
 *
 * No brand purple anywhere on this file. Balenton's colours belong on the shop's own screens; the
 * document belongs to the garage, and a customer should see their garage's paperwork, not ours.
 */

.doc {
  --ink: #000;
  --line: #000;
  --soft: #9a9a9a;
  --fieldbg: #f1f1f1;
  width: 8.5in;
  min-height: 11in;
  padding: 0.45in 0.4in 0.3in;
  margin: 0 auto;
  background: #fff;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9pt;
  line-height: 1.25;
  box-sizing: border-box;
}

/* ── masthead ───────────────────────────────────────────────────────────── */
.doc .mast { display: flex; justify-content: space-between; align-items: flex-start; }
.doc .who { display: flex; align-items: flex-start; gap: 12px; }
/* The shop's own mark, if they have given us one. Height-bounded so a large upload cannot push
   the rest of the masthead down the page. */
.doc .logo { max-height: 56px; max-width: 200px; object-fit: contain; }
.doc .mast .nm { font-family: "Times New Roman", Times, serif; font-size: 15pt; font-weight: 700; line-height: 1.15; }
.doc .mast .ad { font-family: "Times New Roman", Times, serif; font-size: 12pt; font-weight: 700; white-space: pre-line; line-height: 1.15; }
.doc .contact { text-align: right; font-size: 9.5pt; }
.doc .contact span { font-weight: 700; margin-right: 18px; }
.doc .contact .em { margin-top: 10px; font-weight: 700; }

.doc .notice { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 6px; gap: 14px; }
.doc .notice .nt { flex: 1; text-align: center; font-size: 8.5pt; line-height: 1.3; }
.doc .notice .regs { font-size: 8.5pt; font-weight: 700; white-space: nowrap; }

/* ── the bordered body ──────────────────────────────────────────────────── */
.doc .frame { border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; overflow: hidden; }

.doc .titlebar { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 8px 12px 0; }
.doc .badgewrap { display: flex; flex-direction: column; align-items: flex-end; }
/* The vehicle render. Height-capped so an unexpected image size cannot shift the form, and muted
   slightly so it reads as identification rather than decoration competing with the invoice number. */
.doc .car { max-height: 62px; max-width: 190px; object-fit: contain; opacity: .92; }
.doc .badge {
  border: 1px solid var(--line); border-radius: 12px; padding: 4px 26px;
  font-size: 13pt; font-weight: 700; font-style: italic;
}
.doc .ref { font-size: 8.5pt; margin: 2px 8px 0 0; }

/* ── parties ────────────────────────────────────────────────────────────── */
.doc .parties {
  display: grid; grid-template-columns: 1.55fr 0.9fr 1.5fr 0.8fr;
  gap: 0 10px; padding: 6px 12px 8px;
}
.doc .f { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.doc .f > span { font-size: 7.5pt; color: #222; min-width: 52px; }
.doc .f .v {
  flex: 1; min-height: 13px; background: var(--fieldbg);
  border-bottom: 1px solid #c9c9c9; padding: 1px 4px; font-size: 9pt;
}
.doc .f .v.b { font-weight: 700; }

.doc .taxbox { font-size: 7.5pt; }
.doc .taxbox .tl { margin-bottom: 3px; }
.doc .rr { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 2px; }
.doc .rr span { white-space: nowrap; }
.doc .rr b { background: var(--fieldbg); border-bottom: 1px solid #c9c9c9; padding: 1px 6px; font-size: 9pt; min-width: 54px; text-align: right; }

.doc .meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; padding: 0 12px 8px; }
.doc .meta .f > span { font-weight: 700; font-size: 8.5pt; }

/* ── line table ─────────────────────────────────────────────────────────── */
.doc table.lines { width: 100%; border-collapse: collapse; border-top: 1px solid var(--line); }
.doc table.lines th {
  font-size: 7.5pt; font-weight: 400; padding: 3px 4px;
  border-right: 1px solid #d0d0d0; border-bottom: 1px solid var(--line);
}
.doc table.lines td {
  font-size: 9pt; font-weight: 700; padding: 4px;
  border-right: 1px solid #d0d0d0; border-bottom: 1px solid #e6e6e6;
}
.doc table.lines tr.pad td { height: 19px; border-bottom: 0; }
.doc table.lines th:last-child, .doc table.lines td:last-child { border-right: 0; }
.doc table.lines .c { text-align: center; width: 20px; }
.doc table.lines .code { width: 46px; font-size: 7.5pt; font-weight: 400; }
.doc table.lines .item { width: 80px; }
.doc table.lines .desc { text-align: left; }
.doc table.lines .n { text-align: right; white-space: nowrap; }
.doc table.lines th.n { text-align: center; }
.doc table.lines .t { font-size: 7.5pt; font-weight: 400; width: 16px; }
.doc .tk { font-size: 10pt; }
.doc .tk.off { color: var(--soft); }

/* ── foot ───────────────────────────────────────────────────────────────── */
.doc .foot { display: grid; grid-template-columns: 1fr 300px; gap: 10px; border-top: 1px solid var(--line); padding: 6px 12px 8px; align-items: start; }
.doc .legal { font-size: 7pt; line-height: 1.3; }
.doc .lg { margin-bottom: 4px; }
.doc .lg b { font-size: 7.5pt; }
.doc .lg.sm { color: #333; }

.doc .sigs { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 6px; }
.doc .sig { border: 1px solid #b5b5b5; border-radius: 8px; padding: 5px 7px 2px; }
.doc .st { font-size: 6.5pt; text-align: center; line-height: 1.3; min-height: 34px; }
.doc .sl { font-size: 7pt; margin-top: 6px; border-top: 1px solid #000; padding-top: 1px; }

.doc table.totals { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.doc table.totals td { padding: 3px 6px; border: 1px solid #c9c9c9; }
.doc table.totals td:first-child { border: 0; font-weight: 700; text-align: left; white-space: nowrap; }
.doc table.totals td.n { text-align: right; font-weight: 700; min-width: 86px; }
.doc table.totals tr.grand td { font-size: 11pt; }

.doc .validity { font-size: 8pt; text-align: right; margin-top: 6px; }

.doc .balance { display: flex; align-items: center; gap: 10px; padding: 4px 12px 10px; }
.doc .balance span { font-size: 9pt; }
.doc .balance b { background: var(--fieldbg); border: 1px solid #c9c9c9; padding: 3px 26px; font-size: 11pt; }

.doc .print-foot { display: flex; justify-content: space-between; font-size: 7.5pt; margin-top: 6px; }

/* ── print ──────────────────────────────────────────────────────────────── */
@page { size: letter; margin: 0; }
@media print {
  html, body { background: #fff; margin: 0; padding: 0; }
  body * { visibility: hidden; }
  .doc, .doc * { visibility: visible; }
  .doc { position: absolute; inset: 0; margin: 0; box-shadow: none; page-break-after: always; }
  /* A field that is grey on screen should be white on paper — their form prints on plain stock. */
  .doc .f .v, .doc .rr b, .doc .balance b { background: #fff; }
  .no-print { display: none !important; }
}

/* ── the bon de travail ──────────────────────────────────────────────────── */
/* Same letterhead, same paper, different questions. Roomier than the facture on purpose: this
   sheet is written on by hand in a bay, so the complaint and diagnosis boxes have to take a pen. */
.doc.wo .wotitle { font-weight: 800; letter-spacing: .06em; font-size: 11pt; }

.doc.wo .grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; margin-bottom: 8px;
}

.doc.wo .says { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 10px; }
.doc.wo .says .sb { border: 1px solid #000; min-height: 58px; }
.doc.wo .says .sl {
  font-size: 7.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid #000; padding: 2px 5px; background: #eee;
}
.doc.wo .says .sv { padding: 4px 5px; font-size: 9.5pt; line-height: 1.35; white-space: pre-line; }

.doc.wo table.lines { width: 100%; border-collapse: collapse; }
.doc.wo table.lines th {
  font-size: 7.5pt; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid #000; background: #eee; padding: 3px 5px; text-align: left;
}
.doc.wo table.lines td { border: 1px solid #000; padding: 3px 5px; font-size: 9.5pt; }
.doc.wo table.lines td.n { text-align: right; }
.doc.wo table.lines td.c, .doc.wo table.lines th.c { text-align: center; }
/* The tick column is filled in by hand as each job is finished. */
.doc.wo table.lines td.t { width: 26px; }
.doc.wo table.lines tr.pad td { height: 17px; }

.doc.wo .foot { margin-top: 10px; }
