:root {
  --green: #ffcc00;
  --green-dark: #132743;
  --green-soft: #eef4ff;
  --ink: #222222;
  --muted: #666666;
  --line: #dddddd;
  --bg: #f7f7f7;
  --card: #ffffff;
  --danger: #132743;
  --radius: 8px;
  --shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

/* Author display rules (for example .button { display:inline-flex }) can
   otherwise override the browser's built-in hidden attribute styling. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- topbar ---------- */
.topbar { background: #111; color: #fff; border-bottom: 2px solid #ffcc00; }
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  background: var(--green); color: #fff; border-radius: 8px;
  padding: 3px 8px; font-size: 14px; letter-spacing: 0.5px;
}
.brand-mark {
  color: #111;
  border-radius: 6px;
}
.brand-name { font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.link-button {
  background: none; border: none; color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: underline; padding: 4px;
}
.api-status { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,0.14); color: #eee; }
.api-status.ok { background: rgba(19,39,67,0.35); color: #fff; }
.api-status.fail { background: rgba(220, 120, 120, 0.25); color: #ffd7d7; }

/* ---------- wizard shell ---------- */
.wizard { max-width: 620px; margin: 0 auto; padding: 22px 18px 120px; }
.wizard-head { text-align: center; margin-bottom: 18px; }
.wizard-head h1 { font-size: 24px; margin: 6px 0 4px; }
.wizard-sub { color: var(--muted); margin: 0 0 14px; }
.progress { display: flex; gap: 6px; justify-content: center; margin: 14px 0 6px; }
.progress-dot { width: 26px; height: 6px; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.progress-dot.done { background: #132743; }
.progress-dot.current { background: #111; }
.step-counter { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- steps ---------- */
.step { display: none; }
.step.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 20px;
}
.step-card h2 { font-size: 21px; margin: 2px 0 8px; }
.step-eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; color: var(--green); font-weight: 700; margin: 0; }
.step-eyebrow { color: #132743; }
.step-help { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.help-box { margin: 0 0 16px; padding: 12px 14px; border-left: 4px solid #ffcc00; border-radius: 8px; background: #fff8df; color: #3f3a27; font-size: 13px; line-height: 1.5; text-align: left; }
.process-explainer { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9f8; text-align: left; }
.process-explainer summary { cursor: pointer; color: #132743; font-weight: 800; }
.process-explainer ol { margin: 12px 0 0; padding-left: 22px; }
.process-explainer li { margin: 8px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.customer-process { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 14px 0 4px; }
.customer-process span { padding: 7px 5px; border-radius: 8px; background: #edf0ef; color: #68706d; font-size: 10px; font-weight: 700; line-height: 1.25; text-align: center; }
.customer-process span.done { background: #dceee3; color: #185c35; }
.customer-process span.active { background: #132743; color: #fff; box-shadow: 0 0 0 2px #ffcc00; }
.result-process { margin: 12px 0 20px; }
.result-stage-title { margin-bottom: 4px !important; color: #132743; }
.how-to { margin: 0 0 16px; padding-left: 20px; color: var(--ink); font-size: 14px; }
.how-to li { margin: 4px 0; }
.field-status { font-size: 13px; color: var(--muted); margin: 10px 0 0; min-height: 18px; }

/* ---------- inputs ---------- */
.field { display: block; margin: 14px 0; font-weight: 600; font-size: 14px; }
.choice-field { border: 0; padding: 0; margin: 14px 0; }
.choice-field legend { margin-bottom: 8px; font-weight: 700; }
.choice-field .check-item + .check-item { margin-top: 8px; }
.field input, .field select, .field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 13px;
  border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; font-weight: 500;
  background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #132743; box-shadow: 0 0 0 3px var(--green-soft);
}
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; }

/* buttons */
button, .button {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .button:hover { border-color: var(--green); }
button:hover, .button:hover { border-color: #132743; }
button.primary, .button.primary { background: #ffcc00; border-color: #ffcc00; color: #111; }
button.primary:hover, .button.primary:hover { background: #ffb700; }
button.active { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.button-grid > * { flex: 1; min-width: 120px; }
.big-cta { width: 100%; padding: 16px; font-size: 17px; margin-top: 10px; }
.fine-print { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }

/* suggestions */
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.suggestion-item { text-align: left; justify-content: flex-start; font-weight: 500; font-size: 14px; }

.mini-map { margin-top: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.mini-map iframe { width: 100%; height: 200px; border: 0; display: block; }

/* ---------- trace stage ---------- */
.stage-slot { margin: 8px 0 4px; }
.roof-photo-stage {
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 420px;
  border-radius: 14px; overflow: hidden; background: #0c0f0e; touch-action: none;
  border: 1px solid var(--line);
}
.roof-photo-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.roof-photo-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.roof-photo-stage.eave-select-mode canvas { cursor: crosshair; }
.roof-photo-stage.adjust-mode img { cursor: grab; }
.photo-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #cdd6d2; font-size: 14px; text-align: center; padding: 20px;
}
.roof-photo-stage.has-photo .photo-placeholder { display: none; }
.map-adjust-bar {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(17,17,17,0.86);
  color: #fff; padding: 10px; backdrop-filter: blur(4px);
}
.adjust-hint { margin: 0 0 8px; font-size: 12px; text-align: center; }
.nudge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 240px; margin: 0 auto; }
.nudge-grid button { padding: 8px; background: rgba(255,255,255,0.12); border-color: transparent; color: #fff; }
.nudge-grid button.primary { background: #ffcc00; color: #111; }
.captured-flag { color: #132743; font-weight: 700; margin: 10px 0 0; }

/* ---------- option lists ---------- */
.option-list, .check-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.check-list.tight { gap: 6px; margin: 8px 0; }
.option-item, .check-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer;
}
.option-item .shingle-thumb {
  width: 68px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
  margin-top: 2px;
}
.option-item .shingle-thumb.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  background: #f3f4f5;
}
.option-item.selected { border-color: #132743; background: var(--green-soft); }
.option-item input, .check-item input { margin-top: 3px; width: 18px; height: 18px; accent-color: #132743; }
.option-item span, .check-item span { display: flex; flex-direction: column; }
.option-item small, .check-item small { color: var(--muted); font-weight: 500; margin-top: 2px; }
.check-item.big { font-size: 16px; padding: 16px; }
.count-inline { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.count-inline input { width: 90px; margin-left: 8px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 8px; }

/* ---------- colour swatches ---------- */
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.swatch {
  display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; font-weight: 600;
}
.swatch.selected { border-color: #132743; background: var(--green-soft); }
.swatch .chip { width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid var(--b); }

.shingle-colour-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.shingle-colour-block h3 { margin: 0 0 4px; font-size: 17px; }

/* ---------- result ---------- */
.result-card { text-align: center; }
.result-metrics { display: flex; gap: 12px; margin: 16px 0; }
.result-metrics .metric {
  flex: 1; background: #fff8e1; border-radius: 12px; padding: 14px;
}
.result-metrics .metric span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.result-metrics .metric strong { font-size: 20px; }
.ballpark { background: #111; color: #fff; border-radius: 14px; padding: 20px; margin: 8px 0 16px; }
.ballpark span { display: block; font-size: 13px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.06em; }
.ballpark strong { font-size: 30px; }
.disclaimer {
  background: #eef4ff; border: 1.5px solid #b9c9e3; color: #132743; border-radius: 12px;
  padding: 14px; font-size: 13px; text-align: left; line-height: 1.5;
}
/* Detailed-estimate status banner shown when viewing a saved estimate */
.detailed-status {
  margin: 16px 0; padding: 16px 18px; border-radius: 12px; text-align: left;
  border: 1.5px solid transparent; line-height: 1.55;
}
.detailed-status h3 { margin: 0 0 6px; font-size: 16px; }
.detailed-status p { margin: 6px 0; font-size: 14px; }
.detailed-status .detailed-status-call { width: 100%; margin-top: 12px; text-decoration: none; }
.detailed-status.is-pending { background: #fff7e6; border-color: #f0d089; color: #6a4b06; }
.detailed-status.is-pending h3 { color: #8a5a00; }
.detailed-status.is-ready { background: #eaf6ee; border-color: #a9d8b8; color: #1c5330; }
.detailed-status.is-ready h3 { color: #1c7a3e; }
.detailed-status.is-approved { background: #e9f2ff; border-color: #b3ccef; color: #143a6b; }
.detailed-status.is-approved h3 { color: #1a56a8; }

/* Detailed (firm) estimate breakdown shown on the client result view */
.detailed-pricing { margin: 4px 0 16px; text-align: left; }
.detailed-pricing h4 { margin: 0 0 8px; font-size: 14px; color: #132743; }
.detailed-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.detailed-lines th, .detailed-lines td { padding: 7px 8px; border-bottom: 1px solid #e5e5e5; }
.detailed-lines thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.detailed-lines .num { text-align: right; white-space: nowrap; }
.detailed-lines tfoot td { border-bottom: none; padding-top: 8px; }
.detailed-lines tfoot .grand td { font-weight: 800; font-size: 15px; color: #132743; border-top: 2px solid #132743; }

.result-code {
  margin: 16px 0; padding: 14px; border: 1.5px dashed #132743; border-radius: 12px; background: var(--green-soft);
}
.result-code span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.result-code strong { display: block; font-size: 28px; letter-spacing: 4px; color: #132743; margin: 4px 0; }
.result-code p { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.result-code .code-reminder { display: block; font-size: 14px; letter-spacing: 0; color: #7a2e22; margin-top: 8px; }
.result-job-details { margin: 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; }
.result-job-details h3, .result-job-details h4 { margin: 0 0 10px; }
.result-job-details h4 { margin-top: 14px; }
.result-job-details dl { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 7px 12px; margin: 0; }
.result-job-details dt { color: var(--muted); font-weight: 600; }
.result-job-details dd { margin: 0; }
.result-job-details ul { margin: 0; padding-left: 20px; }

/* ---------- nav ---------- */
.wizard-nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.95);
  border-top: 1px solid var(--line); padding: 12px 18px; backdrop-filter: blur(6px);
  display: flex; gap: 12px; max-width: 620px; margin: 0 auto;
}
.wizard-nav button { flex: 1; padding: 14px; font-size: 16px; }
.wizard-nav #backBtn { flex: 0 0 40%; }

/* ---------- dialog ---------- */
.dialog {
  border: none; border-radius: var(--radius); padding: 0; max-width: 420px; width: 92%;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(15,46,38,0.4); }
.dialog::backdrop { background: rgba(0,0,0,0.45); }
.dialog-form { padding: 22px; }
.dialog-form h2 { margin: 0 0 6px; }

/* ---------- footer ---------- */
.site-foot { text-align: center; padding: 24px; }
.site-foot a { color: #132743; font-size: 13px; text-decoration: none; }

@media (max-width: 700px) {
  .topbar-inner {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .topbar-actions {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .wizard {
    padding: 16px 12px 110px;
  }
  .step-card {
    padding: 18px 14px;
  }
  .wizard-head h1 {
    font-size: 22px;
  }
  .step-card h2 {
    font-size: 19px;
  }
  .search-row {
    flex-direction: column;
  }
  .wizard-nav {
    padding: 10px 12px;
    gap: 8px;
  }
  .wizard-nav button {
    padding: 12px;
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .result-code strong {
    font-size: 24px;
    letter-spacing: 2px;
    word-break: break-all;
  }
  .ballpark strong {
    font-size: 26px;
  }
  .wizard-nav #backBtn {
    flex-basis: 44%;
  }
  .dialog-form {
    padding: 16px;
  }
}

@media (max-width: 420px) {
  .swatches { grid-template-columns: 1fr; }
  .result-metrics { flex-direction: column; }
}

/* ---------------- sign-off dialog (review & sign contract) ---------------- */

.signoff-dialog { max-width: 760px; width: calc(100% - 32px); }
.signoff-details {
  margin: 18px 0;
  padding: 20px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
}
.signoff-head h3 { margin: 0 0 4px; font-size: 19px; color: var(--green-dark); }
.signoff-head p { margin: 0; color: var(--muted); font-size: 14px; }
.signoff-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0;
  padding: 0;
}
.signoff-facts > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.signoff-facts dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 2px;
}
.signoff-facts dd { margin: 0; font-weight: 600; font-size: 14px; }
.signoff-details h4 {
  margin: 18px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green-dark);
}
.signoff-scope { margin: 0; padding-left: 20px; }
.signoff-scope li { margin: 5px 0; font-size: 14px; line-height: 1.45; }
.signoff-table-wrap { overflow-x: auto; }
.signoff-lines { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.signoff-total-only {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 15px;
}
.signoff-total-only strong { font-size: 20px; color: var(--green-dark); }

.sign-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sign-pad-wrap { margin: 14px 0 6px; text-align: left; }
.sign-pad-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.sign-pad {
  width: 100%;
  height: 180px;
  display: block;
  background: #fff;
  border: 1.5px dashed var(--green-dark);
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
}
.sign-pad-actions { margin-top: 8px; display: flex; justify-content: flex-end; }
.sign-pad-actions button { padding: 8px 14px; font-size: 13px; }
.signoff-legal { font-size: 12px; line-height: 1.5; color: var(--muted); }

@media (max-width: 560px) {
  .sign-fields { grid-template-columns: 1fr; }
  .signoff-details { padding: 14px; }
  .sign-pad { height: 150px; }
}

/* ---------------- signed-estimate celebration ---------------- */

.celebration-dialog {
  position: relative;
  width: min(680px, calc(100% - 24px));
  max-width: 680px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.34);
}
.celebration-dialog::backdrop {
  background: rgba(7, 18, 32, 0.82);
  backdrop-filter: blur(4px);
}
.celebration-card {
  position: relative;
  z-index: 2;
  padding: 38px 38px 28px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 204, 0, 0.25), transparent 38%),
    linear-gradient(180deg, #fffdf4 0, #fff 48%);
}
.celebration-badge {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border: 7px solid #fff3b5;
  border-radius: 50%;
  background: var(--green);
  color: #132743;
  font-size: 40px;
  font-weight: 900;
  box-shadow: 0 9px 24px rgba(203, 159, 0, 0.25);
  animation: celebration-pop 650ms cubic-bezier(.2, .9, .25, 1.35) both;
}
.celebration-eyebrow {
  margin: 0 0 6px;
  color: #816400;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.celebration-card h2 { margin: 0; color: var(--green-dark); font-size: clamp(30px, 6vw, 45px); line-height: 1.05; }
.celebration-lead { max-width: 520px; margin: 14px auto 22px; color: #4e5662; font-size: 17px; line-height: 1.55; }
.celebration-next { padding: 20px; border: 1px solid #e7e0bd; border-radius: 16px; background: rgba(255,255,255,.9); text-align: left; }
.celebration-next h3 { margin: 0 0 14px; color: var(--green-dark); font-size: 18px; text-align: center; }
.celebration-next ol { margin: 0; padding: 0; list-style: none; counter-reset: next-step; display: grid; gap: 13px; }
.celebration-next li { counter-increment: next-step; position: relative; min-height: 38px; padding-left: 48px; }
.celebration-next li::before {
  content: counter(next-step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-dark);
  color: #fff;
  font-weight: 800;
}
.celebration-next strong, .celebration-next span { display: block; }
.celebration-next strong { color: #202b3a; font-size: 14px; }
.celebration-next span { margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.celebration-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
.celebration-actions > * { min-width: 190px; justify-content: center; }
.celebration-contact { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.celebration-contact a { color: var(--green-dark); font-weight: 700; }
.celebration-confetti { position: absolute; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; }
.celebration-confetti i {
  position: absolute;
  top: -24px;
  left: var(--x);
  width: var(--w);
  height: 14px;
  border-radius: 2px;
  background: var(--colour);
  opacity: 0;
  transform: rotate(var(--rotate));
  animation: confetti-fall var(--duration) var(--delay) ease-in forwards;
}
@keyframes celebration-pop { from { opacity: 0; transform: scale(.45) rotate(-12deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, -20px, 0) rotate(0); }
  100% { opacity: .9; transform: translate3d(var(--drift), 760px, 0) rotate(720deg); }
}
@media (max-width: 560px) {
  .celebration-card { padding: 30px 18px 22px; }
  .celebration-lead { font-size: 15px; }
  .celebration-next { padding: 16px; }
  .celebration-actions { flex-direction: column-reverse; }
  .celebration-actions > * { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .celebration-badge, .celebration-confetti i { animation: none; }
  .celebration-confetti { display: none; }
}
