/* Lavelle CRM shell. Black on light, nothing fancy; the style pass comes later. */
@font-face { font-family: 'Sora'; font-weight: 400; font-display: swap; src: url('/fonts/sora-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 700; font-display: swap; src: url('/fonts/sora-latin-700-normal.woff2') format('woff2'); }

:root { --fg: #000; --bg: #fff; --muted: #555; --line: #d8d8d8; --soft: #f5f5f3; --focus: #1a5fd0; --side: 200px; --bottom: 60px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.5 'Sora', system-ui, sans-serif; color: var(--fg); background: var(--bg); }
a { color: var(--fg); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }

input, select, button, textarea { font: inherit; color: var(--fg); }
input[type=text], input[type=email], input[type=password], textarea, select { border: 1px solid #767676; border-radius: 6px; padding: .55rem .65rem; background: #fff; width: 100%; }
button, .button { border: 1px solid #000; background: #000; color: #fff; border-radius: 6px; padding: .6rem 1rem; cursor: pointer; font-weight: 700; text-decoration: none; display: inline-block; }
button.secondary { background: #fff; color: #000; }
button.link { background: none; color: var(--fg); border: 0; padding: .25rem .4rem; text-decoration: underline; font-weight: 400; }
label { display: block; font-weight: 700; margin: .9rem 0 .3rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.notice { border: 1px solid var(--line); background: var(--soft); padding: .7rem .9rem; border-radius: 6px; margin: 0 0 1rem; }
.notice.error { border-color: #b00020; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1rem; background: #fff; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; font-size: .75rem; border: 1px solid #000; border-radius: 999px; padding: 0 .5rem; margin-left: .4rem; }

/* Bare pages (login, offline) */
.bare-main { max-width: 380px; margin: 10vh auto; padding: 0 16px; }

/* App shell: phones first, bottom nav */
.app { padding-bottom: calc(var(--bottom) + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; }
.top-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.top-right form { margin: 0; }
.db-switch select { width: auto; padding: .3rem .5rem; }
.active-db { font-size: .8rem; border: 1px solid #000; border-radius: 999px; padding: .05rem .55rem; }
.side { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bottom) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; border-top: 1px solid var(--line); background: var(--bg); z-index: 2; }
.side a { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 0 .9rem; text-decoration: none; font-size: .9rem; }
.side a[aria-current=page] { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.content { padding: 1rem 16px 2rem; max-width: 960px; }

/* Wide screens: left nav */
@media (min-width: 800px) {
  .app { padding-bottom: 0; }
  .side { top: 49px; right: auto; bottom: 0; width: var(--side); height: auto; flex-direction: column; overflow-x: visible; overflow-y: auto; border-top: 0; border-right: 1px solid var(--line); padding: 1rem 0; }
  .side a { flex: none; justify-content: flex-start; padding: .55rem 1.25rem; }
  .content { margin-left: var(--side); padding: 1.5rem 2rem 3rem; }
}

@media (forced-colors: active) { button, .button { border: 1px solid ButtonText; } }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; } .mt-lg { margin-top: 1.5rem; } .spread { justify-content: space-between; } .h2 { font-size: 1.1rem; }

/* Section 2: contacts, projects, timeline */
.pill { display: inline-block; font-size: .78rem; border: 1px solid #000; border-radius: 999px; padding: .05rem .55rem; margin: 0 .3rem .2rem .3rem; white-space: nowrap; vertical-align: middle; }
.pill-won { border-width: 2px; font-weight: 700; }
.pill-lost { border-style: dashed; }
.filters { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
.quick-add { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .filters, .quick-add { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; } }
.ids, .projects { list-style: none; padding: 0; margin: .5rem 0; }
.ids li, .projects li { padding: .25rem 0; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .5rem 0; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; }
.notes, .tl-body { white-space: pre-wrap; overflow-wrap: anywhere; }
details summary { cursor: pointer; margin-top: .5rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.tl-item { border-bottom: 1px solid var(--line); padding: .75rem 0; }
.tl-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .85rem; margin-bottom: .25rem; }
.tl-meta .badge { margin-left: 0; }
td .pill { margin-bottom: .2rem; }

/* Keep focused or scrolled-to controls clear of the fixed phone nav bar. */
html { scroll-padding-bottom: calc(var(--bottom) + env(safe-area-inset-bottom) + .5rem); }
@media (min-width: 800px) { html { scroll-padding-bottom: 0; } }

/* Section 3: email threads on the timeline, inline reply, unmatched senders. */
.thread > details > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.thread .emails { list-style: none; padding: 0; margin: .5rem 0 0; }
.thread .email { border-top: 1px solid rgba(214,160,40,.35); padding: .5rem 0; }
.dir { font-weight: 700; color: #9a6400; }
.reply { margin-top: .5rem; }
.reply textarea { width: 100%; font: inherit; }
.unmatched { list-style: none; }
.unmatched li + li { border-top: 1px solid rgba(214,160,40,.35); margin-top: .75rem; padding-top: .75rem; }

/* /mail/unmatched multi-select */
.unmatched .pick { display: flex; gap: .6rem; align-items: center; cursor: pointer; }
.scan-thread { margin: .5rem 0; padding-left: 1.25rem; }
.scan-thread li { margin: .4rem 0; }
.unmatched fieldset { border: 0; padding: 0; margin: .5rem 0; }
.unmatched .pick input, .bulk input { width: 1.15rem; height: 1.15rem; }
.bulk { position: sticky; top: 0; z-index: 1; background: inherit; padding: .5rem 0; }

/* Section 4: pairing QR, /phone/unmatched attach row. */
.pairing .qr svg { width: 240px; height: 240px; background: #fff; }
.pair-code code { font-size: 1.25rem; letter-spacing: 2px; }
.attach select { max-width: 18rem; }

/* Section 5: project updates, client links, the client page. */
.dropzone { border: 2px dashed rgba(214,160,40,.6); border-radius: 14px; padding: 1rem; background: linear-gradient(135deg, rgba(255,205,40,.08), rgba(220,240,107,.08)); }
.dropzone.dragover { border-color: #ff9f1c; background: rgba(255,205,40,.18); }
.updates { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
.update { border: 1px solid rgba(214,160,40,.45); border-radius: 14px; padding: .75rem; background: #fffefb; }
.update img { display: block; width: 100%; height: auto; border-radius: 10px; }
.update-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 .25rem; }
.update-meta { margin: 0; font-size: .85rem; }
.share-toggle { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.update[data-shared="true"] .share-state { font-weight: 700; }
.update[data-shared="true"] .share-state::before { content: "✓ "; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; position: relative; } /* relative: keeps absolutely placed .sr-only labels inside the scroller, so a wide table cannot widen the phone page */
a.button { display: inline-block; padding: .55rem 1rem; border-radius: 12px; background: linear-gradient(135deg,#ffcd28,#ff9f1c); color: #000; font-weight: 700; text-decoration: none; }
a.button.secondary { background: #fffefb; border: 1.5px solid rgba(214,160,40,.5); }
.phone-only { display: none; }
@media (pointer: coarse) { .phone-only { display: inline-block; } }
.client-main { max-width: 52rem; margin: 0 auto; padding: 1rem; }
.client-header { display: flex; gap: .75rem; align-items: center; }
.client-studio { font-weight: 700; letter-spacing: 1px; margin: 0; }
/* Section 6: bids, documents, signing */
.badge-warn { display: inline-block; border: 2px dashed #000; border-radius: 6px; padding: .4rem .7rem; font-weight: 700; margin: 0 0 1rem; }
.bid-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .5rem 1rem; }
.bid-lines input { width: 100%; min-width: 4rem; }
.bid-totals { border: 1px solid var(--line); border-radius: 6px; padding: .6rem .9rem; margin: 1rem 0; }
.bid-totals dl { display: grid; grid-template-columns: auto auto; gap: .2rem 1rem; margin: 0; }
.bid-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ver { margin-right: .6rem; }
ul.plain { list-style: none; padding: 0; }
code.hash { word-break: break-all; font-size: .8rem; }
code.ph { margin-right: .4rem; }
.sign-req { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .8rem; }
.sign-req input[readonly] { width: 100%; }
table.audit { font-size: .85rem; }
label.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.pdf-view { border: 1px solid var(--line); border-radius: 6px; max-height: 70vh; overflow: auto; background: #fff; margin: 1rem 0; }
.pdf-page { display: block; width: 100%; height: auto; border-bottom: 1px solid var(--line); }
.sig-method { border: 0; padding: 0; margin: .8rem 0; }
@font-face { font-family: "Dancing Script"; src: url("/fonts/dancing-script-latin-400-normal.woff2") format("woff2"); font-display: swap; }
.sig-preview { font-family: "Dancing Script", cursive; font-size: 2rem; min-height: 2.6rem; margin: .4rem 0; }
.sig-pad canvas { width: 100%; max-width: 600px; aspect-ratio: 600 / 160; border: 1px dashed #000; border-radius: 6px; touch-action: none; background: #fff; display: block; margin-bottom: .4rem; }
.small { font-size: .85rem; }
.claude-draft { border: 2px dashed #000; border-radius: 6px; padding: .75rem; margin-bottom: .75rem; }

/* Section 9: analytics charts and the content board */
.chart { margin: .5rem 0 0; }
.chart svg { width: 100%; height: auto; max-width: 560px; display: block; }
.chart-label { font-size: 12px; fill: #000; }
.chart-value { font-size: 12px; font-weight: 700; fill: #000; }
.chart-bar { fill: #ffb02f; stroke: #9a6400; stroke-width: 1; }
.chart-bar.alt { fill: #ffcd28; }
.chart-grid { stroke: rgba(0,0,0,.15); }
.chart-line { fill: none; stroke: #000; stroke-width: 2.5; }
.chart-line.dashed { stroke: #9a6400; stroke-dasharray: 6 4; }
.chart-dot { fill: #ff9f1c; stroke: #000; }
.legend { margin-right: 1rem; white-space: nowrap; }
.panels { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; margin: 0; }
.board { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.board-col h2 { font-size: 1rem; margin: 0 0 .5rem; }
.board-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.short-card { border: 1px solid rgba(214,160,40,.45); border-radius: 10px; padding: .55rem .65rem; background: #fffefb; }
.short-card a { font-weight: 700; }
@media (forced-colors: active) { .chart-bar, .chart-dot { fill: Highlight; } .chart-line { stroke: CanvasText; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { font-weight: 700; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
/* Bid builder: the save/update button stays on screen while scrolling the long form (above the phone bottom nav). */
.bid-save-bar { position: sticky; bottom: calc(var(--bottom) + env(safe-area-inset-bottom)); background: var(--bg); padding: .6rem 0; border-top: 1px solid var(--line); z-index: 1; }
@media (min-width: 800px) { .bid-save-bar { bottom: 0; } }

/* Section 14: lead bands and the leads block beside the inquiry list. */
.score { display: inline-block; font-size: .75rem; font-weight: 700; border: 2px solid #000; border-radius: 999px; padding: 0 .5rem; }
.score-warm { border-style: dashed; }
.score-cool { border-width: 1px; font-weight: 400; }
.home-leads { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .home-leads { grid-template-columns: 1fr 1fr; } }
.lead-queue h3 { margin: .8rem 0 .3rem; font-size: 1rem; }
.lead-queue li { margin: .35rem 0; }
.awaiting { display: inline-block; font-size: .75rem; border: 1px dashed #000; border-radius: 6px; padding: 0 .4rem; }
.rules td input[type=number] { width: 5rem; }

/* Section 13: portal tab row (here, not in the component: the CSP blocks inline styles) */
.portal-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.portal-tabs a { color: #000; text-decoration: none; border: 1.5px solid #000; border-radius: 999px; padding: .45rem .9rem; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.portal-tabs a[aria-current='page'] { background: #000; color: #fff; }
.portal-tabs a:focus-visible { outline: 3px solid #000; outline-offset: 2px; }
.tab-count { font-weight: 400; }

/* Contact page, Wix-style: summary panel beside tabbed sections; stacked on phones. */
.contact-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.contact-extras { order: 3; } .contact-extras > section { margin-bottom: 1rem; }
.contact-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 0 0 1rem; }
.contact-stats div { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; background: var(--soft); }
.contact-stats dt { font-size: .8rem; color: var(--muted); }
.contact-stats dd { margin: 0; font-weight: 700; font-size: 1.1rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: none; }
.tabs a { flex: 0 0 auto; padding: .6rem .8rem; text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a[aria-current=page] { font-weight: 700; border-bottom-color: var(--fg); }
table.data { font-size: .95rem; }
@media (min-width: 1100px) { .content:has(.contact-layout) { max-width: 1280px; } .contact-layout { grid-template-columns: 340px minmax(0, 1fr); grid-template-rows: auto 1fr; align-items: start; } .contact-main { grid-column: 2; grid-row: 1 / span 2; } .contact-summary, .contact-extras { grid-column: 1; } }
