/*
 * Hexicor proposal portal — port of the styling from
 * cr4b9_proposalindexhtml v1.11.70.2 (the D365 template's renderer).
 * Editor-time machinery (toolbars, drag handles, contenteditable) was
 * intentionally left behind; what's kept is the brand identity, the
 * paper-card layout, and the Tiptap-content output rules.
 *
 * See docs/renderer-port-plan.md for the full keep/drop ledger.
 */

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Design tokens (brand colours, fonts, radii, --sidebar-width, @font-face) live
   in tokens.css, loaded BEFORE this file on every page. Restyle the brand there;
   this file is layout/components only. */

html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { color: var(--navy); font-weight: 700; }
h1 { font-size: 2rem; line-height: 1.2; }
h2 { font-size: 1.4rem; margin-bottom: .75rem; }
h3 { font-size: 1.1rem; }

.muted { color: var(--text-muted); font-size: .9rem; }
.error-text { color: var(--error); }

/* ===== SITE HEADER ===== */
.site-header {
  display: flex;
  align-items: center;
  background: #fff;
  height: 72px;
  overflow: hidden;
}

.site-header-accent {
  flex-shrink: 0;
  width: 16px;
  align-self: stretch;
  background: var(--grad-spine);
  margin-right: auto;
}

.site-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 40px;
}

.hx-icon {
  height: 46px;
  width: auto;
  flex-shrink: 0;
}

/* Real Hexicor full-colour wordmark (PNG) in the header + on the cover */
.hx-logo { height: 38px; width: auto; display: block; flex-shrink: 0; }

.hx-wordmark {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  user-select: none;
}

.hx-name {
  font-family: var(--font);
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.hx-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  /* Align to baseline of hx-name */
  position: relative;
  bottom: 1px;
}

/* ===== SITE FOOTER ===== */
.site-footer {
  /* fallback for older browsers that don't support color-mix() */
  background: #EEF9FB;
  background: color-mix(in srgb, var(--teal) 5%, #fff);
  /* sticky footer: pinned to the bottom of the viewport on short pages
     (loading / error / signed / short proposals) via the flex-column body. */
  margin-top: auto;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  min-height: 100px;
  padding: 0;
  gap: 0;
}

/* Left: regions text with watermark hex */
.site-footer-left {
  position: relative;
  flex: 1 1 55%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  overflow: hidden;
  padding: 16px 32px;
}

.site-footer-wm {
  position: absolute;
  width: 120px;
  height: 120px;
  object-fit: contain;
  opacity: 0.08;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.site-footer-regions {
  position: relative;          /* above watermark */
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--navy);
  text-align: center;
  line-height: 1.4;
}

/* Vertical separator */
.site-footer-sep {
  flex-shrink: 0;
  width: 1px;
  align-self: stretch;
  background: var(--teal-light);
  margin: 16px 0;
}

/* Right: hex icon + contact list */
.site-footer-right {
  flex: 1 1 45%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
}

.hx-icon--footer {
  height: 50px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.site-footer-contact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.site-footer-contact li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--navy);
  line-height: 1.3;
}

.fc-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.fc-lbl {
  color: var(--teal);
  font-weight: 700;
}

/* ===== PAPER CARD (each section sits on one) ===== */
.paper {
  max-width: var(--max-width);
  margin: 0 auto 24px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 48px 56px;
}
@media (max-width: 720px) {
  .paper { padding: 28px 20px; border-radius: 0; }
}

/* ===== STATE SCREENS =====
   The `[hidden]` HTML attribute should hide elements by default via the UA
   stylesheet, but flex/grid parents and any subsequent rule that touches
   `display` can override it. Lock it down at high specificity so showState()
   reliably hides the inactive state divs.
*/
[hidden] { display: none !important; }

.state-screen {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== COVER ===== */
/* Brand network constellation (bg-hero-network.png, transparent) anchored right
   on a white paper card; a left-to-transparent white scrim keeps the navy title
   crisp on the left while the network fades in on the right. */
.paper.cover {
  position: relative;
  overflow: hidden;
  background: #fff;
  min-height: 420px;
  padding: 56px 56px 64px;
}
/* Brand network constellation fades in from the right behind a crisp navy title.
   Dedicated layers (robust compositing): image layer + white scrim. */
.cover-art {
  position: absolute; inset: 0; z-index: 0;
  background: url('/assets/bg-hero-network.png') right center / cover no-repeat;
}
.paper.cover::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, #ffffff 0%, #ffffff 44%, rgba(255,255,255,0.78) 60%, rgba(255,255,255,0.18) 80%, rgba(255,255,255,0) 100%);
}
.paper.cover > * { position: relative; z-index: 2; }
.paper.cover > .cover-art { position: absolute; inset: 0; z-index: 0; }
.cover-logo { height: 40px; width: auto; display: block; margin-bottom: 26px; }
.cover-eyebrow {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
  margin-bottom: 8px;
}
.cover-title { font-size: 2.2rem; line-height: 1.15; color: var(--navy); margin-bottom: 16px; max-width: 18ch; }
.cover-subtitle { color: var(--text-muted); margin-bottom: 32px; max-width: 38ch; }
.cover-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
  max-width: 460px;
}
.cover-meta-block h4 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.cover-meta-block p { font-size: 14px; color: var(--navy); }

/* ===== INVESTMENT SUMMARY ===== */
.investment-summary { padding-top: 32px; }
.investment-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 32px;
  font-size: 1rem;
  margin-top: 16px;
}
.investment-grid .label { color: var(--text-muted); }
.investment-grid .value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.investment-grid .grand-label,
.investment-grid .grand-value {
  font-size: 1.4rem;
  color: var(--navy);
  border-top: 2px solid var(--teal);
  padding-top: 12px;
  margin-top: 8px;
  font-weight: 600;
}
/* totalsLayout variants — chosen by data-layout attribute on .investment-summary */
.investment-summary[data-layout="2"] .investment-grid {
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  font-size: .9rem;
}
.investment-summary[data-layout="2"] .investment-grid .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.investment-summary[data-layout="2"] .investment-grid .value { font-size: 1.5rem; text-align: center; }
.investment-summary[data-layout="2"] .investment-grid .grand-label,
.investment-summary[data-layout="2"] .investment-grid .grand-value { border-top: none; padding-top: 0; margin-top: 0; }
.investment-summary[data-layout="3"] .investment-grid { font-size: .9rem; }
.investment-summary[data-layout="3"] .grand-value { font-size: 1.7rem; }

/* ===== PRICING GROUPS ===== */
/* HEXICOR-PS-SPACING-1402 (#1): the Professional Services container gets the same column/gap card
   spacing as Product Details so the two sections render identically. */
#groups, #ps-groups { display: flex; flex-direction: column; gap: 24px; }
.pricing-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
}
.pricing-group-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: var(--hx-head-weight);
}
.pricing-group-header .group-subtotal { font-variant-numeric: tabular-nums; display: inline-flex; align-items: baseline; gap: 8px; }
.pricing-group-header .gs-note { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--teal-mid); font-weight: 600; opacity: .9; }
.pricing-group-type {
  display: inline-block;
  margin-left: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--teal-mid);
  font-weight: 600;
}
.pricing-table { width: 100%; border-collapse: collapse; }
.pricing-table th, .pricing-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: .92rem;
  vertical-align: top;
}
.pricing-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
}
.pricing-table td.num, .pricing-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pricing-table tr:last-child td { border-bottom: none; }
/* Per-line product description is rich HTML (parity with the PDF's product-desc-rich).
   Keep block content tight so long spec lists don't blow out the row height. */
.line-desc > :first-child { margin-top: 0; }
.line-desc > :last-child { margin-bottom: 0; }
.line-desc p { margin: 0 0 4px; }
.line-desc ul, .line-desc ol { margin: 4px 0; padding-left: 18px; }
.line-desc li { margin: 0 0 2px; }
.line-desc a { color: var(--teal); text-decoration: underline; }

/* ===== INTERNAL PREVIEW (/preview/{id}) =====
   Amber ribbon pinned above everything so a screenshot of a preview can never
   be mistaken for (or forwarded as) the customer link. */
.preview-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fde68a;
  color: #78350f;
  border-bottom: 1px solid #f59e0b;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 8px 16px;
}

/* ===== BUNDLES (builder parity) =====
   One host row per bundle (label + optional description + "N items included"
   + ex-GST rollup); members indent beneath only when the rep chose to show
   them (itemDisplay qty_only / qty_and_price). */
.bundle-label { font-weight: 600; }
.bundle-desc { margin-top: 2px; font-size: .86em; color: var(--text-muted); }
.bundle-itemcount { margin-top: 2px; font-size: .8em; color: var(--text-muted); }
.bundle-member .bundle-member-name { padding-left: 14px; }
.bundle-member-indent { color: var(--text-muted); margin-right: 6px; }
/* v1.13.87 #2: per-member description under the name (builder parity) */
.bundle-member-desc { margin-top: 2px; margin-left: 20px; font-size: .82em; color: var(--text-muted); line-height: 1.4; }
.bundle-member-desc p { margin: 0 0 3px; } .bundle-member-desc p:last-child { margin-bottom: 0; }
.bundle-member-desc ul, .bundle-member-desc ol { margin: 3px 0 3px 16px; padding: 0; }
/* v1.13.88 #3: Professional Services sub-heading + optional pod (builder parity) */
.pricing-subsection-heading { margin: 28px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 1.05em; font-weight: 700; color: var(--text); }
.profservices-pod { margin: 0 0 16px; color: var(--text); }
.profservices-pod p { margin: 0 0 8px; } .profservices-pod p:last-child { margin-bottom: 0; }
.profservices-pod ul, .profservices-pod ol { margin: 6px 0 6px 20px; padding: 0; }
/* v1.13.89 #6: cosmetic agreement-credit row — badge + effective date + accounting-negative cue.
   print-color-adjust: exact keeps the tint + badge background in the PDF (browsers strip element
   backgrounds on print by default) — without it the credit reads as a plain line. (2026-06-23 salvage #5) */
.agreement-credit-row > td { background: rgba(180,83,9,0.035); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.agreement-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 3px; }
.agreement-badge { font-size: .68em; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.agreement-effective { font-size: .8em; color: var(--text-muted); }
.credit-amt { color: #DC2626; }
/* v1.13.92: opt-in "From <date> you'll pay $X" projected group total under an agreement credit */
.agreement-projected-row > td { background: rgba(180,83,9,0.035); border-top: 0; padding-top: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.agreement-projected-row .projected-label { font-size: .85em; font-style: italic; color: var(--text-muted); }
.agreement-projected-row .projected-amt { font-weight: 700; color: var(--navy); }
.pricing-table td.bundle-muted { color: var(--text-muted); }

/* ===== OPTIONAL ITEMS (portal-1.2.0) ===== */
/* Banner row introducing a PickOne/PickAny set, followed by the items
   themselves (each rendered with .optional-row + an input in the
   description cell). */
.optional-set-banner td {
  background: var(--teal-light);
  font-size: 11px;
  color: var(--navy);
  padding: 12px 16px;
  border-top: 2px solid var(--teal);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.optional-set-banner .optional-set-label {
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.3px;
  font-size: 13px;
}
.optional-set-banner .optional-set-mode {
  display: inline-block;
  margin-right: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.optional-set-banner .optional-set-hint {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}
.optional-set-banner .optional-set-impact {
  float: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--teal);
}
.optional-set-banner .optional-set-impact.none-selected {
  color: var(--text-muted);
  border-color: var(--border);
  font-weight: 500;
}
/* The whole set reads as one contained "your choice" band: a teal rule runs
   down the left edge of the banner + every row in the set, and picked rows
   carry a light tint so the selected state is unmissable. */
.optional-set-banner td,
.optional-row td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.optional-row.selected td { background: rgba(0, 151, 178, 0.06); }
.optional-row td:first-child { padding-left: 24px; }
.optional-row .optional-pick {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.optional-row .optional-pick input {
  margin-top: 3px;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
  width: 20px;   /* comfortable touch target on mobile */
  height: 20px;
}
/* Customer has not picked this row — dim it and strike the money figures so
   the running totals visibly exclude it. The input stays full-opacity so the
   control still reads as actionable. */
.optional-row.deselected td { opacity: .55; }
.optional-row.deselected td:first-child { opacity: 1; }
.optional-row.deselected .optional-pick span,
.optional-row.deselected .recurring-amount { opacity: .55; }
.optional-row.deselected td.num:last-child { text-decoration: line-through; }
.recurring-amount {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== LINE-DESCRIPTION ACCORDIONS =====
   Rich/long descriptions collapse behind a native <details>: the product name
   is the always-visible <summary>; print opens everything (beforeprint hook in
   render-core.js). Optional rows put the <details> BELOW the pick label so the
   toggle never fights the checkbox/radio. */
.line-detail { margin: 0; }
.line-detail > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.line-detail > summary::-webkit-details-marker { display: none; }
.line-detail > summary::after {
  content: "▸";
  font-size: 11px;
  color: var(--teal);
  transition: transform .15s ease;
}
.line-detail[open] > summary::after { transform: rotate(90deg); }
.line-detail > summary:hover { color: var(--teal); }
.line-detail .line-detail-body {
  margin-top: 6px;
  font-weight: 400;
  font-size: .92em;
  color: var(--text);
}
.line-detail.optional-detail { margin: 4px 0 0 28px; }
.line-detail.optional-detail > summary {
  font-weight: 500;
  font-size: 12px;
  color: var(--teal);
}

@media print {
  .line-detail > summary { cursor: default; }
  .line-detail > summary::after { display: none; }
  .line-detail.optional-detail > summary { display: none; }
}

.pricing-section-note {
  padding: 12px 16px;
  background: rgba(0,151,178,0.04);
  border-top: 1px solid var(--border-light);
  font-size: .9rem;
  color: var(--text);
}

/* ===== TIPTAP-RENDERED CONTENT (ported verbatim from source 4523+) ===== */
.tiptap-content u { text-decoration: underline; }
.tiptap-content s { text-decoration: line-through; }
.tiptap-content blockquote {
  border-left: 3px solid var(--teal);
  padding: 4px 14px;
  color: var(--text-muted);
  margin: 12px 0;
  background: rgba(0,151,178,0.04);
  border-radius: 0 6px 6px 0;
}
.tiptap-content a, .tiptap-link {
  color: var(--teal);
  text-decoration: underline;
}
.tiptap-content mark, .tiptap-highlight {
  background: rgba(250,199,117,0.5);
  padding: 0 2px;
  border-radius: 2px;
}
.tiptap-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.tiptap-content p { margin-bottom: 10px; }
.tiptap-content p:last-child { margin-bottom: 0; }
.tiptap-content ul, .tiptap-content ol { padding-left: 22px; margin-bottom: 10px; }
.tiptap-content h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--navy); }

/* HEXICOR-RICH-TABLE-1402 (#6b): tables in rich-text content (cover letter, line-description accordions)
   render bordered — parity with the builder/PDF. Scoped to both .tiptap-content and .line-detail-body. */
.tiptap-content table, .line-detail-body table { border-collapse: collapse; table-layout: fixed; width: 100%; margin: 12px 0; }
.tiptap-content table td, .tiptap-content table th,
.line-detail-body table td, .line-detail-body table th { border: 1px solid var(--border, #cbd5e1); padding: 6px 9px; vertical-align: top; box-sizing: border-box; font-size: .92em; line-height: 1.45; text-align: left; }
.tiptap-content table th, .line-detail-body table th { background: rgba(0,0,0,0.035); font-weight: 600; }
.tiptap-content table p, .line-detail-body table p { margin: 0; }
@media print {
  .tiptap-content table td, .tiptap-content table th,
  .line-detail-body table td, .line-detail-body table th { border: 1px solid #94a3b8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tiptap-content table th, .line-detail-body table th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== ACTION BAR (sign / decline) ===== */
#action-bar {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  box-shadow: 0 -4px 12px rgba(0,0,0,.05);
  z-index: 10;
}

/* ===== BUTTONS ===== */
button {
  font: inherit;
  padding: .65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--paper); color: var(--text); border-color: var(--border); }
.btn-link { background: none; border: none; color: var(--teal); cursor: pointer; padding: 0; text-decoration: underline; }

/* ===== SIGN MODAL ===== */
#sign-modal {
  border: none; border-radius: var(--radius); padding: 0;
  width: min(540px, 92vw); max-width: 540px; max-height: 92vh;
  margin: auto; overflow: hidden; box-shadow: 0 30px 80px rgba(0,37,83,.38);
}
#sign-modal::backdrop { background: rgba(0,18,45,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
#sign-modal[open] { animation: signIn .22s cubic-bezier(.16,.84,.44,1); }
@keyframes signIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
#sign-form { padding: 0; display: flex; flex-direction: column; max-height: 92vh; }
.sign-head { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 55%, var(--blue) 140%); color: #fff; padding: 24px 28px; flex-shrink: 0; }
.sign-head h2 { color: #fff; margin: 0 0 5px; font-size: 1.3rem; font-weight: 700; }
.sign-head p { margin: 0; font-size: .85rem; line-height: 1.55; color: rgba(255,255,255,.82); font-weight: 400; }
.sign-head strong { color: #fff; font-weight: 600; }
.sign-body { padding: 22px 28px 24px; overflow-y: auto; }
#sign-form label { display: block; margin: 0 0 .3rem; font-weight: 600; font-size: 13px; color: var(--navy); }
.sign-field + .sign-field { margin-top: 15px; }
#sign-form label.checkbox { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; font-size: 13px; color: var(--text); margin: 18px 0 0; }
#sign-form label.checkbox input { margin-top: 3px; accent-color: var(--teal); flex-shrink: 0; }
#sign-form input[type="text"], #sign-form input[type="email"] {
  width: 100%; padding: .62rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); outline: none; background: #fff; transition: border-color .15s, box-shadow .15s;
}
#sign-form input[type="text"]:focus, #sign-form input[type="email"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(1,141,205,.14); }
.signature-pad-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .6rem .55rem; margin: 16px 0 0; }
.signature-pad-wrap legend { padding: 0 .4rem; color: var(--text-muted); font-size: .8rem; font-weight: 500; }
#sig-pad { background: #fff; width: 100%; height: 150px; border: 1px dashed var(--border); border-radius: 4px; cursor: crosshair; touch-action: none; display: block; }
#sig-clear { margin-top: 6px; }
.legal-notice { font-size: .78rem; line-height: 1.5; margin-top: 14px; }
#sig-error { margin-top: 12px; font-size: .85rem; }
dialog menu {
  display: flex; justify-content: flex-end; gap: .65rem; margin: 20px 0 0; padding: 0;
}

/* Signature pad footer: hint + Clear on one row under the canvas */
.sig-pad-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.sig-hint { font-size: .76rem; }
.sig-pad-foot #sig-clear { margin-top: 0; }

/* ===== DECLINE MODAL (reuses .sign-head / .sign-body / dialog menu) ===== */
#decline-modal {
  border: none; border-radius: var(--radius); padding: 0;
  width: min(480px, 92vw); max-width: 480px; max-height: 92vh;
  margin: auto; overflow: hidden; box-shadow: 0 30px 80px rgba(0,37,83,.38);
}
#decline-modal::backdrop { background: rgba(0,18,45,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
#decline-modal[open] { animation: signIn .22s cubic-bezier(.16,.84,.44,1); }
#decline-modal form { padding: 0; display: flex; flex-direction: column; max-height: 92vh; }
#decline-modal label { display: block; margin: 0 0 .3rem; font-weight: 600; font-size: 13px; color: var(--navy); }
#decline-modal textarea {
  width: 100%; padding: .62rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); outline: none; background: #fff; resize: vertical; min-height: 64px;
  transition: border-color .15s, box-shadow .15s;
}
#decline-modal textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(1,141,205,.14); }

/* Destructive-action button (decline confirm) — base shape from `button {}` above */
.btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-danger:hover { filter: brightness(1.06); }

/* ===== STATIC LEGAL PAGES (/privacy, /terms) ===== */
.legal-page {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--paper);
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.legal-page h2 { margin-top: 1.75rem; }
.legal-page p { margin: .5rem 0 .75rem; }

/* ===== FINANCING (portal-1.3.0, ported from template v1.11.70.2 lines 2726+) ===== */
.financing-name {
  margin-bottom: 12px;
  font-size: 13px;
}
.financing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.financing-table thead th {
  background: var(--border-light);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
}
.financing-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
.financing-table tbody tr:last-child td { border-bottom: none; }

/* ===== QUOTE NOTES (portal-1.3.0) ===== */
.quote-notes .notes-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.25rem 0;
}

/* ===== PRINT ===== */
@media print {
  body { background: white; }
  .site-header, .site-footer, #action-bar { display: none; }
  .paper { box-shadow: none; border-radius: 0; padding: 24px; margin-bottom: 0; }
  .pricing-group { break-inside: avoid; }
  /* Builder "force page break before this group" (template v1.13.84). First group exempt so the
     "Product Details" heading isn't orphaned onto the previous page. */
  .pricing-group[data-pagebreak="before"] { break-before: page; page-break-before: always; }
  #groups > .pricing-group:first-child[data-pagebreak="before"] { break-before: avoid; page-break-before: avoid; }
  .tiptap-content blockquote {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* =====================================================================
   ACTIVATED REDESIGN (portal-1.4.0)
   Additive layer on top of the brand CSS above. Adds: header status
   pill, sticky TOC sidebar, numbered/accented section heads, a larger
   investment grand-total, gradient pricing headers + hover, and a
   floating glass action bar. No base rule is removed; the three
   investment-summary data-layout variants and all optional-item /
   financing / tiptap rules are untouched. See
   docs/activated-redesign-plan.md.
   ===================================================================== */

/* --sidebar-width lives in tokens.css */

/* leave clearance for the floating (fixed) action bar */
/* flex-column body makes the footer (margin-top:auto) sit at the bottom of the
   viewport on short pages instead of riding up under the content. */
body { padding-bottom: 96px; min-height: 100vh; display: flex; flex-direction: column; }

/* ----- header: logo left, status pill + quote ref right ----- */
.site-header-accent { margin-right: 0; }
.site-header-logo { padding-right: 0; padding-left: 20px; }
.header-right {
  margin-left: auto;
  padding-right: 40px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,151,178,0.10);
  color: var(--teal);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-pill .dot {
  width: 7px; height: 7px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0,151,178,0.18);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(0,151,178,0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(0,151,178,0); }
}
.header-ref {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ----- two-column grid: sticky sidebar + proposal ----- */
.with-sidebar {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  max-width: 1260px;
  margin: 0 auto;
  align-items: start;
}
.with-sidebar #proposal { min-width: 0; padding-right: 24px; }

.proposal-sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 8px 24px 8px 32px;
  display: flex;
  flex-direction: column;
}
.sidebar-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 16px;
}
.toc { display: flex; flex-direction: column; gap: 2px; margin-bottom: 24px; }
.toc a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--navy-light);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.toc a:hover { background: rgba(0,151,178,0.06); color: var(--navy); }
.toc a.active {
  background: rgba(0,151,178,0.10);
  color: var(--teal);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--teal);
}
.toc a .num {
  font-size: 10px;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  width: 16px;
  flex-shrink: 0;
}
.toc a.active .num { color: var(--teal); }
/* HEXICOR-NAVGROUPS: per-group sub-bookmarks — indented, lighter, marker dot, no number */
.toc a.toc-sub {
  padding-left: 34px;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
}
.toc a.toc-sub > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc a.toc-sub::before {
  content: "";
  flex: 0 0 auto;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.toc a.toc-sub:hover { color: var(--navy); }
.toc a.toc-sub.active { color: var(--teal); font-weight: 600; }
/* anchor jumps to a group land just below the top edge (sticky header clearance) */
.pricing-group { scroll-margin-top: 24px; }

.sidebar-meta {
  margin-top: auto;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-muted);
}
.sidebar-meta .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.sidebar-meta .row b { color: var(--navy); font-weight: 600; text-align: right; }
.sidebar-meta .stamp {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

/* anchor jumps shouldn't tuck the section heading under the viewport top */
.paper { scroll-margin-top: 24px; }

/* ----- section heads: numbered badge + teal accent line ----- */
.paper > h2 {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  font-weight: var(--hx-head-weight);
}
.paper > h2::before {
  content: attr(data-num);
  font-size: 11px;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  background: rgba(0,151,178,0.10);
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}
/* no badge until JS assigns a (gap-free) number to a visible section */
.paper > h2:not([data-num])::before { display: none; }
.paper > h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 28px;
  height: 2px;
  background: var(--teal);
  border-radius: 2px;
}

/* ----- investment: larger teal grand-total on the default layout 1
   (layout 2 / layout 3 keep their own, more-specific sizing) ----- */
.investment-summary[data-layout="1"] .investment-grid .grand-value,
.investment-summary:not([data-layout]) .investment-grid .grand-value {
  font-size: 1.8rem;
  line-height: 1.1;
  color: var(--blue);
  letter-spacing: -0.015em;
  font-weight: 700;
  white-space: nowrap;
}
.investment-summary[data-layout="1"] .investment-grid .grand-label {
  align-self: center;
  font-weight: 500;
}
/* split: one-time vs recurring, never combined (each ex-GST -> GST -> total inc) */
.totals-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; align-items: stretch; }
.totals-split.single { grid-template-columns: 1fr; max-width: 520px; }
/* Equal cards: both blocks stretch to the same height, the Total row pins to
   the bottom of each, and the grand figures share one size — the one-time and
   recurring boxes read as a matched pair instead of two different shapes. */
.totals-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px 22px; background: var(--paper); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.totals-block .investment-grid { flex: 1; grid-template-rows: auto auto 1fr; }
.totals-block .investment-grid .grand-label,
.totals-block .investment-grid .grand-value { align-self: end; }
.totals-block .investment-grid .grand-value { font-size: 1.5rem !important; }
.totals-block--rec { background: var(--bg); }
.totals-block-head { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--teal); margin-bottom: 12px; }
.totals-block .investment-grid { margin-top: 0; font-size: .9rem; }
.totals-block .investment-grid .label, .totals-block .investment-grid .value { white-space: nowrap; }
.totals-block .investment-grid .grand-label { white-space: nowrap; font-size: .95rem; }
.totals-block--rec .grand-value { font-size: 1.5rem !important; color: var(--teal) !important; white-space: nowrap; }
@media (max-width: 720px) { .totals-split { grid-template-columns: 1fr; } }

/* ----- pricing groups: gradient header, pill type-tag, hover lift ----- */
.pricing-group { transition: box-shadow 0.2s ease; }
.pricing-group:hover { box-shadow: var(--shadow-lg); }
.pricing-group-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}
.pricing-group-type {
  background: rgba(93,224,230,0.15);
  color: var(--teal-mid);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ----- primary button: gradient + lift ----- */
.btn-primary {
  background: var(--grad-pill);
  box-shadow: 0 2px 0 rgba(255,255,255,0.15) inset, 0 4px 14px rgba(1,141,205,0.28);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  filter: none;
  box-shadow: 0 2px 0 rgba(255,255,255,0.15) inset, 0 8px 22px rgba(1,141,205,0.38);
}

/* ----- floating glass action bar ----- */
#action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  max-width: calc(100vw - 48px);
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  background: rgba(255,255,255,0.85);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px 12px 24px;
  box-shadow: 0 16px 48px rgba(15,23,42,0.15);
}
.action-bar-info { font-size: 13px; color: var(--text-muted); }
.action-bar-buttons { display: flex; gap: 12px; flex-shrink: 0; align-items: center; }
.action-bar-status { font-size: 13px; max-width: 200px; line-height: 1.3; }
button:disabled { opacity: .6; cursor: default; }

/* ----- responsive: collapse the sidebar, edge-to-edge action bar ----- */
@media (max-width: 1024px) {
  .with-sidebar { display: block; max-width: var(--max-width); }
  .proposal-sidebar { display: none; }
  .with-sidebar #proposal { padding-right: 0; }
  #action-bar {
    left: 16px;
    right: 16px;
    transform: none;
    max-width: none;
  }
}
@media (max-width: 560px) {
  .action-bar-info { display: none; }
  /* Stack the actions so the customer isn't faced with three look-alike pills:
     a full-width primary "Accept & Sign" with the secondary Download / Decline
     sharing the row above it. Tap targets kept ≥44px tall. */
  #action-bar {
    left: 8px; right: 8px; bottom: 8px;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }
  .action-bar-buttons { width: 100%; flex-wrap: wrap; gap: 10px; }
  #download-status { order: 0; flex: 1 0 100%; max-width: none; text-align: center; }
  #btn-download-presign, #btn-decline { order: 1; flex: 1 1 0; text-align: center; padding: .72rem 1rem; }
  #btn-accept { order: 2; flex: 1 0 100%; text-align: center; padding: .85rem 1.4rem; }
}

/* ----- reduce motion: kill the pulsing dot ----- */
@media (prefers-reduced-motion: reduce) {
  .status-pill .dot { animation: none; }
}

/* ----- print: hide the activated chrome, restore single column ----- */
@media print {
  .proposal-sidebar, .header-right, #action-bar { display: none; }
  .with-sidebar { display: block; }
  .with-sidebar #proposal { padding-right: 0; }
  body { padding-bottom: 0; }
}

/* =====================================================================
   ANALYTICS CONSENT BANNER (Microsoft Clarity gate)
   Bottom-left toast revealed by /vendor/clarity-init.js only when the
   visitor hasn't chosen yet. Reuses .btn-primary / .btn-ghost. On narrow
   screens it sits ABOVE the floating #action-bar so they never collide.
   ===================================================================== */
.consent-banner {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 1100;            /* above #action-bar (z-index: 10) */
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
/* keep the `hidden` attribute authoritative despite display:flex above */
.consent-banner[hidden] { display: none; }
.consent-text {
  margin: 0;
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.consent-text strong { color: var(--text); }
.consent-text a { color: var(--teal); }
.consent-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}
.consent-actions .btn-primary,
.consent-actions .btn-ghost {
  padding: .5rem 1rem;
  font-size: .8125rem;
}

@media (max-width: 1024px) {
  .consent-banner {
    left: 16px;
    right: 16px;
    max-width: none;
    bottom: 6.5rem;         /* clear the edge-to-edge floating action bar */
  }
}

@media print {
  .consent-banner { display: none; }
}

/* ===== BUILDER-AUTHORED IMAGES =====
   Annotation-resolved (img[data-hex-annotation] → /api/quote-image) or external
   https images inside rich content. Constrained so a full-size product shot
   can't blow out the layout; src-less (unresolved) images collapse. */
#cover-letter-body img,
#exec-summary-body img,
.quote-note img,
.line-desc img,
.line-detail-body img,
.pricing-section-note img,
#terms-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
img.hex-annotation-img:not([src]) { display: none; }

/* ===== DEPOSIT DUE STRIP =====
   "Due upfront (N% deposit): $X" under the Investment Summary blocks — driven
   by the builder's Terms deposit toggle (terms-deposit + deposit-pct section
   notes). Figure tracks the live one-time total as optional picks change. */
.deposit-due {
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--teal-light);
  border: 1px solid var(--teal);
  color: var(--navy);
  font-weight: 700;
  font-size: 14px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ===== TERMS: subheadings + the bold deposit clause (builder parity) ===== */
#terms-body h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--navy); }
#terms-body p { margin-bottom: 12px; }
#terms-body .terms-deposit-clause { font-weight: 700; color: var(--navy); margin-top: 16px; }

/* ===== COVER LETTER salutation (builder parity) ===== */
.cover-letter-salutation { font-weight: 600; margin-bottom: 12px; }

/* ===== CUSTOM SECTIONS (template v1.13.77) =====
   Rep-authored Tiptap sections persisted as layout.customTitles + sectionNotes;
   rendered on /q as a paper card matching the fixed sections (numbered <h2> badge
   via buildSidebar's data-num, sanitised rich-text body). */
.custom-section .custom-section-body {
  margin-top: 12px;
}
.custom-section .custom-section-body:empty { display: none; }

/* ===== OPTIONAL GROUPS / EITHER-OR SETS (portal-1.5.0) =====
   A whole pricing group can be customer-selectable: one header control toggles
   all its eligible member rows together (the member rows reuse the existing
   .optional-row striking). Either-or sets render a radio per group (single choice
   across the set, enforced document-wide). */
.optional-unit-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  background: var(--teal-light);
  border: 1px solid var(--teal);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.optional-unit-control input { cursor: pointer; margin: 0; }
.pricing-group.optional-unit.deselected { opacity: 0.62; }
.pricing-group.optional-unit.deselected .optional-unit-control {
  background: transparent;
  color: var(--text-muted);
}
@media print {
  /* The signed PDF bakes in the customer's choice (struck rows) — the interactive
     toggle is meaningless there. Hide it; keep the rows at full opacity. */
  .optional-unit-control { display: none; }
  .pricing-group.optional-unit.deselected { opacity: 1; }
}

/* ───── Attachments section (rep-shared "[Portal]" files) ───── */
.attachments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.attachment-name { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.attachment-meta { overflow-wrap: anywhere; }
.attachment-download {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}
@media print {
  /* Download links are meaningless on paper / in the PDF. */
  .attachments { display: none; }
}
