/* =========================================================
   THEME-NEUTRAL BASELINE
   Prepended to every theme's CSS. Covers behavior that must work
   regardless of theme (anchor-scroll to the quote form under a sticky
   topbar) and a plain fallback for arbitrary site-authored HTML inside
   CONFIG["cost_body"] (tables, lists) that a theme's own CSS doesn't
   otherwise style.
========================================================= */
*{ box-sizing: border-box; }

/* Browsers default <figure> to `margin: 1em 40px`, which throws off any
   grid/flex pairing it sits in (e.g. an image beside a quote-form box) —
   the sibling box ends up looking like it "sticks out" below the image. */
figure{ margin: 0; }

html, body{ max-width: 100%; overflow-x: clip; }

html, body{
  scroll-behavior: smooth;
  scroll-padding-top: calc(110px + env(safe-area-inset-top));
}

#quote-panel{
  scroll-margin-top: calc(110px + env(safe-area-inset-top));
}

@media (min-width: 900px){
  html, body{ scroll-padding-top: 80px; }
  #quote-panel{ scroll-margin-top: 80px; }
}

[hidden]{ display: none !important; }

.sr-only{
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Fallback styling for arbitrary CONFIG["cost_body"] markup (tables, lists)
   that a theme's own stylesheet doesn't specifically target. */
table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 14px 0;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  overflow: hidden;
}
thead th{
  background: rgba(0,0,0,.04);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,.12);
  white-space: nowrap;
  font-size: 13px;
}
td{
  padding: 10px 12px;
  vertical-align: top;
  border-bottom: 1px solid rgba(0,0,0,.10);
  font-size: 14px;
}
tbody tr:last-child td{ border-bottom: none; }
.table-scroll{ max-width: 100%; }
@media (max-width: 640px){
  .table-scroll{ overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table{ min-width: 720px; }
}

/* Work Order theme — carbon-copy service ticket on canary paper.
   Printed form = Archivo Narrow caps in "form blue"; filled-in = Courier Prime
   in pencil-dark ink; stamps in red. */
:root{
  --desk:#e9e4d6; --paper:#fbf3c4; --paper-2:#f6eaa8; --print:#23408e; --ink:#262421;
  --stamp:#c0352b; --rule:rgba(35,64,142,.55); --faint:rgba(35,64,142,.18);
}
body{ margin:0; background:var(--desk); color:var(--ink); font:16px/1.55 'Courier Prime',ui-monospace,monospace; }
a{ color:inherit; }
.wo-label, .wo-nav a:not(.btn){
  font-family:'Archivo Narrow',ui-sans-serif,sans-serif; text-transform:uppercase; letter-spacing:.08em; color:var(--print);
}
.wo-label{ display:block; font-size:12px; font-weight:700; margin:0 0 6px; }

/* The sheet: perforated left margin + faint ruled carbon texture. */
.wo-sheet{
  position:relative; max-width:1040px; margin:28px auto; background:var(--paper);
  background-image:repeating-linear-gradient(0deg, transparent 0 31px, var(--faint) 31px 32px);
  box-shadow:0 1px 0 #d8cc8a, 0 18px 40px -18px rgba(60,50,10,.45);
  padding:0 34px 0 58px;
}
.wo-sheet::before{
  content:""; position:absolute; top:0; bottom:0; left:18px; width:14px;
  background:radial-gradient(circle at 7px 16px, var(--desk) 5px, transparent 5.5px) 0 0/14px 44px repeat-y;
}
.wo-sheet::after{ content:""; position:absolute; top:0; bottom:0; left:42px; border-left:1px dashed var(--rule); }

/* Header row */
.wo-head{ display:grid; grid-template-columns:1fr auto; align-items:center; gap:18px; padding:22px 0 14px; border-bottom:3px double var(--print); }
.wo-brand{ display:flex; align-items:center; gap:10px; text-decoration:none; font-weight:700; font-size:17px; }
.wo-brand img{ display:block; width:34px; height:34px; }
.wo-nav{ display:flex; align-items:center; gap:16px; flex-wrap:wrap; justify-content:flex-end; }
.wo-nav a:not(.btn){ font-size:14px; font-weight:700; text-decoration:none; padding:4px 0; border-bottom:2px solid transparent; }
.wo-nav a[aria-current="page"]{ border-color:var(--print); }

/* Stamp buttons: red rubber-stamp ink, slightly rotated, inked border. */
.btn, .wo-stamp{
  display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:8px 18px;
  font:700 15px/1 'Archivo Narrow',sans-serif; text-transform:uppercase; letter-spacing:.12em;
  color:var(--stamp); background:transparent; border:3px solid var(--stamp); border-radius:4px;
  text-decoration:none; cursor:pointer; transform:rotate(-1.5deg);
  box-shadow:inset 0 0 0 2px rgba(192,53,43,.12);
}
.btn:hover, .wo-stamp:hover{ background:var(--stamp); color:var(--paper); }
.btn.ghost{ color:var(--print); border-color:var(--print); transform:none; }
.btn.ghost:hover{ background:var(--print); color:var(--paper); }
.wo-stamp--big{ font-size:19px; padding:12px 22px; }

/* Top block: job / customer / photo, laid out as form fields. */
.wo-top{ display:grid; grid-template-columns:1.25fr 1fr; grid-template-areas:"job photo" "cust photo"; border-bottom:1px solid var(--print); }
.wo-field{ padding:16px 18px 18px 0; border-bottom:1px solid var(--print); }
.wo-field--job{ grid-area:job; }
.wo-field--job h1{ margin:0; font-size:30px; line-height:1.18; font-weight:700; }
.wo-field--customer, .wo-field--call{ grid-area:cust; border-bottom:0; align-self:end; }
.wo-zipform{ display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.wo-zipline{
  flex:1 1 180px; min-width:0; max-width:260px; height:46px; border:0; border-bottom:2px solid var(--ink);
  background:transparent; font:700 24px 'Courier Prime',monospace; letter-spacing:.3em; color:var(--ink); padding:0 4px;
}
.wo-zipline:focus{ outline:2px dashed var(--stamp); outline-offset:4px; }
.wo-zipline::placeholder{ color:rgba(38,36,33,.35); letter-spacing:.04em; }
.wo-photo{ grid-area:photo; position:relative; margin:16px 0 16px 18px; padding:8px 8px 4px; background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.18); transform:rotate(1.2deg); align-self:start; }
.wo-photo img{ display:block; width:100%; height:auto; aspect-ratio:4/3; object-fit:cover; }
.wo-photo::before{ /* staple */
  content:""; position:absolute; top:-6px; left:28px; width:38px; height:7px; border-radius:2px;
  background:linear-gradient(#bfc3c7,#8a8f94); transform:rotate(-8deg);
}

/* Body: description + numbered line items, estimate box on the right. */
main{ padding:22px 0 8px; }
.wo-body{ display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:26px; align-items:start; }
.wo-box{ margin:0 0 22px; }
.wo-box p{ margin:0 0 10px; }
.wo-box--desc p{ font-size:17px; }
.wo-items{ list-style:none; margin:0; padding:0; border-top:1px solid var(--print); }
.wo-item{ border-bottom:1px solid var(--print); }
.wo-item__text{ padding:12px 0 6px; }
.wo-item__text h2{ margin:0 0 6px; font-size:18px; line-height:1.3; }
.wo-item__text ul{ margin:0 0 10px; padding-left:20px; }
.wo-item__text li{ margin:0 0 4px; }
.wo-estimate{ position:sticky; top:104px; border:2px solid var(--print); background:var(--paper-2); padding:14px 16px 6px; }
.wo-estimate h2{ margin:0 0 8px; font-size:17px; line-height:1.3; }
.wo-estimate strong{ display:inline-block; font-size:21px; color:var(--stamp); border-bottom:2px solid var(--stamp); }

/* Service area */
.wo-area{ border-top:3px double var(--print); padding-top:14px; }
.wo-area h2{ margin:0 0 4px; font-size:20px; }
.muted{ color:#5b5747; font-size:14px; }
.city-group__title{ margin:18px 0 6px; font:700 13px 'Archivo Narrow',sans-serif; text-transform:uppercase; letter-spacing:.1em; color:var(--print); }
.city-grid{ list-style:none; margin:0; padding:0; columns:4 170px; column-gap:22px; }
.city-grid li{ break-inside:avoid; border-bottom:1px dotted var(--rule); }
.city-grid a{ display:block; padding:6px 0; text-decoration:none; font-size:14px; }
.city-grid a:hover{ color:var(--stamp); }
hr{ border:0; border-top:1px solid var(--print); }

/* Footer */
.wo-foot{ border-top:3px double var(--print); padding:18px 0 0; }
.wo-sign{ display:flex; align-items:flex-end; gap:24px; flex-wrap:wrap; }
.wo-foot__links{ margin:30px 0 4px; display:flex; gap:18px; font-size:14px; }
.wo-foot__copy{ margin:0 0 14px; font-size:14px; }

/* ---------- small screens ---------- */
@media (max-width:820px){
  .wo-sheet{ margin:0; padding:0 16px 0 34px; }
  .wo-sheet::before{ left:6px; }
  .wo-sheet::after{ left:26px; }
  .wo-head{ grid-template-columns:1fr auto; }
  .wo-nav{ gap:12px; }
  .wo-top{ grid-template-columns:1fr; grid-template-areas:"job" "cust" "photo"; }
  .wo-field{ padding-right:0; }
  .wo-field--job h1{ font-size:24px; }
  .wo-photo{ margin:14px 6px; }
  .wo-body{ grid-template-columns:1fr; }
  .wo-estimate{ position:static; }
}
@media (max-width:480px){
  .wo-head{ grid-template-columns:1fr; gap:10px; }
  .wo-nav{ justify-content:flex-start; }
}

/* =========================================================
   STANDALONE (estimate wizard + legal pages)
========================================================= */
.est-body{ background:var(--desk); }
.est-page{ min-height:100vh; display:grid; grid-template-rows:auto 1fr auto; max-width:1040px; margin:0 auto; background:var(--paper); }
.topbar--estimate{ border-bottom:3px double var(--print); padding:16px 24px; }
.topbar-inner--estimate{ display:flex; justify-content:center; }
.brand--estimate{ display:flex; align-items:center; gap:12px; text-decoration:none; font-weight:700; font-size:19px; }
.brand-logo--estimate{ display:block; width:40px; height:40px; }
.est-main{ padding:26px 24px 40px; }
.est-weave{ display:grid; grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr); gap:28px; align-items:start; }
.est-weave-media{ background:#fff; padding:8px; box-shadow:0 2px 6px rgba(0,0,0,.18); transform:rotate(-1deg); }
.est-weave-media img{ display:block; width:100%; height:auto; aspect-ratio:4/3; object-fit:cover; }
.est-shell{ min-width:0; }
.est-title{ margin:0 0 14px; font-size:28px; line-height:1.15; }
.est-form{ border:2px solid var(--print); background:var(--paper-2); padding:18px; }
.est-header{ margin-bottom:12px; }
.est-progress{ height:10px; border:1px solid var(--print); background:var(--paper); }
.est-bar{ height:100%; width:20%; background:repeating-linear-gradient(45deg, var(--print) 0 6px, #3d5bb0 6px 12px); transition:width .25s; }
.est-error{ margin:10px 0; padding:10px 12px; border:2px solid var(--stamp); color:var(--stamp); font-weight:700; }
.est-panel label{ display:block; margin:12px 0; font:700 13px 'Archivo Narrow',sans-serif; text-transform:uppercase; letter-spacing:.08em; color:var(--print); }
.est-panel input, .est-panel select, .est-panel textarea{
  display:block; width:100%; margin-top:6px; padding:10px 6px; border:0; border-bottom:2px solid var(--ink);
  background:transparent; font:17px 'Courier Prime',monospace; color:var(--ink); text-transform:none; letter-spacing:0;
}
.est-panel textarea{ border:2px solid var(--ink); resize:vertical; background:var(--paper); }
.est-panel input:focus, .est-panel select:focus, .est-panel textarea:focus{ outline:2px dashed var(--stamp); outline-offset:2px; }
.est-row{ display:grid; grid-template-columns:1fr 110px 110px; gap:12px; }
.est-tcpa{ margin:12px 0 0; font-size:11px; line-height:1.4; color:#5b5747; }
.est-actions{ display:flex; justify-content:space-between; gap:12px; margin-top:18px; }
.est-thanks{ padding:18px; border:3px solid var(--stamp); color:var(--stamp); font-weight:700; transform:rotate(-1deg); }
.legal-copy p{ margin:0 0 14px; font-size:15px; }
.est-page footer{ border-top:3px double var(--print); padding:14px 24px; text-align:center; font-size:14px; }
@media (max-width:820px){
  .est-weave{ grid-template-columns:1fr; }
  .est-weave-media{ transform:none; }
  .est-row{ grid-template-columns:1fr; }
}

/* keep a wide (min-width:720px) cost table from widening its grid column;
   it scrolls inside its wrapper instead */
.table-scroll{ contain:inline-size; }

/* ---------- sticky header row ----------
   The brand/nav row stays pinned to the top of the sheet while it scrolls.
   It carries the sheet's own ruled paper, so at rest it is invisible as a
   separate strip; a soft shadow fades in once content passes under it. */
.wo-head{
  position:sticky; top:0; z-index:50; background:var(--paper);
  background-image:repeating-linear-gradient(0deg, transparent 0 31px, var(--faint) 31px 32px);
}
.topbar--estimate{ position:sticky; top:0; z-index:50; background:var(--paper); }
@supports (animation-timeline: scroll()){
  .wo-head, .topbar--estimate{ animation:wo-lift linear both; animation-timeline:scroll(root); animation-range:0 80px; }
  @keyframes wo-lift{ to{ box-shadow:0 12px 14px -14px rgba(60,50,10,.6); } }
}
@supports not (animation-timeline: scroll()){
  .wo-head, .topbar--estimate{ box-shadow:0 12px 14px -14px rgba(60,50,10,.6); }
}
