:root {
        --bg: #e9e7e2;
        --paper: #ffffff;
        --ink: #1c1c1e;
        --strong: #111111;
        --soft: #4a4a4a;
        --muted: #666666;
        --faint: #8a8a8a;
        --line: #e7e4df;
        --line-2: #e4e1dc;
        --panel: #f7f6f4;
        --red: #e01a22;
        --gold: #b8912a;
        --green: #1d8a4e;
        --green-soft: #f0f7f2;
        --red-soft: #fdf3f3;
        --input-line: #c9c6bf;
        --shadow: 0 10px 34px rgba(20, 18, 14, 0.14), 0 2px 6px rgba(20, 18, 14, 0.07);
      }
      @media (prefers-color-scheme: dark) {
        :root {
          --bg: #16151a;
          --shadow: 0 10px 34px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
        }
      }
      * { box-sizing: border-box; }
      html { scroll-behavior: smooth; }
      @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
      body {
        margin: 0;
        background: var(--bg);
        color: var(--ink);
        font-family: "Liberation Sans", Arial, Helvetica, sans-serif;
        font-size: 14px;
        line-height: 1.45;
        -webkit-font-smoothing: antialiased;
      }
      .doc {
        max-width: 820px;
        margin: 20px auto 48px;
        background: var(--paper);
        box-shadow: var(--shadow);
        padding: 28px 36px 22px;
      }
      @media (max-width: 640px) { .doc { margin: 0 auto 40px; padding: 20px 16px 18px; } }

      /* read-only-preview notice: part of the static markup, hidden by the script the moment the live page runs.
         In a mail/messages attachment preview scripts never run, so the recipient sees this instead of working
         buttons — it must be big, red, and give the exact escape steps for the phone in their hand. */
      .js-note { border: 2px solid var(--red); background: var(--red-soft); color: var(--ink); font-size: 13.5px; line-height: 1.55; padding: 13px 15px; margin-bottom: 16px; }
      .js-note .jn-head { display: block; font-size: 15.5px; font-weight: 700; color: var(--red); margin-bottom: 4px; }
      .js-note ol { margin: 6px 0 8px 19px; padding: 0; }
      .js-note li { margin: 3px 0; }
      .js-note a { color: var(--strong); font-weight: 700; }
      .js-note.compact { font-size: 13px; padding: 10px 13px; margin: 0 0 14px; }

      /* send bar — Erik's route to the client that does not depend on the app's share button;
         stripped out of the exported copy, so clients never see it */
      .send-bar { border: 1.5px solid var(--red); background: var(--red-soft); padding: 13px 15px; margin-bottom: 16px; }
      .send-bar .sb-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
      .send-bar .sb-txt { flex: 1; min-width: 220px; }
      .send-bar .sb-txt b { color: var(--strong); font-size: 14.5px; display: block; margin-bottom: 2px; }
      .send-bar .sb-txt span { font-size: 12.5px; color: var(--soft); }
      .send-copy-btn {
        background: var(--red); color: #fff; border: none; border-radius: 2px; font: inherit;
        font-size: 14px; font-weight: 700; padding: 11px 18px; cursor: pointer; min-height: 46px; flex: none;
      }
      .send-copy-btn:hover { filter: brightness(1.07); }
      .send-copy-btn:disabled { opacity: 0.65; cursor: wait; }
      .send-copy-status { font-size: 13px; font-weight: 700; color: var(--green); margin-top: 9px; }
      .send-copy-status:empty { display: none; }

      /* ---------- header (matches the printed estimate) ---------- */
      .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
      .head img.logo { width: 218px; max-width: 64vw; height: auto; display: block; }
      .doc-meta { text-align: right; }
      .doc-meta .t { font-size: 23px; font-weight: 700; letter-spacing: 5px; color: var(--strong); line-height: 1; }
      .doc-meta .meta { font-size: 12px; color: #555; margin-top: 6px; line-height: 1.5; }
      .doc-meta .meta b { color: var(--strong); }
      .sample-chip {
        display: inline-block; margin-top: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 2px;
        color: var(--gold); border: 1px solid var(--gold); padding: 3px 8px; border-radius: 2px; text-transform: uppercase;
      }
      .rule { border: none; border-top: 3px solid var(--strong); margin: 12px 0 2px; }
      .rule2 { border: none; border-top: 1px solid var(--red); margin: 0 0 14px; }

      /* party cards */
      .cards { display: flex; gap: 14px; margin-bottom: 12px; }
      .card { flex: 1; min-width: 0; background: var(--panel); border-top: 3px solid var(--strong); padding: 9px 11px 10px; }
      .card.red-top { border-top-color: var(--red); }
      .card .k { font-size: 10.5px; letter-spacing: 2px; color: var(--red); font-weight: 700; margin-bottom: 4px; text-transform: uppercase; }
      .card .n { font-size: 15.5px; font-weight: 700; color: var(--strong); line-height: 1.25; }
      .card .d { font-size: 12.5px; color: #444; line-height: 1.45; margin-top: 2px; }
      @media (max-width: 640px) { .cards { flex-direction: column; } }

      /* trust strip */
      .trust { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line-2); padding: 8px 12px; }
      .trust img { height: 38px; width: auto; display: block; }
      .trust .tx { font-size: 12.5px; color: #333; }
      .trust .tx b { color: var(--strong); }
      @media (max-width: 480px) { .trust img { height: 36px; } }

      /* ---------- sections ---------- */
      section { margin-top: 22px; }
      h2.sec { font-size: 16px; margin: 0 0 4px; color: var(--strong); letter-spacing: 0.4px; font-weight: 700; text-transform: uppercase; }
      h2.sec .no { color: var(--red); margin-right: 7px; }
      .sub { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; max-width: 72ch; }

      /* scope table */
      table.scope { width: 100%; border-collapse: collapse; }
      table.scope tr { border-bottom: 1px solid var(--line); }
      table.scope td { padding: 7px 4px; vertical-align: top; }
      td.it .nm { font-weight: 700; font-size: 14.5px; color: var(--strong); }
      td.it .ds { font-size: 12.5px; color: var(--soft); margin-top: 1px; max-width: 58ch; }
      td.pr { text-align: right; font-weight: 700; font-size: 14.5px; color: var(--strong); white-space: nowrap; font-variant-numeric: tabular-nums; }

      .totals { margin-top: 10px; margin-left: auto; width: 320px; max-width: 100%; }
      .totals .row { display: flex; justify-content: space-between; font-size: 13.5px; color: #444; padding: 2px 0; font-variant-numeric: tabular-nums; }
      .totals .row span:last-child { color: var(--strong); }
      .totals .grand { background: var(--strong); color: #fff; padding: 8px 12px; margin-top: 6px; display: flex; justify-content: space-between; align-items: center; }
      .totals .grand .l { font-size: 11px; letter-spacing: 3px; }
      .totals .grand .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
      .totals .split { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
      .totals .split .row { font-size: 12.5px; }
      .totals .split .row span:last-child { font-weight: 700; }
      .trim-note { font-size: 11.5px; color: #777; margin-top: 6px; text-align: right; }

      /* included / not included */
      .cols { display: flex; gap: 28px; }
      .col { flex: 1; min-width: 0; }
      .col .ch { font-size: 11.5px; letter-spacing: 2px; font-weight: 700; margin-bottom: 6px; text-transform: uppercase; }
      .col.inc .ch { color: var(--green); }
      .col.exc .ch { color: #999; }
      .col ul { list-style: none; margin: 0; padding: 0; font-size: 13px; color: #333; }
      .col li { padding: 3px 0 3px 18px; position: relative; }
      .col.inc li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }
      .col.exc li { color: #777; }
      .col.exc li::before { content: "—"; position: absolute; left: 0; color: #b0aca4; }
      @media (max-width: 640px) { .cols { flex-direction: column; gap: 16px; } }

      /* photo areas */
      .photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
      @media (max-width: 560px) { .photo-grid { grid-template-columns: 1fr; } }
      .photo-slot { border: 1.5px dashed #cfccc4; background: var(--panel); overflow: hidden; }
      .photo-slot.filled { border: 1px solid var(--line-2); background: var(--paper); }
      .slot-drop {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
        min-height: 116px; padding: 14px 10px; text-align: center; cursor: pointer; color: var(--muted);
        background: none; border: none; width: 100%; font: inherit;
      }
      .slot-drop:hover { color: var(--red); }
      .slot-drop svg { width: 24px; height: 24px; stroke: currentColor; }
      .slot-drop .sd-label { font-weight: 700; color: var(--strong); font-size: 13.5px; }
      .slot-drop .sd-hint { font-size: 11.5px; }
      .slot-imgwrap { position: relative; }
      .slot-imgwrap img { display: block; width: 100%; height: 150px; object-fit: cover; }
      .slot-remove {
        position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 999px;
        border: none; background: rgba(10, 14, 20, 0.72); color: #fff; font-size: 17px; line-height: 1; cursor: pointer;
      }
      .slot-cap { padding: 8px 10px 10px; }
      .slot-cap .cap-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 5px; }
      .slot-cap input {
        width: 100%; border: 1px solid var(--input-line); border-radius: 2px; background: var(--paper);
        color: var(--ink); font: inherit; font-size: 13px; padding: 7px 9px;
      }
      .add-photo {
        margin-top: 12px; background: var(--paper); border: 1.5px solid var(--strong); color: var(--strong);
        border-radius: 2px; padding: 8px 15px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 38px;
      }
      .add-photo:hover { background: var(--strong); color: #fff; }

      /* steps */
      .steps { display: flex; gap: 10px; }
      .step { flex: 1; min-width: 0; background: var(--panel); padding: 8px 10px 10px; }
      .step .n { font-size: 19px; font-weight: 700; color: var(--red); line-height: 1; }
      .step .h { font-weight: 700; font-size: 13.5px; color: var(--strong); margin: 4px 0 2px; }
      .step .p { font-size: 12px; color: #555; line-height: 1.45; margin: 0; }
      @media (max-width: 640px) { .steps { flex-wrap: wrap; } .step { flex: 1 1 42%; } }
      @media (max-width: 430px) { .step { flex: 1 1 100%; } }

      /* options */
      .opt-card { border: 1px solid var(--line-2); border-left: 3px solid var(--gold); padding: 10px 12px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 16px; background: var(--paper); }
      .opt-card.added { border-color: var(--green); border-left-color: var(--green); background: var(--green-soft); }
      .opt-main { min-width: 0; }
      .opt-name { font-weight: 700; color: var(--strong); font-size: 14.5px; }
      .opt-desc { font-size: 12.5px; color: var(--soft); margin: 3px 0 0; max-width: 58ch; }
      .opt-side { text-align: right; white-space: nowrap; flex: none; }
      .opt-side .k { font-size: 10.5px; letter-spacing: 1.5px; color: var(--gold); font-weight: 700; text-transform: uppercase; }
      .opt-side .v { font-weight: 700; font-size: 15px; color: var(--strong); font-variant-numeric: tabular-nums; }
      .opt-side .v small { font-size: 12px; color: #777; font-weight: 400; }
      @media (max-width: 560px) {
        .opt-card { flex-direction: column; gap: 8px; }
        .opt-side { text-align: left; display: flex; gap: 10px; align-items: baseline; order: -1; }
      }
      .toggle-btn {
        margin-top: 9px; border: 1.5px solid var(--strong); background: var(--paper); color: var(--strong); border-radius: 2px;
        padding: 8px 16px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 40px;
      }
      .toggle-btn:hover { background: var(--strong); color: #fff; }
      .toggle-btn[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }

      /* paint upgrade */
      .ups { display: flex; gap: 12px; }
      .up-card {
        flex: 1; min-width: 0; border: 1px solid var(--line-2); padding: 10px 12px; display: flex; gap: 12px; align-items: flex-start;
        background: var(--paper); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
      }
      .up-card img { height: 58px; width: auto; flex: none; }
      .up-card .up-body { display: block; min-width: 0; }
      .up-card .up-name { display: block; font-weight: 700; color: var(--strong); font-size: 14px; }
      .up-card .up-desc { display: block; font-size: 12px; color: #555; margin-top: 2px; }
      .up-card .up-price { display: block; font-weight: 700; color: var(--red); font-size: 14.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
      .up-card .up-check { display: none; font-size: 10.5px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 5px; }
      .up-card[aria-pressed="true"] { border: 1.5px solid var(--red); background: var(--red-soft); padding: 9.5px 11.5px; }
      .up-card[aria-pressed="true"] .up-check { display: block; }
      @media (max-width: 760px) { .ups { flex-direction: column; } }

      /* warranty */
      .warr img.banner { width: 100%; height: auto; display: block; border: 1px solid var(--line-2); }
      .warr .cov { display: flex; gap: 14px; margin-top: 9px; font-size: 12.5px; color: #444; }
      .warr .cov div { flex: 1; min-width: 0; padding-left: 17px; position: relative; }
      .warr .cov div::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }
      .warr .cov b { color: var(--strong); }
      @media (max-width: 640px) { .warr .cov { flex-direction: column; gap: 8px; } }

      /* badges + license */
      .badges { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 2px; }
      .badges img { height: 56px; width: 23%; object-fit: contain; }
      @media (max-width: 560px) { .badges { flex-wrap: wrap; } .badges img { width: 47%; height: 48px; } }
      .license-line { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
      .license-line b { color: var(--strong); }

      /* terms prose */
      .terms h5 { margin: 15px 0 3px; font-size: 14px; font-weight: 700; color: var(--strong); }
      .terms h5:first-of-type { margin-top: 2px; }
      .terms p { margin: 0 0 9px; color: var(--soft); font-size: 13px; max-width: 72ch; }
      .terms p b, .terms li b { color: var(--strong); }
      .process-list { list-style: none; margin: 4px 0 2px; padding: 0; }
      .process-list li { font-size: 13px; color: var(--soft); padding: 3px 0 3px 17px; position: relative; }
      .process-list li::before { content: ""; position: absolute; left: 0; top: 10px; width: 7px; height: 7px; background: var(--red); }
      .notice-box { border: 1px solid var(--line-2); background: var(--panel); padding: 12px 14px; margin-top: 14px; }
      .notice-box h5 { margin: 0 0 8px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--strong); }
      .notice-box p { font-size: 11.5px; color: #555; margin: 0 0 8px; }
      .notice-box p:last-child { margin-bottom: 0; }

      /* ---------- signature ---------- */
      .sign-note { font-size: 13.5px; color: #333; margin: 0 0 14px; max-width: 72ch; }
      .sign-note b { color: var(--red); }
      .sign-box { border: 1.5px solid var(--strong); padding: 18px; }
      @media (max-width: 640px) { .sign-box { padding: 14px; } }
      .sign-box h4 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--strong); }
      .sign-box .sc-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
      .field { margin-bottom: 14px; }
      .field label { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 7px; }
      .field input[type="text"] {
        width: 100%; border: 1px solid var(--input-line); border-radius: 2px; background: var(--paper);
        color: var(--ink); font: inherit; font-size: 15px; padding: 9px 11px; min-height: 44px;
      }
      .field input[type="text"]:focus, .slot-cap input:focus { outline: 2px solid var(--red); outline-offset: 1px; border-color: transparent; }
      .sig-pad-wrap { position: relative; border: 1px solid var(--input-line); background: var(--paper); overflow: hidden; }
      .sig-pad-wrap canvas { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; }
      .sig-placeholder {
        position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
        color: #a9a49a; font-size: 14px; pointer-events: none; font-style: italic;
      }
      .sig-baseline { position: absolute; left: 18px; right: 18px; bottom: 32px; border-bottom: 1px dashed var(--input-line); pointer-events: none; }
      .sig-x { position: absolute; left: 18px; bottom: 36px; font-weight: 700; color: #a9a49a; pointer-events: none; }
      .sig-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
      .sig-tools .hint { font-size: 12.5px; color: var(--faint); }
      .clear-btn { background: var(--paper); border: 1px solid var(--input-line); border-radius: 2px; color: var(--soft); font: inherit; font-size: 13px; font-weight: 700; padding: 7px 14px; cursor: pointer; min-height: 38px; }
      .clear-btn:hover { border-color: var(--strong); color: var(--strong); }
      .agree-line { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--soft); margin: 14px 0; }
      .agree-line svg { flex: none; width: 18px; height: 18px; stroke: var(--green); margin-top: 2px; }
      .sign-btn {
        width: 100%; background: var(--red); color: #fff; border: none; border-radius: 2px;
        font: inherit; font-size: 16.5px; font-weight: 700; padding: 13px 18px; cursor: pointer; min-height: 52px;
      }
      .sign-btn:hover { filter: brightness(1.07); }
      .sign-btn:active { transform: translateY(1px); }
      .sign-error { display: none; margin-top: 12px; background: var(--red-soft); color: var(--red); border: 1px solid var(--red); padding: 11px 14px; font-size: 14.5px; font-weight: 700; }
      .sign-error.show { display: block; }
      .sign-fineprint { font-size: 11.5px; color: var(--faint); margin: 12px 0 0; text-align: center; }

      .signed-banner { display: none; border: 1.5px solid var(--green); background: var(--green-soft); padding: 18px; }
      .signed-banner.show { display: block; }
      .signed-banner h4 { margin: 0 0 4px; font-size: 19px; font-weight: 700; color: var(--green); display: flex; align-items: center; gap: 10px; }
      .signed-banner h4 svg { width: 24px; height: 24px; stroke: var(--green); flex: none; }
      .signed-banner p { margin: 4px 0; font-size: 14px; }
      .signed-banner .sig-img { background: #fff; border: 1px solid var(--line-2); padding: 8px 14px; margin: 14px 0; max-width: 420px; }
      .signed-banner .sig-img img { max-width: 100%; height: 76px; display: block; }
      .signed-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
      .dl-btn, .mail-btn {
        border-radius: 2px; font: inherit; font-size: 14px; font-weight: 700; padding: 11px 18px; cursor: pointer; min-height: 46px;
        text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
      }
      .dl-btn { background: var(--strong); color: #fff; border: none; }
      .mail-btn.primary { background: var(--red); color: #fff; border-color: var(--red); }
      .mail-btn.primary:hover { filter: brightness(1.07); }
      .mail-btn { background: transparent; color: var(--strong); border: 1.5px solid var(--strong); }
      .reset-link { background: none; border: none; color: var(--faint); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; margin-top: 14px; padding: 4px; }

      .locked .opt-zone, .locked .photo-zone, .locked .upgrade-zone { opacity: 0.55; pointer-events: none; }
      .doc-foot { margin-top: 30px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; text-align: center; }

      /* tap hint on unselected upgrade cards */
      .up-card .up-hint { display: none; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 5px; }
      .up-card[aria-pressed="false"] .up-hint { display: block; }

      /* signed-banner notification line */
      .signed-banner .notify-line { margin-top: 10px; }

      /* sticky running total — same black box as the document TOTAL */
      body { padding-bottom: 74px; }
      .sticky-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--strong); color: #fff; box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.22); padding-bottom: env(safe-area-inset-bottom); }
      .sb-inner { max-width: 820px; margin: 0 auto; padding: 8px 36px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
      .sb-left { min-width: 0; }
      .sb-label { display: block; font-size: 10.5px; letter-spacing: 2.5px; text-transform: uppercase; color: #c9c6bf; }
      .sb-addons { display: block; font-size: 12.5px; color: #e8e6e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      .sb-right { display: flex; align-items: center; gap: 14px; flex: none; }
      .sb-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
      .sb-total.pulse { animation: sbpulse 0.7s ease; }
      @keyframes sbpulse { 0% { color: #f2c94c; transform: scale(1.07); } 100% { color: #fff; transform: scale(1); } }
      @media (prefers-reduced-motion: reduce) { .sb-total.pulse { animation: none; } }
      .sb-btn { background: var(--red); color: #fff; text-decoration: none; font-weight: 700; font-size: 13.5px; padding: 8px 14px; border-radius: 2px; white-space: nowrap; }
      .sb-btn:hover { filter: brightness(1.08); }
      .sticky-bar.signed .sb-btn { display: none; }
      @media (max-width: 640px) { .sb-inner { padding: 8px 16px; } }
      @media (max-width: 480px) { .sb-addons { display: none; } .sb-total { font-size: 18px; } }

      @media print {
        body { background: #fff; }
        .doc { box-shadow: none; margin: 0 auto; }
        .slot-drop, .add-photo, .toggle-btn, .clear-btn, .sign-btn, .reset-link, .sticky-bar, .send-bar { display: none !important; }
        body { padding-bottom: 0; }
      }
