/* Mobile-first, minimal. */
:root { --brand: #1b3a5b; --accent: #1b3a5b; --side-w: 0px; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #1b1f24;
  background: #f5f6f8;
}
a { color: #1a5fb4; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .75rem 1rem;
  background: var(--brand); color: #fff;
}
.topbar a, .topbar .role { color: #fff; }
.topbar .brand { font-weight: 700; font-size: 1.1rem; display: inline-flex; align-items: center; gap: .5rem; }
.brandlogo { height: 24px; width: auto; border-radius: 4px; background: #fff; }
.herologo { height: 64px; width: auto; margin-bottom: .5rem; }
.topbar nav { display: flex; align-items: center; gap: 1rem; }
/* Marketing (no-role) header: white bar so the contractor's own logo reads. */
.topbar-light { background: #fff; color: var(--brand); border-bottom: 1px solid #e6e8ec; }
.topbar-light a, .topbar-light .role, .topbar-light .brand { color: var(--brand); }
.topbar-light .brandlogo { background: transparent; border-radius: 0; height: 30px; }
.role { opacity: .8; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
/* Hamburger nav toggle: hidden on desktop, collapses the menu on mobile. */
.navtoggle { display: none; flex-direction: column; justify-content: center; gap: 4px; width: 42px; height: 38px; padding: 8px 9px; background: transparent; border: 1px solid currentColor; border-radius: 6px; color: inherit; cursor: pointer; }
.navtoggle span { display: block; width: 100%; height: 2px; background: currentColor; border-radius: 2px; }
@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; }
  .navtoggle { display: inline-flex; }
  .topbar nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; margin-top: .5rem; }
  .topbar nav.open { display: flex; }
  .topbar nav > * { padding: .6rem .25rem; border-top: 1px solid rgba(127,127,127,.22); }
  .topbar nav form.inline { display: block; }
}
.navbadge { background: #e11d48; color: #fff; border-radius: 999px; padding: 0 .4rem; font-size: .75rem; }
.card.unread { border-left: 3px solid #1a5fb4; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem; }

/* Header row: title on the left, primary action on the right */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1 { margin: .2rem 0; }
.crumb { margin: 0 0 .25rem; }

/* Two-column layout (main + sidebar) on wider screens; stacks on mobile */
.layout { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 820px) {
  .layout { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
  .sidebar { position: sticky; top: 1rem; }
}

/* Forms read better constrained */
.formcard { max-width: 680px; }

/* Definition list for sidebar facts */
.facts { margin: 0; }
.facts dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; margin-top: .5rem; }
.facts dd { margin: 0; }

h1 { font-size: 1.4rem; margin: .2rem 0 1rem; }
h2 { font-size: 1rem; margin: 0 0 .5rem; color: #444; }
.muted { color: #6b7280; }

.card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 1rem; margin: .75rem 0;
}
.stack > * { display: block; width: 100%; margin-bottom: .75rem; }
.stack input, .stack textarea, .stack select {
  width: 100%; padding: .6rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit;
}

.btn {
  display: inline-block; background: #1a5fb4; color: #fff; border: 0;
  padding: .6rem 1rem; border-radius: 8px; font: inherit; cursor: pointer;
}
.btn:hover { background: #154c91; text-decoration: none; }
.btn.small { padding: .4rem .7rem; font-size: .9rem; }
.btn.danger { background: #991b1b; }
.declinebox summary { cursor: pointer; font-weight: 600; }
.action-sep { display: inline-block; width: 1px; height: 1.5rem; background: #e5e7eb; margin: 0 .35rem; vertical-align: middle; }

/* Project milestone timeline (portal + job detail) */
.timeline { list-style: none; padding: 0; margin: .5rem 0 1rem .55rem; }
.timeline li { position: relative; padding: 0 0 1.1rem 1.6rem; border-left: 2px solid #e2e6ea; }
.timeline li:last-child { padding-bottom: .2rem; border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: .15rem; width: 14px; height: 14px; border-radius: 50%; background: #e2e6ea; }
.timeline li.done::before { background: var(--brand); }
.timeline li.current::before { background: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.timeline li.current .t-label { font-weight: 700; color: var(--brand); }
.timeline li.upcoming .t-label { color: #8a929d; }
.t-date { color: #7a828d; font-size: .85rem; margin-left: .4rem; }
.t-now { background: var(--accent); color: #1b1f24; font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px; margin-left: .45rem; }
.nextstep { background: #f1f5f9; border-left: 4px solid var(--accent); padding: .75rem 1rem; border-radius: 6px; }
.holdbanner { background: #fef3c7; color: #92400e; padding: .6rem .9rem; border-radius: 6px; }
.hp { position: absolute; left: -9999px; }

/* Category filter chips (showcase gallery) */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { padding: .3rem .8rem; border: 1px solid #cbd5e1; border-radius: 999px; font-size: .9rem; color: #1b1f24; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.linenote { font-size: .88rem; }
.stars { color: #f3b415; letter-spacing: .1em; }
.nudgecard { border-left: 4px solid var(--accent); }

/* Dashboard KPI strip + filter bar */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: #fff; border-radius: 10px; padding: .8rem 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kpi-num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--brand); }
.kpi-label { color: #7a828d; font-size: .85rem; }
.filterbar { margin-bottom: 1rem; align-items: center; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }

/* Onboarding checklist */
.onboard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.meter { height: 8px; background: #e2e6ea; border-radius: 999px; overflow: hidden; margin: .4rem 0 .8rem; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.onboardlist { list-style: none; padding: 0; margin: 0; }
.onboardlist li { display: flex; align-items: baseline; gap: .5rem; padding: .3rem 0; }
.onboardlist li.done { color: #8a929d; }
.onboardlist .tick { width: 1.1rem; color: var(--brand); font-weight: 700; flex-shrink: 0; }

.resourcelist { list-style: none; padding: 0; margin: 0; }
.resourcelist li { padding: .55rem 0; border-bottom: 1px solid #eef0f3; }
.resourcelist li:last-child { border-bottom: 0; }
.resourcelist a { font-weight: 600; }
.resourcelist p { margin: .15rem 0 0; font-size: .92rem; }

/* Stack read-only line-item tables on phones */
@media (max-width: 600px) {
  .lineitems.stackable thead { display: none; }
  .lineitems.stackable tr { display: block; border-bottom: 1px solid #eef0f3; padding: .5rem 0; }
  .lineitems.stackable td, .lineitems.stackable tfoot th { display: block; border: 0; padding: .15rem .5rem; text-align: left; }
  .lineitems.stackable td::before { content: attr(data-label); display: block; font-size: .75rem; font-weight: 600; color: #7a828d; text-transform: uppercase; letter-spacing: .04em; }
  .lineitems.stackable td[data-label="Description"]::before { content: none; }
  .lineitems.stackable tfoot tr { border-bottom: 0; }
  .lineitems.stackable tfoot th[colspan] { display: none; }
}
.errorlist { margin: .2rem 0 .4rem; padding: .45rem .6rem .45rem 1.5rem; list-style-position: inside; color: #991b1b; background: #fee2e2; border-radius: 6px; font-size: .9rem; }
button[disabled], .btn[disabled] { opacity: .6; cursor: default; pointer-events: none; }
.declinebox textarea { width: 100%; padding: .5rem; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
.linkbtn { background: none; border: 0; color: #fff; cursor: pointer; font: inherit; text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.joblist { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .joblist { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.joblist .card { margin: 0; }
.joblink { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.jobtitle { font-weight: 600; }

.badge {
  font-size: .8rem; padding: .15rem .5rem; border-radius: 999px;
  background: #e5e7eb; color: #374151; white-space: nowrap;
}
.status-approved, .status-completed, .status-closed { background: #d1fae5; color: #065f46; }
.status-on_hold, .status-cancelled { background: #fee2e2; color: #991b1b; }
.status-in_progress, .status-scheduled { background: #dbeafe; color: #1e40af; }

.qa { border-bottom: 1px solid #eef0f3; padding: .5rem 0; }
.qa p { margin: .2rem 0; }
.qa-reply { margin-left: 1.25rem; padding-left: .75rem; border-left: 2px solid #dbe3ea; }

.vcard { display: flex; flex-direction: column; gap: 1rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 1.25rem; max-width: 560px; }
.vcard-body { width: 100%; }
.vcard-name { font-weight: 600; margin: .2rem 0; }
.vcard-photo { width: 96px; height: 96px; object-fit: cover; border-radius: 50%; border: 1px solid #e5e7eb; margin-bottom: .5rem; }

/* Estimate builder: description cell stacks the line name over a full-width
   scope/notes textarea (was a tiny input floating outside the table). */
.desccell { min-width: 240px; }
.desccell input[data-f="desc"] { width: 100%; }
.linenote-input { width: 100%; margin-top: .3rem; font-size: .85rem; color: #4b5563; resize: vertical; }

/* Proposal: divisions with spec text, then indented line items + subtotal. */
.proposal-section { margin-bottom: 1.5rem; }
.proposal-head { font-size: 1.05rem; color: var(--brand); border-bottom: 2px solid #e5e7eb; padding-bottom: .3rem; margin: 0 0 .4rem; }
.proposal-spec { white-space: normal; font-size: .88rem; margin: .2rem 0 .6rem; }
.proposal .lineitems { margin-bottom: 0; }
.proposal .num { text-align: right; }

/* Proposal acceptance / e-signature. */
.sigfield { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 1.3rem; }
.signed { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 1.6rem; color: var(--brand); margin: .2rem 0; }
.acceptbox { border-left: 4px solid var(--accent); }
.acceptcard { border-left: 4px solid #059669; background: #f0fdf4; }
.agreeline { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; }
.agreeline input { margin-top: .25rem; }

/* Selections: contractor option rows + portal option cards. */
.optthumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.optform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.optform input { padding: .45rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-top: .5rem; }
.optcard { border: 1px solid #e5e7eb; border-radius: 10px; padding: .75rem; background: #fff; text-align: center; }
.optphoto { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: .4rem; }
.optname { font-weight: 600; margin: .2rem 0; }
.optprice { font-size: 1.1rem; font-weight: 700; color: var(--brand); margin: .2rem 0 .5rem; }
.vcard-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.vcard-qr { text-align: center; }
.vcard-qr img { width: min(200px, 60vw); height: auto; }

/* Photo enhancer: thumbnail strip + editor modal */
.pe-strip { display: flex; flex-wrap: wrap; gap: .6rem; margin: .6rem 0; }
.pe-thumb { position: relative; width: 120px; }
.pe-thumb > img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e7eb; display: block; }
.pe-thumb .pe-badge { position: absolute; top: 4px; left: 4px; background: #16a34a; color: #fff; font-size: .62rem; padding: .05rem .35rem; border-radius: 999px; }
.pe-thumb-actions { display: flex; justify-content: space-between; align-items: center; gap: .25rem; margin-top: .2rem; font-size: .78rem; }

.pe-overlay { position: fixed; inset: 0; background: rgba(15,18,25,.75); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.pe-modal { width: min(680px, 96vw); max-height: 94vh; overflow-y: auto; }
.pe-stage { max-height: 56vh; margin-bottom: .75rem; }
.pe-stage img { max-width: 100%; }
/* live preview: adjustments applied to the cropper image */
.pe-overlay .cropper-view-box img, .pe-overlay .cropper-canvas img { filter: var(--pe-filter, none); }
.pe-controls { display: flex; flex-direction: column; gap: .4rem; }
.pe-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.pe-row .pe-sp { flex: 1 1 auto; }
.pe-slider { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: .6rem; font-size: .82rem; }
.pe-slider input[type=range] { width: 100%; }
.pe-ba { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; margin-left: auto; }
.pe-actions { display: flex; gap: .75rem; align-items: center; margin-top: .9rem; }

.hero { padding: 1.5rem 0; }
.hero h1 { font-size: 1.8rem; }
.lead { font-size: 1.15rem; color: #374151; }
.features { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .features { grid-template-columns: repeat(3, 1fr); } }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; margin: 1rem 0; }
.tile { display: block; position: relative; border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid #e5e7eb; }
.tile img { width: 100%; height: 180px; object-fit: cover; display: block; }
.tile-title { display: block; padding: .5rem .75rem; font-weight: 600; }
.tile figcaption { padding: .4rem .75rem; color: #6b7280; font-size: .9rem; }

.docgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.doc { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #fff; }
.doc img { width: 100%; height: 110px; object-fit: cover; display: block; }
.doc-file { display: block; padding: 1.2rem .5rem; font-size: .8rem; word-break: break-word; }
.doc-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .35rem .5rem; }
.row input[type=file] { font: inherit; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.row select { padding: .45rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
.link-danger { background: none; border: 0; color: #991b1b; cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.linkbtn-dark { background: none; border: 0; color: #374151; cursor: pointer; font: inherit; padding: 0 .15rem; }

.tablewrap { overflow-x: auto; }
.lineitems { width: 100%; border-collapse: collapse; }
.lineitems th, .lineitems td { padding: .4rem .5rem; text-align: left; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.lineitems thead th { background: var(--brand); color: #fff; }
.lineitems input { width: 100%; padding: .35rem; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
.lineitems tfoot th { border-top: 2px solid #333; }
/* Estimate builder (cost/markup) — compact inputs, right-aligned money */
.lineitems.estimate th, .lineitems.estimate td { padding: .3rem .35rem; }
.lineitems.estimate input, .lineitems.estimate select { padding: .3rem; }
.lineitems.estimate input[name$="-quantity"], .lineitems.estimate input[name$="-unit_cost"],
.lineitems.estimate input[name$="-unit_price"], .lineitems.estimate input[name$="-markup"] { min-width: 4.5rem; }
.lineitems.estimate input[name$="-unit"] { min-width: 3rem; }
.lineitems.estimate input[name$="-markup"] { width: 3.5rem; display: inline-block; }
.lineitems.estimate select[name$="-markup_type"] { width: auto; display: inline-block; }
.lineitems.estimate .num, .lineitems.estimate [data-total] { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lineitems.estimate [data-f="margin"] { color: #15803d; font-weight: 600; }
.lineitems.estimate tfoot td[data-total] { font-weight: 700; }
.quotelist { list-style: none; padding: 0; }
.quotelist li { padding: .35rem 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.state-draft { background: #e5e7eb; color: #374151; }
.state-paid { background: #d1fae5; color: #065f46; }
.state-void { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.state-sent { background: #dbeafe; color: #1e40af; }
.state-approved { background: #d1fae5; color: #065f46; }
.state-declined { background: #fee2e2; color: #991b1b; }

.messages { list-style: none; padding: 0; margin: 0; }
.msg { padding: .6rem 1rem; }
.msg.success { background: #d1fae5; color: #065f46; }
.msg.error { background: #fee2e2; color: #991b1b; }
/* Estimate builder: highlight a line the save flagged. */
.li-errors td { padding: .3rem .5rem; border: 0; }
.row-error > td { background: #fef2f2; }

/* Full-width, spreadsheet-style estimate grid — breaks out to the workspace
   edges (viewport minus the desktop sidebar width). */
.estimate-full { width: calc(100vw - var(--side-w)); margin-left: calc(50% - (100vw - var(--side-w)) / 2);
  background: #fff; border-top: 1px solid #e5e7eb; margin-top: 1rem; }
.estimate-toolbar { position: sticky; top: 0; z-index: 6; display: flex; flex-wrap: wrap;
  gap: 1rem; align-items: center; justify-content: space-between;
  padding: .55rem clamp(.75rem, 3vw, 2rem); background: #fff; border-bottom: 1px solid #e5e7eb; }
.est-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.est-kpi { font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.est-kpi strong { display: block; font-size: 1.15rem; color: #1b1f24; letter-spacing: 0; text-transform: none; }
.est-kpi-total strong { color: var(--brand); }
.est-actions { display: flex; gap: .6rem; align-items: center; }
.est-status { font-size: .82rem; }
.est-status.ok { color: #059669; }
.est-status.err { color: #b91c1c; }
.est-lib { max-width: 200px; padding: .4rem; border: 1px solid #cbd5e1; border-radius: 8px; }
.est-help { padding: .4rem clamp(.75rem, 3vw, 2rem) 0; }
.estimate-scroll { overflow-x: auto; padding: .5rem clamp(.75rem, 3vw, 2rem) 1.5rem; }

table.estimate.sheet { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
table.estimate.sheet th, table.estimate.sheet td { border: 1px solid #e5e7eb; padding: 0; }
table.estimate.sheet thead th { position: sticky; top: 46px; z-index: 4; background: #f1f5f9;
  padding: .45rem .55rem; text-align: left; font-size: .8rem; color: #475569; white-space: nowrap; }
table.estimate.sheet thead th.num { text-align: right; }
table.estimate.sheet .col-desc { min-width: 260px; }
table.estimate.sheet .col-code { min-width: 150px; }
table.estimate.sheet td > input, table.estimate.sheet td > select,
table.estimate.sheet .desccell input[data-f="desc"] {
  border: 0; width: 100%; padding: .45rem .55rem; background: transparent; font: inherit; border-radius: 0; }
table.estimate.sheet td > input:focus, table.estimate.sheet td > select:focus,
table.estimate.sheet .desccell input:focus, table.estimate.sheet .desccell textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -2px; background: #fffdf5; }
table.estimate.sheet .desccell { padding: .15rem .25rem; }
table.estimate.sheet .desccell .linenote-input { border: 1px dashed #e2e8f0; border-radius: 6px; margin-top: .15rem; padding: .3rem .45rem; }
table.estimate.sheet .nowrap { display: flex; }
table.estimate.sheet .nowrap input { max-width: 70px; }
table.estimate.sheet tbody tr:nth-child(even of [data-li]) td { background: #fcfcfd; }
table.estimate.sheet tfoot th, table.estimate.sheet tfoot td { position: sticky; bottom: 0; z-index: 3;
  background: #f1f5f9; font-weight: 700; padding: .5rem .55rem; }

/* Live subtotals by cost-code division (shown while building). */
.group-subtotals { border: 1px solid #e5e7eb; border-radius: 10px; margin: 0 clamp(.75rem, 3vw, 2rem) .5rem;
  padding: .5rem .75rem; background: #f8fafc; }
.gs-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; margin-bottom: .3rem; }
.gs-row { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; padding: .15rem 0; font-size: .9rem; }
.gs-label { flex: 1 1 45%; }
.gs-price { font-weight: 600; }
.gs-margin { font-size: .82rem; }

/* Mobile: the estimate grid becomes a stacked, labeled card per line. */
@media (max-width: 720px) {
  .estimate-toolbar { position: static; }
  .estimate-scroll { padding-left: .75rem; padding-right: .75rem; }
  table.estimate.sheet { min-width: 0; display: block; }
  table.estimate.sheet thead { display: none; }
  table.estimate.sheet tbody { display: block; }
  table.estimate.sheet tfoot { display: none; }  /* totals live in the summary bar */
  table.estimate.sheet tr[data-li] { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .6rem;
    border: 1px solid #e5e7eb; border-radius: 10px; padding: .6rem; margin-bottom: .6rem; background: #fff; }
  table.estimate.sheet tr[data-li] > td { display: flex; flex-direction: column; border: 0; padding: 0; }
  table.estimate.sheet tr[data-li] > td::before { content: attr(data-label); font-size: .68rem;
    text-transform: uppercase; letter-spacing: .03em; color: #6b7280; margin-bottom: .15rem; }
  table.estimate.sheet tr[data-li] > td.desccell { grid-column: 1 / -1; }
  table.estimate.sheet tr[data-li] > td > input:not([type=checkbox]),
  table.estimate.sheet .desccell input, table.estimate.sheet tr[data-li] > td > select {
    border: 1px solid #cbd5e1; border-radius: 8px; padding: .55rem; background: #fff; }
  table.estimate.sheet .nowrap { flex-direction: row; align-items: center; gap: .35rem; }
  table.estimate.sheet .nowrap input { max-width: none; flex: 1 1 auto; }
  .li-errors td { display: block; }
}

/* Settings form (site editor) */
.settingsform { max-width: 46rem; }
.settingsform .hint { color: #7a828d; font-weight: 400; font-size: .85rem; }
.fieldrow { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 600px) { .fieldrow { grid-template-columns: 1fr; } }
.colorpick { display: flex; align-items: center; gap: .6rem; }
.colorpick input[type=color] { width: 3.2rem; height: 2.4rem; padding: 2px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; cursor: pointer; }
.hexval { color: #4a5568; background: #f1f5f9; padding: .2rem .5rem; border-radius: 6px; font-size: .85rem; }
.imgpreview { display: block; height: 56px; width: auto; border-radius: 8px; border: 1px solid #e2e6ea; background: #fff; padding: 4px; margin: .35rem 0; }
.imgpreview-wide { height: 72px; }
.togglerow { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.toggle { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, #f5f6f8 30%); padding: .8rem 0; }

/* Work-order verification page */
.verifycard { max-width: 26rem; margin: 2rem auto; text-align: center; }
.verifycard .herologo { margin: 0 auto .5rem; }
.verifycode { font-family: ui-monospace, Consolas, monospace; font-size: 1.9rem; font-weight: 700; color: var(--brand); letter-spacing: .06em; margin: .2rem 0 1rem; }
.verifycard .facts { text-align: left; }
.verifynote { font-size: .85rem; }

/* Job page: tabs, horizontal timeline, status dropdown */
.jobcode { font-family: ui-monospace, Consolas, monospace; font-size: .55em; color: #7a828d; background: #eef2f6; border-radius: 6px; padding: .15rem .5rem; vertical-align: middle; margin-left: .4rem; }
.statusdrop { display: flex; align-items: center; gap: .5rem; }
.statusdrop select { padding: .45rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; font-weight: 600; color: var(--brand); background: #fff; }
.timeline-h { list-style: none; display: flex; flex-wrap: wrap; gap: 0; padding: 0; margin: .25rem 0 .5rem; }
.timeline-h li { display: flex; align-items: center; gap: .35rem; padding: .2rem .9rem .2rem 0; position: relative; font-size: .85rem; }
.timeline-h li:not(:last-child)::after { content: ""; width: .55rem; height: 2px; background: #d6dce3; margin-left: .35rem; }
.timeline-h .dot { width: 11px; height: 11px; border-radius: 50%; background: #d6dce3; flex-shrink: 0; }
.timeline-h .done .dot { background: var(--brand); }
.timeline-h .current .dot { background: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.timeline-h .current .t-label { font-weight: 700; color: var(--brand); }
.timeline-h .upcoming .t-label { color: #98a1ab; }
.timeline-h .t-date { color: #98a1ab; font-size: .75rem; }
.nextstep.slim { padding: .45rem .8rem; margin: 0 0 1rem; font-size: .9rem; }
.tabbar { display: flex; gap: .25rem; border-bottom: 2px solid #e2e6ea; margin: .25rem 0 1rem; overflow-x: auto; }
.tabbar button { border: 0; background: none; font: inherit; font-weight: 600; color: #5a6472; padding: .55rem 1rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabbar button:hover { color: var(--brand); }
.tabbar button.active { color: var(--brand); border-bottom-color: var(--accent); }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.cardhead h2 { margin: 0; }

/* Global input polish + people subnav */
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]):not([type=submit]), select, textarea {
  padding: .5rem .65rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--brand); }
.tabbar a { display: inline-block; font-weight: 600; color: #5a6472; padding: .55rem 1rem; border-bottom: 3px solid transparent; margin-bottom: -2px; text-decoration: none; white-space: nowrap; }
.tabbar a:hover { color: var(--brand); text-decoration: none; }
.tabbar a.active { color: var(--brand); border-bottom-color: var(--accent); }
.refdocs ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .75rem; }

/* Leadership page: bios + clients list */
.teambio { display: flex; gap: 1.25rem; align-items: flex-start; }
.teambio .teamphoto { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; flex-shrink: 0; border: 1px solid #e5e7eb; }
.teambio .teamtitle { font-weight: 600; margin: .1rem 0 .5rem; }
.clientlist { columns: 3; column-gap: 2rem; list-style: none; padding: 0; margin: .5rem 0 0; font-size: .92rem; }
.clientlist li { padding: .2rem 0; break-inside: avoid; }
@media (max-width: 640px) { .clientlist { columns: 2; } .teambio { flex-direction: column; } }

/* ============================================================
   Desktop application shell: persistent, collapsible left nav.
   Contractor-only, activates >=1200px; tablet/mobile keep the topbar.
   ============================================================ */
.appside { display: none; }
@media (min-width: 1200px) {
  :root { --side-w: 244px; }
  html.side-collapsed { --side-w: 64px; }
  body { padding-left: var(--side-w); }
  .topbar { display: none; }          /* the sidebar replaces the top nav */
  .appside {
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--side-w); background: var(--brand); color: #fff; z-index: 40;
    overflow-x: hidden; transition: width .15s ease;
  }
  .appside-head { display: flex; align-items: center; gap: .5rem; padding: .8rem .9rem;
    border-bottom: 1px solid rgba(255,255,255,.12); }
  .appside-brand { color: #fff; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem;
    white-space: nowrap; overflow: hidden; }
  .appside-brand .brandlogo { height: 26px; }
  .appside-toggle { margin-left: auto; background: transparent; border: 1px solid rgba(255,255,255,.3);
    color: #fff; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; line-height: 1; flex-shrink: 0; }
  .appside-nav { display: flex; flex-direction: column; padding: .5rem; gap: 2px; overflow-y: auto; flex: 1; }
  .appside-nav a { color: #dfe7f1; display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem;
    border-radius: 8px; white-space: nowrap; overflow: hidden; text-decoration: none; }
  .appside-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
  .appside-nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
  .appside-nav a.nav-cta { background: var(--accent); color: #1b1f24; font-weight: 600; margin: .25rem 0; }
  .appside-nav .ni { width: 1.4rem; text-align: center; font-size: 1.05rem; flex-shrink: 0; }
  .appside-nav .navbadge { margin-left: auto; }
  .appside-logout { padding: .5rem; border-top: 1px solid rgba(255,255,255,.12); }
  .appside-logout button { width: 100%; display: flex; align-items: center; gap: .7rem; background: transparent;
    border: 0; color: #dfe7f1; padding: .55rem .6rem; border-radius: 8px; cursor: pointer; font: inherit; }
  .appside-logout button:hover { background: rgba(255,255,255,.1); color: #fff; }
  .appside-logout .ni { width: 1.4rem; text-align: center; }
  /* Collapsed: icons only. */
  html.side-collapsed .appside .nl,
  html.side-collapsed .appside .navbadge { display: none; }
  html.side-collapsed .appside-toggle { transform: rotate(180deg); }
  html.side-collapsed .appside-nav a,
  html.side-collapsed .appside-logout button { justify-content: center; }
  html.side-collapsed .appside-head { justify-content: center; }
}

/* --- Sidebar tree: SVG icons, collapsible sections, tighter/cleaner --- */
@media (min-width: 1200px) {
  .appside-nav { gap: 1px; padding: .4rem .5rem .6rem; }
  .appside-nav > a, .navsec > summary {
    color: #cdd8e6; display: flex; align-items: center; gap: .6rem; padding: .42rem .55rem;
    border-radius: 7px; font-size: .9rem; white-space: nowrap; overflow: hidden;
    cursor: pointer; list-style: none;
  }
  .navsec > summary::-webkit-details-marker { display: none; }
  .appside-nav > a:hover, .navsec > summary:hover { background: rgba(255,255,255,.09); color: #fff; }
  .appside-nav > a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
  .ni { width: 20px; display: inline-flex; flex-shrink: 0; justify-content: center; }
  .ni svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round; }
  .nav-cta { background: var(--accent); color: #1b1f24 !important; font-weight: 600; }

  .navsec { position: relative; }
  .navsec > summary::after { content: "›"; margin-left: auto; transition: transform .12s ease; opacity: .6; }
  .navsec[open] > summary::after { transform: rotate(90deg); }
  .navsec-job > summary { color: #fff; font-weight: 600; }
  .navsub { display: flex; flex-direction: column; padding: 1px 0 4px 2.15rem; gap: 1px; }
  .navsub a { padding: .32rem .55rem; font-size: .85rem; color: #b3c1d4; border-radius: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .navsub a:hover { background: rgba(255,255,255,.09); color: #fff; }
  .navsub a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
  .navsub-all { opacity: .75; font-size: .82rem; }

  /* Collapsed rail: icons only; sections reveal children as a hover flyout. */
  html.side-collapsed .appside-nav > a, html.side-collapsed .navsec > summary { justify-content: center; }
  html.side-collapsed .navsec > summary::after { display: none; }
  html.side-collapsed .navsub { display: none; }
  html.side-collapsed .navsec:hover > .navsub {
    display: flex; position: absolute; left: 100%; top: 0; min-width: 210px; padding: .4rem;
    background: var(--brand); border-radius: 0 10px 10px 0; box-shadow: 3px 3px 12px rgba(0,0,0,.35); z-index: 60;
  }
  html.side-collapsed .navsub a { justify-content: flex-start; }
}

/* Tasks (reminders) — Todoist-style list. */
.task-actions .linkbtn { color: #1a5fb4; text-decoration: none; }
.task-actions .linkbtn:hover { text-decoration: underline; }
.task-actions .linkbtn.danger { color: #b91c1c; }
.taskadd { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.taskadd input[type=text] { flex: 1 1 260px; }
.taskadd input, .taskadd select { padding: .5rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
.tasksec { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; margin: 0 0 .4rem; }
.tasksec.overdue { color: #b91c1c; }
.tasklist { list-style: none; padding: 0; margin: 0; }
.task { display: flex; align-items: flex-start; gap: .7rem; padding: .5rem 0; border-top: 1px solid #f0f2f5; }
.task:first-child { border-top: 0; }
.taskcheck { flex-shrink: 0; }
.checkbtn { width: 20px; height: 20px; border: 2px solid #cbd5e1; border-radius: 50%; background: #fff;
  cursor: pointer; color: #fff; font-size: .72rem; line-height: 1; margin-top: .15rem; }
.checkbtn.checked { background: var(--brand); border-color: var(--brand); }
.task-main { flex: 1; min-width: 0; }
.task-title { display: block; }
.task.done .task-title { text-decoration: line-through; color: #9aa2ad; }
.task-meta { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; font-size: .82rem; margin-top: .12rem; }
.task-due { background: #eef2f7; color: #475569; padding: 0 .45rem; border-radius: 999px; }
.task-due.overdue { background: #fee2e2; color: #b91c1c; }
.task-link { background: #eef2ff; color: #3b52cc; padding: 0 .45rem; border-radius: 999px; }
.task-actions { display: flex; gap: .6rem; font-size: .82rem; flex-shrink: 0; }

/* --- Sidebar polish: spacing, dividers, calmer CTA --- */
@media (min-width: 1200px) {
  .appside-nav { gap: 2px; min-height: 0; }
  /* Keep rows their natural height and let the nav scroll — otherwise the flex
     column shrinks single-line links when the outline runs past the viewport. */
  .appside-nav > a, .appside-nav > .navsec { flex-shrink: 0; }
  .appside-nav > a, .navsec > summary { padding: .5rem .6rem; }
  .navsec[data-navkey=recent], .navsec[data-navkey=job] {
    margin-bottom: .4rem; padding-bottom: .25rem; border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .navsec[data-navkey=reports] { margin-top: .35rem; }
  .navsub { padding-top: 2px; padding-bottom: 6px; gap: 2px; }
  .navsub a { padding: .36rem .55rem; }
  /* A tasteful CTA instead of a garish tenant-accent block. */
  .appside-nav > a.nav-cta { background: rgba(255,255,255,.12); color: #fff !important;
    border: 1px solid rgba(255,255,255,.15); font-weight: 600; }
  .appside-nav > a.nav-cta:hover { background: rgba(255,255,255,.2); }
  .appside-nav > a.nav-cta .ni svg { stroke: var(--accent); }
}

/* --- Proposal "Contents" jump-nav (long quotes) --- */
.proposal-toc { position: sticky; top: .5rem; z-index: 5; padding: .6rem .9rem; }
.proposal-toc > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline;
  justify-content: space-between; gap: .75rem; font-weight: 600; }
.proposal-toc > summary::-webkit-details-marker { display: none; }
.proposal-toc > summary::before { content: "▾"; margin-right: .4rem; color: #9aa2ad; font-size: .8rem; }
.proposal-toc:not([open]) > summary::before { content: "▸"; }
.proposal-toc .toc-title { font-size: 1rem; }
.toc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .1rem .6rem; margin-top: .6rem; max-height: 42vh; overflow-y: auto; }
.toc-list a { display: flex; align-items: baseline; gap: .5rem; padding: .28rem .4rem;
  border-radius: 6px; color: #1b1f24; font-size: .92rem; }
.toc-list a:hover { background: #eef2f8; text-decoration: none; }
.toc-code { color: #8a929d; font-variant-numeric: tabular-nums; flex: 0 0 auto; min-width: 2.6em; }
.toc-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-amt { color: #6b7280; font-variant-numeric: tabular-nums; flex: 0 0 auto; font-size: .85rem; }
.proposal-head { scroll-margin-top: 3.5rem; }
.proposal-section { scroll-margin-top: 3.5rem; }
.toc-top { float: right; color: #b6bcc5; font-size: .8rem; text-decoration: none; font-weight: 400; }
.toc-top:hover { color: var(--brand); text-decoration: none; }

/* --- Toolbar: consistent action row, destructive pushed right --- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: .6rem .7rem; }
.toolbar form.inline { margin: 0; }
.toolbar .toolbar-end { margin-left: auto; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid #cbd5e1; }
.btn.ghost:hover { background: #f1f5f9; border-color: var(--brand); }

/* --- Tasks: expandable add form (full fields) --- */
.taskadd-full { display: block; }
.taskadd-more { margin-top: .5rem; }
.taskadd-more > summary { cursor: pointer; color: var(--brand); font-size: .9rem; font-weight: 600; }
.taskadd-detail { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; gap: .75rem; margin-top: .6rem; }
.taskadd-detail label { display: block; font-size: .85rem; }
.taskadd-detail select, .taskadd-detail textarea { width: 100%; padding: .5rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
@media (max-width: 640px) { .taskadd-detail { grid-template-columns: 1fr; } }

/* --- Cost-code table manager --- */
.cc-table .linkbtn { color: #1a5fb4; text-decoration: none; }
.cc-table .linkbtn:hover { text-decoration: underline; }
.cc-table .linkbtn.danger { color: #b91c1c; }
.cc-rowactions { white-space: nowrap; }
.cc-rowactions .linkbtn { margin-right: .7rem; }
.cc-indent { color: #9aa2ad; }
.cc-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.cc-forms .row { flex-wrap: wrap; }
.cc-fullwidth { width: 100%; margin: .5rem 0; padding: .5rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; }
@media (max-width: 760px) { .cc-forms { grid-template-columns: 1fr; } }

/* --- Proposal section organizer --- */
.org-add { align-items: center; }
.org-add input[type=text]:first-of-type { flex: 1 1 240px; }
.org-sections { display: flex; flex-direction: column; gap: .6rem; }
.org-section { margin: 0; border-left: 3px solid var(--brand); }
.org-section.dragging { opacity: .5; outline: 2px dashed var(--brand); }
.org-head { display: flex; align-items: center; gap: .6rem; }
.org-grip { cursor: grab; color: #9aa2ad; font-size: 1.1rem; user-select: none; }
.org-section[draggable=true] { cursor: default; }
.org-title { font-weight: 600; }
.org-sub { margin-left: .3rem; font-size: .85rem; }
.org-headbtns { margin-left: auto; display: flex; gap: .2rem; }
.iconbtn { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px; width: 28px; height: 28px;
  cursor: pointer; color: #334155; font: inherit; line-height: 1; }
.iconbtn:hover:not(:disabled) { background: #e2e8f0; }
.iconbtn:disabled { opacity: .4; cursor: default; }
.org-edit { margin: .5rem 0; }
.org-edit > summary { cursor: pointer; color: var(--brand); font-size: .88rem; }
.org-lines { list-style: none; padding: 0; margin: .5rem 0 0; }
.org-line { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid #f0f2f5; }
.org-line-desc { flex: 1 1 auto; min-width: 0; }
.org-line-amt { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.org-move { flex: 0 0 auto; display: flex; gap: .3rem; }
.org-move select { padding: .3rem .4rem; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; max-width: 12rem; }
.org-delete { display: block; margin-top: .6rem; }
.org-delete .linkbtn { color: #b91c1c; text-decoration: none; }
.org-delete .linkbtn:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .org-line { flex-wrap: wrap; }
  .org-move select { max-width: none; }
}
