/* FairWatt proposal: screen (mobile first) and print (2 pages, US Letter).
   Brand colours come from the tenant: --amber (primary), --amber-deep, --coral (accent),
   --ink, --bg — injected per tenant by the Worker. */
:root {
  --amber: #1F6FEB; --amber-deep: #1554B8; --coral: #0FB5AE; --ink: #14213D; --bg: #F6F8FC;
  --surface: #fff; --dim: #5b6475; --line: rgba(20, 33, 61, .12); --good: #1e8e5a; --warn: #b4540a;
  --r: 14px; --shadow: 0 10px 30px rgba(20, 33, 61, .08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--bg); padding-bottom: 84px; }
a { color: var(--amber-deep); }
h1 { font-size: clamp(24px, 4.4vw, 36px); line-height: 1.15; margin: 4px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 21px; line-height: 1.25; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.small { font-size: 13.5px; color: var(--dim); }
.note { font-size: 14px; color: var(--dim); background: rgba(20, 33, 61, .04); border-radius: 10px; padding: 8px 12px; }
.lead { color: var(--dim); margin-top: 0; }
[hidden] { display: none !important; }

/* top bar */
.p-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.p-top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand small { color: var(--dim); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call { font-weight: 600; text-decoration: none; white-space: nowrap; padding: 10px 0; }

/* header */
.p-head { padding: 22px 0 6px; }
.h-for { color: var(--dim); font-size: 15px; }
.h-meta { color: var(--dim); font-size: 14px; }
.held { color: var(--ink); font-weight: 600; background: rgba(15, 181, 174, .12); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.home-ask { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.home-ask form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; width: 100%; position: relative; }
.home-ask label { flex: 1 1 240px; display: flex; flex-direction: column; font-size: 13px; color: var(--dim); position: relative; }
input, select { font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 44px; width: 100%; }

/* buttons */
.btn, .btn-sm, .p-bar button, .p-bar a { font: inherit; font-weight: 650; border-radius: 12px; cursor: pointer; text-decoration: none; text-align: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 20px; background: var(--amber); color: #fff; border: 0; }
.btn.ghost, .btn-sm.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-sm { min-height: 44px; padding: 8px 16px; background: var(--amber); color: #fff; border: 0; }
.btn-link { align-self: center; font-size: 14px; }
.btn:disabled, .btn-sm:disabled { opacity: .6; cursor: progress; }

/* the answer */
.answer { display: grid; grid-template-columns: 1fr; gap: 12px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin: 10px 0 18px; }
.a-label { color: var(--dim); font-size: 14px; font-weight: 600; }
.a-price { font-size: clamp(34px, 7vw, 46px); font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.a-or { font-size: 18px; font-weight: 500; color: var(--dim); }
.a-offer { margin: 6px 0; }
.a-sub { margin: 4px 0 0; color: var(--dim); font-size: 13.5px; }
.a-facts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.a-facts div { background: var(--bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.f-n { font-weight: 700; font-size: 16px; }
.f-l { color: var(--dim); font-size: 12.5px; }
@media (min-width: 760px) { .answer { grid-template-columns: 1.2fr 1fr; align-items: center; } .a-facts { grid-template-columns: 1fr; } }

/* option cards: horizontal snap carousel on phones */
.cards { display: grid; grid-auto-flow: column; grid-auto-columns: 78%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; margin: 8px -2px 0; }
@media (min-width: 760px) { .cards { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); overflow: visible; } }
.card { scroll-snap-align: start; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-height: 44px; }
.card.on { border-color: var(--amber); box-shadow: var(--shadow); }
.c-name { font-weight: 750; font-size: 17px; }
.c-name em { font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: var(--amber); color: #fff; border-radius: 999px; padding: 2px 8px; margin-left: 4px; vertical-align: 2px; }
.c-what, .c-row, .c-blurb { font-size: 13.5px; color: var(--dim); }
.c-price { font-size: 24px; font-weight: 750; }
.bt { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 600; margin: 4px 0 6px; }
.bt input { width: 22px; height: 22px; min-height: 0; }

/* sections */
.sec { background: var(--surface); border-radius: var(--r); padding: 18px; margin: 14px 0; border: 1px solid var(--line); }
.two { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .two { grid-template-columns: 1fr 1fr; } }
.est { border-radius: 12px; padding: 14px; background: var(--bg); }
.est-std { border: 2px solid rgba(20, 33, 61, .18); }
.e-tag { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); font-weight: 700; }
.e-n { font-size: 28px; font-weight: 750; }
.e-l { color: var(--dim); font-size: 13.5px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
dt { color: var(--dim); }
dd { margin: 0; }
.assume dl { grid-template-columns: 1fr; }
.assume dt { font-weight: 700; color: var(--ink); margin-top: 8px; }
.why { font-size: 14.5px; }
.explain { background: var(--bg); border-radius: 12px; padding: 4px 14px 2px; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 12.5px; }
.pay, .faces { display: block; overflow-x: auto; }
@media (max-width: 560px) {
  /* stacked rows instead of a cut-off table */
  .pay thead { display: none; }
  .pay, .pay tbody, .pay tr, .pay td { display: block; width: 100%; }
  .pay tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .pay td { border: 0; padding: 2px 0; }
  .pay td:first-child { font-weight: 700; }
  .pay td:nth-child(2)::before { content: "Monthly: "; color: var(--dim); }
  .pay td:nth-child(3)::before { content: "APR: "; color: var(--dim); }
  .pay td:nth-child(4)::before { content: "Lender fee: "; color: var(--dim); }
  .pay td:nth-child(5)::before { content: "APR on cash price: "; color: var(--dim); }
  .pay td:nth-child(6)::before { content: "Total: "; color: var(--dim); }
}
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
.warn { color: var(--warn); font-weight: 700; }
.flag { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 999px; padding: 2px 8px; }
.flag-unverified { background: #fdecc8; color: #8a4b00; }
.flag-secondary { background: #e8eefb; color: #23447f; }
ul.ticks, ul.maybe, ul.trust { padding-left: 20px; }
.steps { padding-left: 0; list-style: none; }
.steps li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.days { color: var(--dim); font-size: 13.5px; }
blockquote { margin: 10px 0; padding: 10px 14px; background: var(--bg); border-radius: 10px; }
blockquote cite { display: block; font-size: 13px; color: var(--dim); font-style: normal; }
.ess { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 8px; }
.ess label { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: 14.5px; }
.ess input { width: 20px; height: 20px; min-height: 0; }

/* charts and roof */
.chart { width: 100%; height: auto; display: block; margin: 8px 0 0; }
.c-before { fill: rgba(20, 33, 61, .28); }
.c-after { fill: var(--amber); }
.c-p50 { fill: var(--coral); opacity: .85; }
.c-p90 { stroke: var(--ink); stroke-width: 2; }
.c-lab { font-size: 11px; fill: var(--dim); }
.c-zero { stroke: rgba(20, 33, 61, .35); stroke-dasharray: 3 3; }
.c-plan { fill: none; stroke: var(--amber); stroke-width: 3; }
.c-low, .c-high { fill: none; stroke: rgba(20, 33, 61, .3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.legend { font-size: 12.5px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.legend span { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.k-before { background: rgba(20, 33, 61, .28); } .k-after { background: var(--amber); }
.k-p50 { background: var(--coral); } .k-p90 { background: var(--ink); height: 3px !important; }
.k-plan { background: var(--amber); height: 4px !important; } .k-band { border: 1.5px dashed rgba(20, 33, 61, .4); height: 4px !important; }
.roof-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #3b4a3a; }
.roof { position: relative; width: 100%; height: auto; display: block; }
/* the satellite photo under the panel overlay (render.ts roofSvg): cover = the SVG's xMidYMid slice */
.roof-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }
.pn { fill: rgb(calc(30 + var(--r, 1) * 30), calc(40 + var(--r, 1) * 40), calc(70 + var(--r, 1) * 60)); stroke: #ffd36a; stroke-width: 1; }
.pg { fill: rgba(255, 255, 255, .06); stroke: rgba(255, 255, 255, .35); stroke-width: .6; stroke-dasharray: 2 2; }

/* sticky action bar */
.p-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(20, 33, 61, .08); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.p-bar .wrap { display: flex; gap: 8px; align-items: center; }
.pb-price { font-weight: 750; font-size: 18px; margin-right: auto; line-height: 1.1; }
.pb-price small { display: block; font-size: 12px; color: var(--dim); font-weight: 500; }
.p-bar button, .p-bar a { min-height: 44px; min-width: 44px; padding: 8px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 14.5px; display: inline-flex; align-items: center; }
.p-bar .primary { background: var(--amber); color: #fff; border-color: var(--amber); }
@media (max-width: 380px) { .p-bar button, .p-bar a { padding: 8px 9px; font-size: 13.5px; } .pb-price { font-size: 16px; } }
.acts { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.p-foot { color: var(--dim); font-size: 12.5px; padding: 18px 0; }
.fw-powered { display: block; margin-top: 6px; font-size: 11.5px; opacity: .75; }
.print-qr { display: none; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; max-width: 92vw; font-size: 14px; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* address suggestions */
.suggest { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 40; overflow: hidden; }
.suggest div { padding: 12px; min-height: 44px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest div:hover { background: var(--bg); }

/* dialogs (reserve, guide) */
dialog { border: 0; border-radius: 16px; padding: 0; max-width: 560px; width: calc(100vw - 24px); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(20, 33, 61, .45); }
.dlg { padding: 20px; }
.dlg label { display: flex; flex-direction: column; font-size: 13.5px; color: var(--dim); margin: 8px 0; }
.dlg .cb { flex-direction: row; gap: 10px; align-items: flex-start; color: var(--ink); font-size: 14.5px; }
.dlg .cb input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; }
.err { color: #b42318; font-weight: 600; }
.guide-box { max-height: 40vh; overflow: auto; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* editor */
.editor .ed-roof { overflow: auto; max-height: 60vh; border-radius: 12px; background: #3b4a3a; -webkit-overflow-scrolling: touch; }
.editor .ed-roof svg { display: block; }
.editor .ed-roof polygon { cursor: pointer; }
.editor .ed-roof .pn { fill: #2c4a7e; stroke: #ffd36a; stroke-width: 1.2; }
.editor .ed-roof .pg { fill: rgba(255, 255, 255, .12); stroke: rgba(255, 220, 120, .8); stroke-width: .8; }
.editor .ed-roof polygon:focus { outline: none; stroke: #fff; stroke-width: 2; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.grid2 label, label.file { display: flex; flex-direction: column; font-size: 13.5px; color: var(--dim); }
.grid2 .cb { flex-direction: row; gap: 10px; align-items: center; color: var(--ink); min-height: 44px; }
.grid2 .cb input { width: 22px; height: 22px; min-height: 0; }

/* self-serve landing */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(30px, 6vw, 48px); }
.self { display: flex; flex-wrap: wrap; gap: 10px; position: relative; max-width: 640px; }
.self label { flex: 1 1 280px; position: relative; display: flex; }
.self .btn { flex: 0 0 auto; }

/* staff */
.staff table td, .staff table th { white-space: nowrap; }
.status { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 999px; padding: 2px 8px; background: var(--bg); }
.status-viewed, .status-shared { background: #e8eefb; } .status-reserved { background: #d8f3e3; color: #135c39; }
.staff form.new { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .staff form.new { grid-template-columns: 2fr 1fr 1fr; } }
.staff .opts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.staff .preview { border: 2px dashed var(--line); border-radius: var(--r); overflow: hidden; }
.staff .preview iframe { width: 100%; height: 70vh; border: 0; background: var(--bg); }
.staff a, .staff .small { overflow-wrap: anywhere; }
.dev-banner { background: #fdecc8; color: #8a4b00; font-size: 13px; text-align: center; padding: 6px; font-weight: 600; }

/* the roof: the caveat and "Edit panels" (render.ts roofNote, proposal.js) */
.pe-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; }
.pe-row .small { flex: 1 1 220px; }
.roof-note { margin: 8px 0 0; }
.po { stroke: #ff9f43 !important; stroke-dasharray: 3 2; }
.pe-dlg { max-width: 920px; width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
.pe-box { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.pe-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pe-head h2 { margin: 0; }
.pe-x { font: inherit; font-size: 26px; line-height: 1; width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(20, 33, 61, .06); cursor: pointer; }
.pe-how { margin: 0; }
.pe-roof { overflow: auto; max-height: min(56vh, 560px); border-radius: 12px; background: #3b4a3a; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pe-canvas { position: relative; overflow: hidden; }
.pe-photo { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.pe-canvas svg { position: relative; display: block; }
.pe-canvas polygon { cursor: pointer; touch-action: none; }
.pe-canvas .pn { fill: rgba(28, 52, 104, .78); stroke: #ffd36a; stroke-width: 1.3; cursor: grab; }
.pe-canvas .pg { fill: rgba(255, 255, 255, .14); stroke: rgba(255, 255, 255, .85); stroke-width: .8; stroke-dasharray: 2.5 2; }
.pe-canvas .pg:hover { fill: rgba(255, 211, 106, .35); }
.pe-canvas .pe-drag { opacity: .85; cursor: grabbing; }
.pe-canvas polygon:focus { outline: none; stroke: #fff; stroke-width: 2.2; }
.pe-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; }
.pe-stats .pe-price { margin-left: auto; font-size: 17px; }
.pe-msg { margin: 0; font-size: 14px; font-weight: 600; color: var(--warn); }
.pe-off { margin: 0; color: var(--warn); }
.pe-key { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 0; }
.pe-key i { display: inline-block; width: 16px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.pe-key .k-pn { background: #1c3468; border: 1.5px solid #ffd36a; }
.pe-key .k-pg { border: 1.5px dashed #8a93a6; }
.pe-key .k-po { background: #1c3468; border: 1.5px dashed #ff9f43; }
.pe-note { margin: 0; }
.pe-box .acts { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); padding: 8px 0 calc(4px + env(safe-area-inset-bottom)); margin-bottom: -4px; }
@media (max-width: 600px) { .pe-box { padding: 12px; } .pe-dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; } .pe-roof { max-height: 48vh; } }
@media print { .pe-row, .roof-note { display: none !important; } }

/* ---------------------------------------------------------------- print: 2 pages, US Letter
   The screen layout is hidden; a dedicated two-page sheet for the chosen option prints instead. */
.print-sheet { display: none; }
@page { size: letter; margin: 0.4in 0.45in; }
@media print {
  body { background: #fff; padding: 0; font-size: 9.5pt; line-height: 1.32; }
  .p-top, .p-head, .cards, .bt, .p-bar, #toast, dialog, .p-foot, .print-qr, .next,
  main > .sec, .opt > :not(.print-sheet) { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .opt:not([hidden]) > .print-sheet { display: block; }
  .ps-page { height: 10.1in; overflow: hidden; break-after: page; }
  .ps-p2 { break-after: auto; }
  .ps-head { display: flex; gap: 8px; align-items: center; border-bottom: 2px solid var(--amber); padding-bottom: 5px; }
  .ps-head small { color: var(--dim); }
  h1 { font-size: 17pt; margin: 8px 0 2px; }
  h2 { font-size: 11pt; margin: 8px 0 3px; }
  .ps-meta { margin: 0 0 6px; color: var(--dim); }
  .ps-answer { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
  .ps-price { font-size: 24pt; font-weight: 750; line-height: 1.1; }
  .ps-price small { font-size: 11pt; font-weight: 500; color: var(--dim); }
  .ps-l { color: var(--dim); }
  .ps-facts { display: flex; flex-direction: column; gap: 3px; justify-content: center; }
  .ps-grid { display: grid; grid-template-columns: 3.1in 1fr; gap: 12px; margin-top: 8px; }
  .ps-roof svg { width: 100%; height: auto; border-radius: 6px; }
  .ps-roof .roof-wrap { border-radius: 6px; }
  .ps-roof small { color: var(--dim); font-size: 8pt; }
  .ps-t { width: 100%; font-size: 8.5pt; }
  .ps-t th, .ps-t td { padding: 2px 3px; }
  .ps-t tr.on td { font-weight: 700; background: rgba(20, 33, 61, .05); }
  .ps-grid .chart { max-height: 1.25in; margin: 0; }
  .legend { font-size: 7.5pt; }
  .ps-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
  .ps-box { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 8.8pt; }
  .ps-s { font-size: 8.3pt; color: var(--dim); }
  .print-sheet ul, .print-sheet ol { margin: 2px 0; padding-left: 16px; }
  .print-sheet li { margin: 1px 0; }
  .ps-foot { display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; font-size: 8.5pt; }
  .ps-qr svg { width: 1in; height: 1in; display: block; }
  .ps-sign { margin-top: 10px; }
  a { color: inherit; text-decoration: none; }
}
.a-adder { font-size: 14px; background: #fff7e6; border: 1px solid #f3d9a4; border-radius: 10px; padding: 8px 12px; margin: 8px 0 0; }
