/* Clear blue / white appearance. Load last on both clients.
 * Paint only: no size, spacing, type metrics, display, positioning or overflow.
 * Business status colors, validation, disabled states and report canvases stay
 * with their owning modules. The mobile directory has its own stylesheet.
 */
@media screen {
  :root {
    --bw-blue: #3266df;
    --bw-blue-hover: #2857c6;
    --bw-bg: #f2f5fb;
    --bw-paper: #fff;
    --bw-ink: #1e304b;
    --bw-muted: #64758e;
    --bw-line: #e2e9f4;
    --bw-control-line: #cbd7e8;
    --bw-soft: #eef4ff;
    --bg: var(--bw-bg);
    --card: var(--bw-paper);
    --line: var(--bw-control-line);
    --brand: var(--bw-blue);
    --brand-dark: var(--bw-blue-hover);
    --text: var(--bw-ink);
    --muted: var(--bw-muted);
  }
  body,
  body.pc-ui-preview,
  body.mobile-ui-active,
  body.mobile-workflow-fidelity {
    --brand: var(--bw-blue);
    --brand-dark: var(--bw-blue-hover);
    --text: var(--bw-ink);
    --muted: var(--bw-muted);
    --ui-primary: var(--bw-blue);
    --ui-ink: var(--bw-ink);
    --ui-muted: var(--bw-muted);
    --ui-border: var(--bw-line);
    --ui-soft: var(--bw-bg);
    --ui-row-base: var(--bw-paper);
    --ui-row-stripe: #f8faff;
    --ui-row-hover: var(--bw-soft);
    background: var(--bw-bg);
    color: var(--bw-ink);
  }
  body .mobile-system-shell,
  body.mobile-ui-active .mobile-system-shell,
  body.mobile-workflow-fidelity .mobile-system-shell {
    --ms-brand: var(--bw-blue);
    --ms-brand-dark: var(--bw-blue-hover);
    --ms-blue: var(--bw-blue);
    --ms-ink: var(--bw-ink);
    --ms-muted: var(--bw-muted);
    --ms-soft: var(--bw-bg);
    --ms-card: var(--bw-paper);
    --ms-line: var(--bw-line);
    background: var(--bw-bg);
    color: var(--bw-ink);
  }
  body :is(.mw-workspace,.mw-modal) { --mw-teal: var(--bw-blue); --mw-ink: var(--bw-ink); }
  body .project-contract-detail-panel[data-detail-refined="true"] {
    --detail-ink: var(--bw-ink); --detail-muted: var(--bw-muted);
    --detail-line: var(--bw-line); --detail-action: var(--bw-blue);
  }
  body :is(.report-workspace,.rw-dialog) {
    --rw-ink: var(--bw-ink); --rw-muted: var(--bw-muted);
    --rw-line: var(--bw-line); --rw-blue: var(--bw-blue);
  }
  body .rw-ledger { --rl-ink: var(--bw-ink); --rl-muted: var(--bw-muted); --rl-line: var(--bw-line); }

  /* Existing application chrome, including login and detached return bars. */
  body .main-view,
  body.pc-ui-preview .main-view,
  body.mobile-workflow-fidelity .mobile-system-shell #content.mobile-system-content {
    background: var(--bw-bg);
  }
  body .login-view { background: var(--bw-bg); }
  body .login-view > .card { background: var(--bw-paper); color: var(--bw-ink); border-color: var(--bw-line); box-shadow: 0 8px 24px #1e304b0a; }
  body #loginBtn { background: var(--bw-blue); border-color: var(--bw-blue); color: #fff; }
  body #loginBtn:hover:not(:disabled) { background: var(--bw-blue-hover); border-color: var(--bw-blue-hover); }
  body:is(.pc-ui-preview,.mobile-ui-active) :is(.topbar,.business-return-bar,.mobile-system-topbar) {
    background: var(--bw-paper); color: var(--bw-ink); border-color: var(--bw-line); box-shadow: none;
  }
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-system-topbar,
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-system-bottom-nav {
    background: var(--bw-paper); border-color: var(--bw-line); box-shadow: none;
  }
  body.mobile-workflow-fidelity .mobile-system-shell .topbar-product .mobile-app-back {
    background: var(--bw-soft); color: var(--bw-blue);
  }
  body.mobile-workflow-fidelity .mobile-system-shell .topbar-product .mobile-app-back:not(.visible) {
    background: var(--bw-blue); color: #fff;
  }
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-app-topbar-copy strong { color: var(--bw-ink); }
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-app-topbar-copy small { color: var(--bw-muted); }
  body.mobile-workflow-fidelity .mobile-system-shell .topbar-product .mobile-app-menu { color: var(--bw-blue); }
  body.mobile-workflow-fidelity.mobile-task-workflow .mobile-system-shell .topbar-product .mobile-app-menu { background: var(--bw-soft); }
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-system-bottom-nav .mobile-system-bottom-nav-item { color: var(--bw-muted); }
  body.mobile-workflow-fidelity .mobile-system-shell .mobile-system-bottom-nav .mobile-system-bottom-nav-item.active { color: var(--bw-blue); }

  /* Primary page surfaces and every existing dialog family. No overlay/shade
     selector is painted white, and no report/attachment content is recolored. */
  body :is(#content,.mobile-system-content) > :is(.panel,.page-hero):not(.danger,.warning,.error,.success,.is-error,.is-success),
  body :is(.client-page-panel,.client-detail-workspace,.quote-list-panel,.quote-editor-refined,
    .project-contract-detail-panel,.task-workspace-board,.task-detail-section,
    .ca-workspace,.mw-panel,.fw-workspace,.iv-workspace,.reimbursements-page,
    .purchase-a-shell,.material-workspace,.fa-workspace,.ai-workspace,
    .ep-workspace,.payroll-workspace,.attendance-workspace,
    .proposal-files-workspace,.venue-template-library,.venue-template-editor,.ua-workspace,.sa-workspace):not(.danger,.warning,.error,.success,.is-error,.is-success),
  body :is(.preview-modal-card,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,.ca-detail-page,
    .fw-dialog,.iv-shell,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog,.af-dialog,
    .device-scope-dialog,.dw-classic-dialog),
  body .mw-modal > section:not(:has(.mr-report,.ar-report,.ir-report)),
  body .reim-modal > section,
  body .cd-confirm > section {
    background-color: var(--bw-paper);
    border-color: var(--bw-line);
    color: var(--bw-ink);
  }
  body :is(.bf-header,.cw-header,.qd-header,.cd-header,.ca-header,.fw-header,.iv-shell > header,
    .rw-dialog > header,.ua-dialog > header,.af-header,.system-dialog-header,
    .bf-footer,.cw-footer,.iv-footer,.ua-modal-footer) {
    background-color: var(--bw-paper); border-color: var(--bw-line);
  }
  body:is(.pc-ui-preview,.mobile-ui-active) :is(#content,.preview-modal-card,.bf-shell,.cw-shell,
    .qd-dialog,.cd-shell,.ca-dialog,.ca-detail-page,.fw-dialog,.iv-shell,.reim-modal,
    .mw-modal,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog,.af-dialog)
    :is(h1,h2,h3,h4):not(:where(.mr-report *,.ar-report *,.ir-report *,[role="alert"] *,
      .danger,.warn,.warning,.error,.success,[class*="error"],[class*="warning"],
      [class*="error"] *,[class*="warning"] *,[class*="danger"] *,[class*="success"] *)) {
    color: var(--bw-ink);
  }
  body :is(#content,.preview-modal-card,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,
    .fw-dialog,.iv-shell,.reim-modal,.mw-modal,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog)
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]),select,textarea):not(:disabled):not([readonly]):not([aria-invalid="true"]):not(.is-invalid,.invalid):not(:where(.mr-report *,.ar-report *,.ir-report *)) {
    background-color: var(--bw-paper); border-color: var(--bw-control-line); color: var(--bw-ink);
  }
  body :is(#content,.preview-modal-card,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,
    .fw-dialog,.iv-shell,.reim-modal,.mw-modal,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog)
    :is(input,select,textarea):focus-visible:not([aria-invalid="true"]):not(.is-invalid,.invalid):not(:where(.mr-report *,.ar-report *,.ir-report *)) {
    border-color: var(--bw-blue); outline-color: #3266df55;
  }
  body :is(#content,.bf-shell,.cw-shell,.qd-dialog,.ca-dialog,.fw-dialog,.iv-shell,.ua-dialog)
    :is(input[type="checkbox"],input[type="radio"]):not(:where(.mr-report *,.ar-report *,.ir-report *)) { accent-color: var(--bw-blue); }

  /* Secondary operations stay quiet. Destructive and semantic-state actions
     retain their module colors, as do selected controls until handled below. */
  body :is(#content,.preview-modal-card,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,
    .fw-dialog,.iv-shell,.reim-modal,.mw-modal,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog)
    button.secondary:not(:where(.danger,.warning,.warn,.error,.success,.is-error,.is-success,
      .is-error,.is-success,.active,.selected,.is-active,[aria-pressed="true"],[aria-selected="true"],[aria-current],
      [class*="danger"],[class*="delete"],[class*="remove"],.stat-action,.mr-report *,.ar-report *,.ir-report *)) {
    background-color: var(--bw-paper); border-color: var(--bw-control-line); color: var(--bw-blue);
  }
  body :is(#content,.preview-modal-card,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,
    .fw-dialog,.iv-shell,.reim-modal,.mw-modal,.rw-dialog,.fa-dialog,.ai-dialog,.ep-dialog,.ua-dialog)
    button.secondary:hover:not(:disabled):not(:where(.danger,.warning,.warn,.error,.success,
      .active,.selected,.is-active,[aria-pressed="true"],[aria-selected="true"],[aria-current],
      [class*="danger"],[class*="delete"],[class*="remove"],.stat-action,.mr-report *,.ar-report *,.ir-report *)) {
    background-color: var(--bw-soft); border-color: #a9c0ef;
  }
  body :is(.client-create-toggle,.quote-create-toggle,.client-detail-primary,.execution-create-toggle,
    .bf-primary,.mobile-system-primary,.ia-primary,.as-primary,.ma-sign-button,.ma-enter,
    .reim-actions > button[type="submit"]):not(:where(.danger,.warning,[class*="danger"],.mr-report *,.ar-report *,.ir-report *)) {
    background: var(--bw-blue); border-color: var(--bw-blue); color: #fff;
  }
  body :is(.client-detail-tabs,.quote-form-step-nav,.bf-tabs,.mw-service-tabs,.rw-tabs,
    .fw-tabs,.ep-tabs,.payroll-tabs,.support-system-nav,.ma-pages)
    :is(.active,.is-active,[aria-selected="true"],[aria-current="page"]):not(:where(.mr-report *,.ar-report *,.ir-report *)) {
    border-color: var(--bw-blue); color: var(--bw-blue); background-color: var(--bw-soft);
  }
  body :is(.business-return-bar,.mobile-return-row) > button,
  body :is(.client-back-to-list,.preview-modal-close,.mobile-workspace-refresh) {
    color: var(--bw-blue); border-color: var(--bw-control-line);
  }
  body :is(.business-list-sort-inline,.business-list-sort-control,.customer-table-sort) { color: var(--bw-muted); }

  /* Table headers, neutral rows and dividers. Do not touch semantic rows. */
  body :is(#content,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,.fw-dialog,.iv-shell,.ua-dialog)
    th:not(:where(.mr-report *,.ar-report *,.ir-report *,.quote-summary-table *)) {
    background-color: #f5f8fd; color: #536783; border-color: var(--bw-line);
  }
  body :is(#content,.bf-shell,.cw-shell,.qd-dialog,.cd-shell,.ca-dialog,.fw-dialog,.iv-shell,.ua-dialog)
    td:not(:where(.mr-report *,.ar-report *,.ir-report *,.quote-summary-table *,
      .danger,.warning,.error,.success,.needs-nudge,.danger *,.warning *,.error *,.success *,.needs-nudge *)) {
    border-color: var(--bw-line);
  }

  /* Explicit late mobile rules originally use !important. Match only these
     ordinary navigation/actions; never neutralize professional result colors. */
  body.mobile-ui-active .mw-workspace .mtr-system-menu > .mtr-system-options button { background: #fff !important; color: var(--bw-ink) !important; }
  body.mobile-ui-active .mw-workspace .mtr-system-menu > .mtr-system-options button:is(.active,.selected,[aria-current="page"],[aria-pressed="true"]) {
    background: var(--bw-soft) !important; border-color: #a9c0ef !important; color: var(--bw-blue) !important;
  }
  body.mobile-ui-active .mw-workspace.mw-phone-list > .ma-header [data-mw="create"],
  body.mobile-ui-active :is(.mw-inspection-association,.mw-assessment-simple) :is(.ia-primary,.as-primary) {
    background: var(--bw-blue) !important; border-color: var(--bw-blue) !important; color: #fff !important;
  }
  body.mobile-ui-active :is(.mw-inspection-association,.mw-assessment-simple) :is(.ia-header,.as-header) button {
    background: var(--bw-soft) !important; color: var(--bw-blue) !important;
  }
  body.mobile-ui-active :is(.mw-inspection-association,.mw-assessment-simple) :is(.ia-outline,.as-outline,.ia-dashed,.as-dashed) {
    border-color: var(--bw-control-line) !important; color: var(--bw-blue) !important;
  }
  body.mobile-ui-active .mw-workspace:has(.ma-app) { background: var(--bw-bg) !important; }
  body.mobile-ui-active .mw-workspace:has(.ma-app) .ma-header h2,
  body.mobile-ui-active .mw-workspace:has(.ma-app) .ma-app h3 { color: var(--bw-ink) !important; }
  body.mobile-ui-active .mw-workspace:has(.ma-app) .ma-header button {
    background: var(--bw-soft) !important; color: var(--bw-blue) !important;
  }
  body.mobile-ui-active .client-page-panel [data-client-floating][open] > summary {
    background: var(--bw-soft) !important; color: var(--bw-blue) !important; border-color: #a9c0ef !important;
  }
  body.mobile-ui-active .mur-page :is(.mur-ai-bottom,.mur-material-bottom) :is(button,summary),
  body.mobile-ui-active .msw-page :is(.msw-ai-bottom,.msw-material-bottom) :is(button,summary),
  body.mobile-ui-active #content > .mfa-page .fw-body .fw-account-row-actions button {
    color: var(--bw-blue) !important;
  }
  body.mobile-ui-active dialog.material-issue-dialog:is(.mur-scope,.msw-scope) form > button[type="submit"],
  body.mobile-ui-active #inventoryCountsModal.msw-scope :is(.bf-primary,button[type="submit"]) {
    background: var(--bw-blue) !important; border-color: var(--bw-blue) !important; color: #fff !important;
  }
  body.mobile-ui-active .cw-modal.mfa-owned[data-mobile-account-source] .cw-footer > button[data-cw-action="list"] {
    background: var(--bw-soft) !important; border-color: var(--bw-line) !important; color: var(--bw-blue) !important;
  }
}

/* The desktop navigation uses the same white surfaces as the mobile design.
 * All sidebar/header dimensions, expansion and notification colors are intact. */
@media screen and (min-width: 769px) {
  body.pc-ui-preview .tabs { background: #fff; box-shadow: inset -1px 0 0 #e2e9f4; scrollbar-color: #b8c7dd transparent; }
  body.pc-ui-preview :is(.desktop-sidebar-brand,.desktop-sidebar-footer) { border-color: var(--bw-line); }
  body.pc-ui-preview .desktop-sidebar-mark { background: var(--bw-blue); color: #fff; }
  body.pc-ui-preview .desktop-sidebar-brand-copy { color: var(--bw-ink); }
  body.pc-ui-preview .desktop-sidebar-brand-copy small { color: var(--bw-muted); }
  body.pc-ui-preview :is(.desktop-page-heading h2,#userMeta) { color: var(--bw-ink); }
  body.pc-ui-preview .tabs .desktop-nav-group-toggle,
  body.pc-ui-preview .tabs .tab-group.has-active .desktop-nav-group-toggle { color: var(--bw-ink); }
  body.pc-ui-preview .tabs button,
  body.pc-ui-preview .tabs .desktop-nav-items > button[data-tab] { background: transparent; color: #536783; }
  body.pc-ui-preview .tabs button:hover,
  body.pc-ui-preview .tabs .desktop-nav-items > button[data-tab]:hover { background: var(--bw-soft); border-color: transparent; color: var(--bw-blue); }
  body.pc-ui-preview .tabs button.active,
  body.pc-ui-preview .tabs .desktop-nav-items > button[data-tab].active { background: var(--bw-soft); border-color: #d5e2ff; color: var(--bw-blue); box-shadow: none; }
}
