:root {
  --green-950: #8f3f22;
  --green-900: #a94f2b;
  --green-700: #b85c32;
  --green-100: #f8dfcf;
  --ink: #2d211b;
  --muted: #7a6254;
  --line: #e8cdbd;
  --page: #f8e3d5;
  --white: #fff9f5;
  --shadow: 0 6px 18px rgba(112, 67, 43, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

.report-shell {
  width: min(1440px, calc(100% - 64px));
  margin: 32px auto;
  overflow: hidden;
  background: var(--page);
  border: 1px solid #e8cdbd;
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(112, 67, 43, 0.09);
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 148px;
  padding: 30px 42px;
  color: var(--ink);
  background: linear-gradient(120deg, #f5d6c3, #fbe9dd);
  border-bottom: 4px solid #c8734d;
}

.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo {
  display: block;
  width: 159px;
  height: 78px;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: multiply;
}

.company-name { margin: 0 0 7px; color: var(--green-900); font-size: 13px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.report-header h1 { margin: 0; font-size: 25px; font-weight: 500; letter-spacing: .03em; text-transform: uppercase; }
.header-label { padding: 9px 14px; border: 1px solid #cf9274; border-radius: 999px; color: var(--green-950); background: rgba(255,249,245,.45); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.report-body { padding: 30px 34px 24px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.property-card { padding: 23px 26px 26px; }
.section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 21px; }
.section-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; color: var(--green-900); background: var(--green-100); font-size: 11px; font-weight: 700; }
.section-heading h2, .image-card h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.property-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span, .metric-content > label, .metric-label { color: #6f5649; font-size: 12px; font-weight: 600; }
input { color: var(--ink); }
.field input { width: 100%; height: 46px; padding: 0 14px; background: #fffdfb; border: 1px solid #e4c7b7; border-radius: 6px; outline: none; transition: border .2s, box-shadow .2s; }
input:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(184,92,50,.12); }
input::placeholder { color: #aa9183; }
.image-section, .summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
.image-card { display: flex; min-width: 0; overflow: hidden; flex-direction: column; break-inside: avoid; page-break-inside: avoid; }
.image-card-heading { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 17px 20px; border-bottom: 1px solid var(--line); background: var(--white); }
.eyebrow { display: block; margin-bottom: 6px; color: var(--green-700); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-button { cursor: pointer; padding: 9px 13px; border: 1px solid #d7aa91; border-radius: 6px; color: var(--green-900); background: #fff5ef; font-size: 11px; font-weight: 700; transition: background .2s, border .2s; }
.upload-button:hover { background: var(--green-100); border-color: #c77d58; }
.upload-button:focus-within { outline: 3px solid rgba(184,92,50,.15); }
.image-frame { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: clamp(330px, 32vw, 475px); min-width: 0; padding: 12px; overflow: hidden; background-color: #fdf0e7; background-image: linear-gradient(45deg, rgba(184,92,50,.025) 25%, transparent 25%), linear-gradient(-45deg, rgba(184,92,50,.025) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(184,92,50,.025) 75%), linear-gradient(-45deg, transparent 75%, rgba(184,92,50,.025) 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.image-frame img { display: none; flex: 0 1 auto; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center center; }
.image-frame.has-image img { display: block; }
.image-frame.has-image .image-placeholder { display: none; }
.image-frame.is-dragover::after {
  position: absolute;
  z-index: 2;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  content: "Drop image here";
  color: var(--green-950);
  background: rgba(253, 240, 231, .92);
  border: 2px dashed #c8734d;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  pointer-events: none;
}
.image-placeholder { display: flex; flex-direction: column; align-items: center; text-align: center; color: #92796b; }
.image-placeholder svg { width: 42px; height: 42px; margin-bottom: 12px; fill: #c9a28d; }
.image-placeholder strong { margin-bottom: 5px; color: #755e52; font-size: 13px; }
.image-placeholder span { font-size: 11px; }
.summary-grid { margin-top: 22px; }
.metric-card { display: flex; align-items: center; gap: 22px; min-height: 155px; padding: 28px; }
.metric-icon { display: grid; flex: 0 0 auto; place-items: center; width: 50px; height: 50px; border-radius: 9px; background: var(--green-100); }
.metric-icon svg { width: 25px; height: 25px; fill: var(--green-700); }
.metric-content { flex: 1; min-width: 0; }
.metric-content > label, .metric-label { display: block; margin: 9px 0 8px; }
.value-input { display: flex; align-items: baseline; gap: 8px; }
.value-input input { width: 180px; padding: 0; border: 0; border-bottom: 1px solid #d9b9a8; outline: 0; box-shadow: none; background: transparent; font-size: 34px; font-weight: 700; }
.value-input span { color: var(--muted); font-size: 17px; font-weight: 500; }
.area-explanation { max-width: 430px; margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.price-card { align-items: flex-start; }
.roofing-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.roofing-price-option { min-width: 0; padding: 12px 14px; border: 1px solid #e8cdbd; border-radius: 7px; background: #fdf0e7; }
.price-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.price-title strong { color: var(--green-900); font-size: 14px; font-weight: 700; }
.price-title span { color: var(--muted); font-size: 9px; }
.price-range { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 6px; }
.price-range label { display: flex; align-items: baseline; border-bottom: 1px solid #d9b9a8; }
.price-range label > span { color: var(--green-700); font-size: 21px; font-weight: 700; }
.price-range input { width: 100%; min-width: 0; padding: 0 2px 2px; border: 0; outline: 0; box-shadow: none; background: transparent; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.range-dash { color: #947465; font-size: 20px; }
.proposal-selection { display: flex; align-items: center; gap: 12px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); color: #6f5649; font-size: 9px; font-weight: 600; }
.proposal-selection > span { margin-right: auto; color: var(--green-900); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.proposal-selection label { display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.proposal-selection input { width: 14px; height: 14px; margin: 0; accent-color: var(--green-700); }
.proposal-page.is-excluded, .roofing-price-option.is-excluded { display: none; }
input[type="number"]::-webkit-inner-spin-button { appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
.report-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding: 20px 2px 0; border-top: 1px solid #e3c5b5; }
.report-footer p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.report-footer strong { color: var(--green-900); }
.actions { display: flex; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 17px; cursor: pointer; border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 700; transition: transform .15s, background .2s; }
.button:active { transform: translateY(1px); }
.button svg { width: 17px; height: 17px; fill: currentColor; }
.button-primary { color: white; background: var(--green-900); }
.button-primary:hover { background: var(--green-950); }
.button-secondary { color: #71594c; border-color: #dbb9a6; background: #fff9f5; }
.button-secondary:hover { background: #fdf0e7; }

.detail-page-body { padding: 30px 34px 24px; }
.detail-page .report-header { border-bottom-color: #c8734d; }
.detail-address-card { padding: 18px 22px; }
.detail-label { display: block; margin-bottom: 6px; color: var(--green-700); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.synced-address { margin: 0; color: var(--ink); font-size: 18px; font-weight: 600; }
.detail-middle { display: grid; grid-template-columns: minmax(0, 48fr) minmax(0, 52fr); align-items: stretch; gap: 20px; margin-top: 20px; }
.detail-image-card { min-width: 0; margin: 0; overflow: hidden; }
.detail-section-heading { padding: 15px 20px; border-bottom: 1px solid var(--line); }
.detail-section-heading h2, .detail-price-card h2 { margin: 0; color: var(--ink); font-size: 17px; text-transform: uppercase; }
.detail-image-frame { display: flex; align-items: center; justify-content: center; width: 100%; height: 260px; padding: 12px; overflow: hidden; background: #fdf0e7; }
.detail-image-frame img { display: none; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.detail-image-frame.has-image img { display: block; }
.detail-image-frame.has-image .detail-image-placeholder { display: none; }
.detail-image-placeholder { color: var(--muted); font-size: 12px; }
.detail-price-card { display: flex; align-items: flex-start; justify-content: center; min-width: 0; gap: 14px; margin: 0; padding: 28px 30px; border-left: 5px solid var(--green-700); flex-direction: column; }
.detail-price-card h2 { font-size: 22px; }
.detail-price { display: flex; align-items: baseline; gap: 6px; margin: 0; color: var(--green-950); white-space: nowrap; font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-price strong { font-size: 42px; font-weight: 700; }
.detail-price-dash { margin: 0 5px; color: #a76748; }
.price-support { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 2px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fdf0e7; }
.price-support strong { color: var(--green-900); font-size: 11px; }
.price-support span { font-size: 10px; }
.scope-card { margin-top: 20px; padding-bottom: 30px; }
.scope-heading { margin-bottom: 4px; }
.scope-heading h2 { font-size: 24px; font-weight: 700; }
.scope-list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 10px 28px 0; padding: 0; list-style: none; }
.scope-list li { position: relative; padding: 17px 12px 17px 38px; border-bottom: 1px solid var(--line); color: #4e3c32; font-size: 23.5px; font-weight: 600; line-height: 1.45; }
.scope-list li:last-child { border-bottom: 0; }
.scope-list li::before { position: absolute; top: 16px; left: 2px; content: "✓"; color: var(--green-700); font-size: 24.5px; font-weight: 700; line-height: 1.3; }
.scope-emphasis, .labour-warranty { color: var(--green-950); }
.labour-warranty { margin: 24px 28px 0; padding-top: 17px; border-top: 1px solid var(--line); font-size: 22px; font-weight: 700; }
.detail-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding: 16px 2px 0; border-top: 1px solid #e3c5b5; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.detail-footer p { margin: 0; }
.detail-footer strong { color: var(--green-900); }

@media (max-width: 900px) {
  .report-shell { width: min(100% - 24px, 760px); margin: 12px auto; }
  .report-header { padding: 24px; }
  .report-body { padding: 22px; }
  .image-section, .summary-grid { grid-template-columns: 1fr; }
  .image-frame { height: 400px; }
  .roofing-prices { grid-template-columns: 1fr 1fr; }
  .detail-page-body { padding: 22px; }
  .detail-image-frame { height: 240px; }
}

@media (max-width: 600px) {
  .report-shell { width: 100%; margin: 0; border: 0; border-radius: 0; }
  .report-header { min-height: 110px; padding: 22px 18px; }
  .brand-logo { width: 98px; height: 48px; }
  .company-name { font-size: 10px; }
  .report-header h1 { font-size: 18px; }
  .header-label { display: none; }
  .report-body { padding: 16px; }
  .property-card { padding: 19px 17px; }
  .property-grid { grid-template-columns: 1fr; }
  .image-frame { height: 300px; }
  .metric-card { padding: 20px 17px; }
  .metric-icon { display: none; }
  .price-range input { font-size: 19px; }
  .roofing-prices { grid-template-columns: 1fr; }
  .proposal-selection { align-items: flex-start; flex-direction: column; }
  .proposal-selection > span { margin-right: 0; }
  .report-footer { align-items: stretch; flex-direction: column; gap: 18px; }
  .actions { flex-direction: column-reverse; }
  .detail-page-body { padding: 16px; }
  .detail-image-frame { height: 220px; }
  .detail-middle { grid-template-columns: 1fr; }
  .detail-price-card { align-items: flex-start; flex-direction: column; gap: 10px; }
  .detail-price { font-size: 25px; }
  .detail-price strong { font-size: 32px; }
  .scope-list { margin-inline: 17px; }
}

@page { size: landscape; margin: 8mm; }

@media print {
  * {
    box-sizing: border-box;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html, body {
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: var(--page);
  }

  .report-shell {
    width: 100%;
    height: auto;
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .report-header {
    min-height: 0;
    height: 94px;
    padding: 8px 21px;
    border-bottom-width: 2px;
  }

  .brand { gap: 13px; }
  .brand-logo { width: 154px; height: 76px; object-fit: contain; object-position: center; }
  .company-name { margin: 0 0 4px; font-size: 10.5px; }
  .report-header h1 { font-size: 26px; font-weight: 600; }
  .header-label { display: none; }

  .report-body {
    display: block;
    padding: 8px 12px 0;
  }

  .card { border-radius: 5px; box-shadow: none; }

  .property-card {
    min-height: 0;
    padding: 5px 10px 6px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .property-card .section-heading { display: none; }
  .property-grid { grid-template-columns: 2fr 1fr; gap: 12px; }
  .field { gap: 1px; }
  .field > span { color: #6f5649; font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; }
  .field input {
    height: 28px;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: 13px;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
  }
  input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

  .image-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    margin: 8px 0 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .image-card {
    min-width: 0;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .image-card-heading {
    min-height: 0;
    height: 38px;
    padding: 5px 9px;
  }
  .image-card h2 { font-size: 11px; }
  .eyebrow { margin-bottom: 1px; font-size: 7px; }
  .upload-button, .file-input, .actions, .internal-controls, .image-frame.is-dragover::after { display: none !important; }

  .image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 385px;
    min-height: 0;
    max-height: 385px;
    padding: 0;
    overflow: hidden;
  }

  .image-frame img,
  .image-frame.has-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    object-fit: contain !important;
    object-position: center center !important;
  }
  .image-frame:not(.has-image) img { display: none; }
  .image-placeholder svg { width: 22px; height: 22px; margin-bottom: 3px; }
  .image-placeholder strong { margin-bottom: 2px; font-size: 7px; }
  .image-placeholder span { font-size: 6px; }

  .summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    margin: 8px 0 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .metric-card {
    align-items: center;
    min-width: 0;
    min-height: 0;
    height: 128px;
    padding: 12px 16px;
    gap: 13px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .metric-icon { width: 42px; height: 42px; }
  .metric-icon svg { width: 22px; height: 22px; }
  .metric-content > label, .metric-label { margin: 4px 0 2px; font-size: 10px; }
  .value-input input {
    width: 190px;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 38px;
    font-weight: 700;
    appearance: none;
    -webkit-appearance: none;
  }
  .value-input span { font-size: 15px; }
  .area-explanation { max-width: none; margin: 5px 0 0; font-size: 8px; line-height: 1.3; }

  .price-card { align-items: center; }
  .price-card .metric-icon { display: none; }
  .roofing-prices { grid-template-columns: 1fr; gap: 6px; margin-top: 5px; }
  .roofing-price-option {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 39px;
    padding: 6px 10px;
    border-radius: 4px;
  }
  .price-title { display: block; margin: 0; }
  .price-title strong { display: block; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
  .price-title span { display: block; margin-top: 1px; font-size: 7px; font-weight: 500; }
  .price-range { gap: 6px; }
  .price-range label { border: 0; }
  .price-range input {
    padding: 0 2px;
    color: var(--ink);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    appearance: none;
    -webkit-appearance: none;
  }
  .price-range label > span { font-size: 18px; font-weight: 700; }
  .range-dash { font-size: 17px; }

  .report-footer { display: none; }

  .proposal-page {
    width: 100%;
    height: 194mm;
    max-height: 194mm;
    overflow: hidden;
    box-sizing: border-box;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .page-one,
  .metal-detail-page {
    break-after: page;
    page-break-after: always;
  }
  .shingle-detail-page {
    break-after: auto;
    page-break-after: auto;
  }
  .proposal-page.is-excluded { display: none !important; }
  .proposal-page.is-last-included {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  .detail-page {
    display: flex;
    flex-direction: column;
  }
  .detail-page-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    padding: 7px 12px 0;
    flex-direction: column;
  }
  .detail-address-card {
    min-height: 0;
    padding: 6px 10px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .detail-label { margin-bottom: 2px; font-size: 7px; }
  .synced-address { font-size: 13px; }

  .detail-middle {
    display: grid;
    grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
    align-items: stretch;
    gap: 10px;
    margin-top: 5px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .detail-image-card {
    margin: 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .detail-section-heading { padding: 5px 9px; }
  .detail-section-heading h2, .detail-price-card h2 { font-size: 11px; }
  .detail-image-frame {
    width: 100%;
    height: 155px;
    padding: 0;
    overflow: hidden;
  }
  .detail-image-frame img,
  .detail-image-frame.has-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain !important;
    object-position: center !important;
  }
  .detail-image-frame:not(.has-image) img { display: none; }
  .detail-image-placeholder { font-size: 7px; }

  .detail-price-card {
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 14px 18px;
    border-left-width: 4px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .detail-price-card h2 { font-size: 16px; }
  .detail-price { gap: 4px; font-size: 24px; font-weight: 700; }
  .detail-price strong { font-size: 34px; }
  .detail-price-dash { margin: 0 5px; }
  .price-support { margin-top: 0; padding: 7px 9px; border-radius: 4px; }
  .price-support strong { font-size: 8px; }
  .price-support span { font-size: 7px; }

  .scope-card {
    min-height: 0;
    margin-top: 5px;
    padding-bottom: 6px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .scope-heading { margin-bottom: 0; padding: 5px 12px; }
  .scope-heading h2 { font-size: 17px; font-weight: 700; }
  .scope-list {
    grid-template-columns: 1fr;
    gap: 0;
    margin: 5px 16px 0;
  }
  .scope-list li { padding: 5px 8px 5px 26px; font-size: 16.25px; font-weight: 600; line-height: 1.4; }
  .scope-list li::before { top: 5px; left: 2px; font-size: 19px; line-height: 1.3; }
  .labour-warranty { margin: 12px 16px 0; padding-top: 9px; font-size: 16px; }

  .detail-footer {
    flex: 0 0 auto;
    min-height: 22px;
    margin-top: auto;
    padding: 4px 2px 0;
    font-size: 7px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
