/* The client-facing sheet. Follows the house estimate layout.
   On screen it renders as a page preview; on print it becomes the PDF. */

#printHost { display: none; }
body.printing #printHost { display: block; background: #6b7280; padding: 24px 16px 60px; }

.sheet {
  width: 8.5in;
  min-height: 11in;
  margin: 0 auto;
  padding: 0.42in 0.667in 0.46in;   /* 48pt side margins, as the original */
  background: #fff;
  color: #171717;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.42;
  box-shadow: 0 6px 26px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

/* ---------- masthead ---------- */

/* Full-bleed orange band across the head of the page, 12pt tall,
   exactly as the original estimate. */
.sh-band {
  position: absolute; top: 0; left: 0; right: 0;
  height: 12pt; background: #ff914d;
}

.sh-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 30px;
  padding: 14pt 0 14px; border-bottom: 1px solid #d9d9d9;
}
.sh-brand { display: flex; align-items: flex-start; gap: 13px; }
.sh-logo { height: 100pt; width: auto; max-width: 120pt; object-fit: contain; }
.sh-co { font-size: 13pt; font-weight: 700; letter-spacing: -0.01em; }
.sh-tag { font-size: 9pt; color: #5e6368; letter-spacing: 0.02em; }
.sh-brand-text { padding-top: 3pt; }

.sh-title { text-align: right; }
.sh-title h1 {
  margin: 0 0 5px; font-size: 24pt; font-weight: 700;
  letter-spacing: 0.02em; line-height: 1; color: #171717;
}
.sh-meta { font-size: 9.5pt; color: #5e6368; }
.sh-meta div { white-space: nowrap; }

/* ---------- parties ---------- */

.sh-parties {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
  padding: 18px 0; border-bottom: 1px solid #d9d9d9;
}
.sh-block-label {
  font-size: 7.5pt; font-weight: 700; letter-spacing: 0.11em;
  text-transform: uppercase; color: #5e6368; margin-bottom: 5px;
}
.sh-block-body { font-size: 9.5pt; line-height: 1.45; }
.sh-block-body .strong { font-weight: 700; font-size: 10.5pt; }

.sh-po { font-size: 9.5pt; padding-top: 10px; color: #4a5160; }

/* ---------- line table ---------- */

.sh-lines { width: 100%; border-collapse: collapse; margin-top: 20px; }
.sh-lines th {
  font-size: 7.5pt; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase;
  color: #5e6368; text-align: left; padding: 0 0 7px; border-bottom: 1px solid #171717;
}
.sh-lines td { padding: 7px 0; border-bottom: 1px solid #ececec; vertical-align: top; }
.sh-lines .sh-qty { width: 60px; text-align: center; }
.sh-lines .sh-amt { width: 110px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-lines th.sh-qty { text-align: center; }
.sh-lines th.sh-amt { text-align: right; }
.sh-exempt { color: #5e6368; font-size: 8.5pt; }

/* ---------- money stack ---------- */

.sh-totals { margin: 14px 0 0 auto; width: 58%; }
.sh-row {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 5px 0; font-size: 10pt; border-bottom: 1px solid #f1f1f1;
}
.sh-row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-grand {
  border-top: 2px solid #ff914d; border-bottom: none;
  margin-top: 5px; padding-top: 9px;
  font-size: 12.5pt; font-weight: 700; letter-spacing: 0.03em;
}

/* ---------- notes ---------- */

.sh-note { margin-top: 20px; font-size: 8.5pt; color: #5e6368; line-height: 1.5; }
.sh-note-label {
  font-size: 7.5pt; font-weight: 700; letter-spacing: 0.11em;
  text-transform: uppercase; color: #5e6368; margin-bottom: 3px;
}
.sh-note div:last-child { white-space: pre-wrap; }

/* ---------- footer ---------- */

.sh-foot {
  margin-top: auto; padding-top: 10px;
  border-top: 2px solid #ff914d;
  display: flex; justify-content: space-between; align-items: baseline; gap: 20px;
}
.sh-foot-name { font-size: 8.5pt; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #171717; }
.sh-foot-tag { font-size: 8.5pt; color: #5e6368; }

/* ---------- on a small screen, before printing ---------- */

@media (max-width: 900px) {
  body.printing .sheet {
    width: auto; max-width: 8.5in; min-height: 0;
    padding: 0.42in 16px 0.4in;
  }
  #printBar { flex-wrap: wrap; gap: 8px; }
  #printBar .print-hint { order: 3; width: 100%; font-size: 11.5px; }
}

/* M4 + S12: the client approval page on a phone. The masthead, the three
   party blocks and the money stack all assumed a letter-width page. */
@media (max-width: 720px) {
  .sh-head { flex-wrap: wrap; gap: 12px; }
  .sh-title { text-align: left; width: 100%; }
  .sh-parties { grid-template-columns: 1fr; gap: 14px; }
  .sh-totals { width: 100%; }
  .sh-logo { height: 72pt; }
}
.sh-block-body div { white-space: pre-line; }

/* ---------- actual printing ---------- */

@page { size: letter portrait; margin: 0.4in; }

@media print {
  body { background: #fff; }
  body.printing #topbar,
  body.printing #main,
  body.printing #foot,
  #printBar { display: none !important; }
  body.printing #printHost { display: block; background: #fff; padding: 0; }

  .sheet {
    width: auto; min-height: 0; margin: 0; padding: 12pt 0 0;
    box-shadow: none; font-size: 10pt;
  }
  /* The band has to reach the paper edge, so pull it out past the @page margin. */
  .sh-band { top: -0.4in; left: -0.4in; right: -0.4in; height: 12pt; }

  /* Keep a line item from splitting across a page break. */
  .sh-lines tr, .sh-row, .sh-note { break-inside: avoid; page-break-inside: avoid; }
  .sh-lines thead { display: table-header-group; }
  .sh-totals, .sh-foot { break-inside: avoid; page-break-inside: avoid; }

  /* Force the background tones the layout depends on. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
