/* =========================================================================
 * BBO Contrast Fixes v1.0.0 (2026-09-25) — WCAG AA readability overrides
 * Generated from axe-core audit against live scopecam/, board.html, and
 * cockpit route. Readability-only; palette-preserving.
 * Rollback: remove this file + the <link> tag in board.html/scopecam.
 * ========================================================================= */

/* -------------------------------------------------------------------------
 * A. CRITICAL — dark navy text (#1F2A2E, the light-theme --txt) inheriting
 *    onto dark cockpit surfaces. These pairs were literally unreadable
 *    (ratio 1.0-1.3). Force the dark-theme text color (#E6ECFF) on the
 *    specific surfaces that are dark navy.
 * ----------------------------------------------------------------------- */

/* Cockpit job-count cards render on --card-dark #0F1A2E.
   Scope tightly to text elements INSIDE .jc-card, but leave nested buttons
   (which have their own backgrounds) untouched. */
.jc-card,
.jc-card > div,
.jc-card > div > div,
.jc-card > span,
.jc-card > p,
.jc-card .muted,
.jc-card [style*="color:var(--muted)"],
.jc-card [style*="color: var(--muted)"] {
    color: #E6ECFF !important;
}
.jc-card .muted,
.jc-card [style*="color:var(--muted)"],
.jc-card [style*="color: var(--muted)"] {
    color: #B5C3D9 !important; /* softer muted still >4.5:1 on #0F1A2E */
}

/* Cockpit chip strip (chip bg #1C2848) */
.jc-chips .chip { color: #E6ECFF !important; }
.jc-chips .chip.active { color: #0B1220 !important; } /* dark ink on #3AA0FF for AA */

/* Scopecam default view: staff-quick chip strip + big chips on dark bg */
.staff-quick .qbtn,
.staff-quick .qbtn .lbl { color: #E6ECFF !important; }
.staff-quick .qbtn.info,
.staff-quick .qbtn.info .lbl { color: #C5E8F5 !important; } /* was #7ADFF5 on #1F2F3B — bumped for AA */

/* .chip.big variants (dark bg #1C2848 when inactive, #3AA0FF when active) */
.chip.big { color: #E6ECFF !important; }
.chip.big.active { color: #0B1220 !important; }

/* Generic inline chip pattern used on scopecam filter row */
span.chip[style*="flex-shrink:0"] { color: #E6ECFF !important; }
span.chip.active[style*="flex-shrink:0"] { color: #0B1220 !important; }

/* Push-notif prompt lives on dark #0E1729 */
.bbo-pr-title { color: #E6ECFF !important; }
.bbo-pr-sub   { color: #B5C3D9 !important; } /* was #6B7B7F — insufficient on dark */

/* Board: signed change-order note on dark bg #150D26 */
.jobcard [style*="#150d26"] span,
.jobcard [style*="#150D26"] span,
.jobrow [style*="background:#150d26"] span,
.jobrow [style*="background:#150D26"] span {
    color: #E6ECFF !important;
}
.jobcard [style*="color:var(--muted)"],
.jobrow [style*="color:var(--muted)"] {
    /* The default --muted (#6B7B7F) is 4.26 on #150D26 — nudge lighter */
    /* Only override where parent bg is dark: use a scoped attribute selector match */
}

/* Version badge — dynamic bg (#AAABAD / #B9B7B4 / #B2B1AE depending on route).
   Force a dark bg so any light fg text on it reads clearly. Inline JS style attr
   requires beating with attribute+id specificity. */
#bboVerBadge,
div#bboVerBadge[style],
html body #bboVerBadge {
    background: #4A4B4D !important;
    color: #FFFFFF !important;
}

/* -------------------------------------------------------------------------
 * B. MUTED text (#6B7B7F) darkened to #4D5A5E (still gray, still muted,
 *    but >6:1 on every light bg we use). Applies to both board + scopecam
 *    where --muted resolves the same value.
 * ----------------------------------------------------------------------- */
:root {
    /* Do NOT change the variable itself (would affect dark-mode too).
       Instead override the concrete color in leaf usages below. */
}

/* Board light-mode surfaces (bg #F8F5EE, cards #FFFFFF, various tinted panels).
   Blanket-darken every muted usage on LIGHT surfaces. Dark-surface muted overrides
   are handled above in Section A. */
.wrap .muted,
.jobcard .muted,
.jobcard .jobsub .muted,
.stage-lbl,
.stage-usd,
.stage .stage-lbl,
.stage .stage-usd,
.kpi .lbl,
.right > span,
.sub,
h3 { }
/* .muted on light bg (default surface color across board + scopecam). Do NOT !important
 * so any legit inline `style="color: ..."` on a .muted span keeps working. */
body .muted:not([style*="color"]) { color: #4D5A5E; }
/* Stage labels/pipeline USD on white cards — target with high specificity to beat
 * the board's own `.stage .stage-lbl { color:var(--muted)!important }` rule. */
.wrap .stage .stage-lbl,
.wrap .stage-lbl,
html body .stage .stage-lbl,
html body .stage-lbl { color: #4D5A5E !important; }
html body .stage .stage-usd,
html body .stage-usd { color: #7A6228 !important; }
/* KPI / pipeline heading + timestamp */
.wrap .sub, .wrap #asof, #asof { color: #4D5A5E !important; }
/* Header user chip */
.right > span, header .right > span { color: #4D5A5E !important; }

/* Inline muted style patterns — match BOTH `color:var(--muted)` and
   `color: var(--muted)` (space variant), plus var(--txt-muted). */
[style*="color:var(--muted)"],
[style*="color: var(--muted)"],
[style*="color:var(--txt-muted)"],
[style*="color: var(--txt-muted)"] {
    color: #4D5A5E !important;
}
/* But re-lighten those inside dark cockpit cards (they were handled above,
   but !important cascade means we need to re-assert). */
.jc-card [style*="color:var(--muted)"],
.jc-card [style*="color: var(--muted)"] { color: #B5C3D9 !important; }

/* Bare tab/heading muted on cream */
.staff-section h3 { color: #3F4C50 !important; }
.tile-sub, .staff-tile .tile-sub { color: #4D5A5E !important; }
.typetab[style*="color:var(--txt)"] { color: #1F2A2E !important; }
/* Board — unselected .tab is #6B7B7F on cream (4.04). Darken. */
.tabs .tab:not(.on) { color: #4D5A5E !important; }
/* Board — class-level muted usages on white card. Higher specificity to beat
 * the existing `!important` rules in board.html. Bare `.moneyline` and `.jobsub`
 * both default to --muted color. */
html body .jobcard .jobsub,
html body .bbo-jobcard-v3 .jobsub,
html body .jobrow .jobsub,
html body .jobcard .moneyline,
html body .jobcard .moneyline > span,
html body .jobcard .moneyline > div,
html body .jobrow  .moneyline,
html body .jobrow  .moneyline > span,
html body .jobrow  .moneyline > div { color: #4D5A5E !important; }
/* Keep the bold amounts in .moneyline b sharp (dark ink on white) */
html body .jobcard .moneyline b,
html body .jobrow  .moneyline b { color: #1F2A2E !important; }

/* Change Order block on dark #150D26 (JS-injected via .style.cssText, one job pattern).
 * Browsers normalize style-attr serialization, so hex may become rgb. Anchor on the
 * OTHER distinctive style (border-left color #a76efd) which is unique to this block. */
html body div[style*="#a76efd"],
html body div[style*="#A76EFD"],
html body div[style*="rgb(167, 110, 253)"],
html body div[style*="rgb(21, 13, 38)"] {
    color: #E6ECFF !important;
}
html body div[style*="#a76efd"] *,
html body div[style*="rgb(167, 110, 253)"] *,
html body div[style*="rgb(21, 13, 38)"] * {
    color: #E6ECFF !important;
}
html body div[style*="#a76efd"] [style*="color:var(--muted)"],
html body div[style*="#a76efd"] [style*="color: var(--muted)"] {
    color: #B5C3D9 !important;
}
/* Contractor-facing PDF LINK (blue) on info-light bg — darken blue. */
html body .pdf-btns .pdf-btn[target="_blank"],
html body .pdf-btns a.pdf-btn { color: #1F5E9D !important; }
/* (Change Order dark-bg block rule consolidated above with .moneyline) */

/* Scopecam default view */
.card p.muted,
.card .muted,
.bbo-ib-sub,
.seg { color: #4D5A5E !important; }

/* -------------------------------------------------------------------------
 * C. GOLD (#C9A355 / #B08F42) — decorative brand accent that was showing
 *    up as body text on white/cream. Darkened to #7A6228 (still gold, still
 *    on-brand) to hit >5:1 on white/cream/gold-light.
 * ----------------------------------------------------------------------- */
.jobcard a[style*="color:var(--gold)"],
.jobrow  a[style*="color:var(--gold)"],
.jobcard span[style*="color:var(--gold)"],
.jobcard div[style*="color:var(--gold)"],
.jobrow  span[style*="color:var(--gold)"],
a[style*="color:var(--gold)"][href*="sms:"] {
    color: #7A6228 !important;
}
/* PM ACTION NEEDED etc. */
.jobcard [style*="color: var(--gold)"],
.jobrow  [style*="color: var(--gold)"] {
    color: #7A6228 !important;
}
/* Contractor-facing PDF button was gold-hover text on cream */
.pdf-btns .pdf-btn.internal { color: #7A6228 !important; }

/* -------------------------------------------------------------------------
 * D. INFO BLUE (#2E7BC6) — scope-summary + similar headers on info-light bg.
 * ----------------------------------------------------------------------- */
.jobcard [style*="color:var(--blue)"],
.jobcard [style*="color: var(--blue)"],
.jobcard [style*="color:var(--info)"],
.jobcard [style*="color: var(--info)"],
.jobrow  [style*="color:var(--blue)"],
.jobrow  [style*="color: var(--blue)"],
.jobrow  [style*="color:var(--info)"],
.jobrow  [style*="color: var(--info)"] {
    color: #1F5E9D !important;
}
/* Scope summary span pattern (inherits blue via nearby wrapper) */
.jobcard div[style*="background: var(--info-light)"] span,
.jobcard div[style*="background:var(--info-light)"] span {
    color: #1F5E9D !important;
}

/* -------------------------------------------------------------------------
 * E. WARNING ORANGE (#C68A2E) — "Scope verification needed" headers on
 *    warning-light bg. Darken to #8F6220 (>4.7:1).
 * ----------------------------------------------------------------------- */
.jobcard [style*="color:var(--warning)"],
.jobcard [style*="color: var(--warning)"],
.jobrow  [style*="color:var(--warning)"],
.jobrow  [style*="color: var(--warning)"] {
    color: #8F6220 !important;
}
/* KPI warn */
.kpi.warn .val { color: #8F6220 !important; }

/* -------------------------------------------------------------------------
 * F. PILL / STATUS BADGES — white text on mid-tone brand fills.
 *    Darken the fills slightly so #FFFFFF hits AA (need bg L* < ~40).
 * ----------------------------------------------------------------------- */
.pill.in_progress.editable       { background: #7A6228 !important; color: #FFFFFF !important; }
.pill.awaiting_deposit.editable  { background: #8F6220 !important; color: #FFFFFF !important; }
.pill.recurring_service.editable { background: #1F5E9D !important; color: #FFFFFF !important; }

/* -------------------------------------------------------------------------
 * G. VERIFY-SCOPE-DONE button — inline bg var(--success) with color
 *    accidentally set to rgb(255,255,255) by the browser default but the
 *    CSS var was outputting a dark ink. Force white-on-brand-green.
 * ----------------------------------------------------------------------- */
.jobcard button[style*="background: var(--success)"],
.jobcard button[style*="background:var(--success)"],
.jobrow  button[style*="background: var(--success)"],
.jobrow  button[style*="background:var(--success)"] {
    color: #FFFFFF !important;
}

/* -------------------------------------------------------------------------
 * H. Scopecam BLUE / GREEN action buttons — white text on #3AA0FF / #2EB673
 *    fails AA (2.6-2.7). Switch to dark ink #0B1220 which is >6.5:1.
 * ----------------------------------------------------------------------- */
[style*="background:#3aa0ff"],
[style*="background: #3aa0ff"],
[style*="background:#3AA0FF"] {
    color: #0B1220 !important;
}
[style*="background:#2eb673"],
[style*="background: #2eb673"],
[style*="background:#2EB673"] {
    color: #0B1220 !important;
}

/* Inline muted link on info-light bg (email links) */
[style*="color: var(--muted)"][href^="mailto:"],
[style*="color:var(--muted)"][href^="mailto:"] { color: #3F4C50 !important; }

/* Trade pill (blue on info-light) */
.tl .trade { color: #1F5E9D !important; }

/* service_call pill was #FFFFFF on #B08F42 (3.06). Darken bg. */
.pill.service_call.editable { background: #7A6228 !important; color: #FFFFFF !important; }

/* Board (signed) muted spans nested inside dark #150D26 backgrounds */
div[style*="background:#150d26"] span,
div[style*="background: #150d26"] span,
div[style*="background:#150D26"] span {
    color: #E6ECFF !important;
}
div[style*="background:#150d26"] [style*="color:var(--muted)"],
div[style*="background: #150d26"] [style*="color:var(--muted)"] {
    color: #B5C3D9 !important;
}

/* Ghost buttons: text color depends on card bg. Since scopecam route can render
 * the same .card class over either light (#FFF) or dark (#131b2e / #111a2e) bg
 * depending on theme + route, we can't universally decide. Use a pragmatic rule:
 *   - .btn.ghost inside html[data-theme="dark"] or .theme-dark = light text
 *   - .btn.ghost inside body = readable dark text by default.
 * We also anchor to specific known dark-card ancestors (`.wholesale-cockpit`,
 * `.staff-cockpit`, `#staff-root`) so we don't fight the light-mode default. */
.card:not([class*="dark"]) .btn.ghost,
.row > .btn.ghost { color: #1F2A2E !important; }
html[data-theme="dark"] .btn.ghost,
.theme-dark .btn.ghost,
#staff-root .btn.ghost,
.wholesale-cockpit .btn.ghost,
.staff-cockpit .btn.ghost { color: #E6ECFF !important; }

/* Emergency fallback for any .btn.ghost that is visually on dark surface. The
 * safest cross-theme approach: give ghost a subtle text-shadow-free semi-
 * transparent surface so text is legible on BOTH light and dark. But that
 * changes visuals — skip. Instead accept the 1-node edge case (🏠 Investor
 * on scopecam customer-cockpit) and note in report. */

/* -------------------------------------------------------------------------
 * I. Bucket dividers — light greens/teals text on mid green/teal fills.
 *    Bump the pill lightness slightly.
 * ----------------------------------------------------------------------- */
.bucket-divider span[style*="rgba(255,255,255,0.15)"] {
    color: #F5FADF !important;
    background: rgba(0,0,0,0.28) !important; /* darkens the light-tinted bg for AA */
}

/* -------------------------------------------------------------------------
 * J. Header brand text .b "Better Built" (#3AA0FF on cream) — this is a
 *    small logotype, but audit flagged it. Darken.
 * ----------------------------------------------------------------------- */
.right .b, header .b, .b { color: #1F5E9D !important; }

/* -------------------------------------------------------------------------
 * K. Banner.info — was #A8C8F3 on #1F2E4A (fine at 4.4 large-text, but
 *    normal-size fails). Lighten fg.
 * ----------------------------------------------------------------------- */
.banner.info { color: #D9E6FF !important; }

/* End BBO Contrast Fixes v1.0.0 */