/* ConstructNav v0.18.3 R2 — shared screen contrast.
   Keep these rules after the legacy theme files. The PDF, drawing canvas,
   signature artwork and print stylesheet retain their own presentation. */
@media screen {
  :root {
    --cn-contrast-ink: #0b2942;
    --cn-contrast-muted: #52677b;
    --cn-contrast-control-line: #77899a;
    --cn-contrast-focus: #075f9d;
    --muted: var(--cn-contrast-muted);
    --cn-readable-muted: var(--cn-contrast-muted);
    --cn994-muted: var(--cn-contrast-muted);
  }

  /* These classes describe secondary text on the standard light surfaces.
     Dark banners retain their explicit light-text rules. */
  html body :is(.content, .view, dialog, .modal, .modal-card, .cnx-modal)
    :is(.field-note, .helper, .hint, .receipt-meta, .meeting-meta,
        .xe-ai-status, .cn-home-alert-time, .cn-home-alert-empty,
        .time-empty, .chart-label, .activity-time, .due) {
    color: var(--cn-contrast-muted);
  }
  html body .content > .version { color: var(--cn-contrast-muted) !important; }

  /* Give controls a visible edge on white and light blue-gray forms. Do not
     recolor color pickers, sliders, checkboxes, or drawing/signature content. */
  html body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not(.cn-sign-field *),
  html body select:not(.cn-sign-field *),
  html body textarea:not(.cn-sign-field *) {
    color: var(--cn-contrast-ink) !important;
    background: #fff !important;
    border-color: var(--cn-contrast-control-line) !important;
  }
  html body input::placeholder,
  html body textarea::placeholder {
    color: var(--cn-contrast-muted) !important;
    opacity: 1 !important;
  }
  html body :is(input, select, textarea):is(:disabled, [readonly]):not(.cn-sign-field *) {
    color: #405a70 !important;
    background: #e9f0f5 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #405a70;
  }
  html body :is(input[type="checkbox"], input[type="radio"]) {
    accent-color: #145f94;
  }

  /* Selection is visible before the runtime audit, including tab text nested
     in spans. These are application tabs, not sidebar navigation buttons. */
  html body :is(.task-tab, .cnx-tab, .project-tab, .cn-subtab):not(.active) {
    color: #294761 !important;
  }
  html body :is(.task-tab, .cnx-tab, .project-tab).active {
    color: #fff !important;
    background: #0c4f83 !important;
    border-color: #0c4f83 !important;
  }
  html body .cn-subtab.active {
    color: #0c4f83 !important;
    background: #fff !important;
    box-shadow: inset 0 -3px 0 #0c4f83;
  }
  html body :is(.task-tab, .cnx-tab, .project-tab, .cn-subtab)
    :where(span, strong, small, b) { color: inherit !important; }

  /* Retain status meaning; replace the pale orange/red/green foregrounds
     whose small text fell below 4.5:1 on the existing tinted backgrounds. */
  html body .pill.warn,
  html body .priority.medium {
    color: #8a4b08 !important;
    background: #fff0df !important;
  }
  html body .pill.danger,
  html body .priority.high {
    color: #9b2430 !important;
    background: #fde3e5 !important;
  }
  html body .pill.ok,
  html body .priority.low {
    color: #17633f !important;
    background: #dff4e9 !important;
  }
  html body .stat .trend b { color: #17633f; }

  /* Children of controls use the control's own foreground. In particular,
     a light button in a navy banner must not inherit the banner's white. */
  html body .btn :where(span, strong, small, b, i),
  html body .cn-readability-dark-surface .btn :where(span, strong, small, b, i) {
    color: inherit !important;
  }
  html body :is(.cn-live-proposal-head, .cn-auth-brand,
      .cn-signature-guest-banner, .cn-external-guest-session)
    .btn:not(.primary):not(.green):not(.danger) {
    background: #fff !important;
    color: #0a3558 !important;
    border-color: var(--cn-contrast-control-line) !important;
  }

  /* Disabled controls remain legible. Their actual disabled state, subdued
     solid surface, and cursor communicate availability without fading text. */
  html body button:disabled { opacity: 1 !important; }
  html body .btn:disabled,
  html body .btn.primary:disabled,
  html body .btn.green:disabled,
  html body .btn.danger:disabled,
  html body .cn-simple-action:disabled,
  html body .cn-auth-button:disabled {
    color: #405a70 !important;
    background: #e9f0f5 !important;
    border-color: #8294a4 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    cursor: not-allowed;
  }
  html body :is(.btn, .cn-simple-action, .cn-auth-button):disabled
    :where(span, strong, small, b, i) { color: inherit !important; }

  /* An opaque ring plus a white separator is visible on light and dark
     backgrounds; the earlier translucent rings disappeared on pale panels. */
  html body :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--cn-contrast-focus) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 3px #fff !important;
  }
  html body #nav button:focus-visible,
  html.cn-mobile-mode body #cnMobileBottomNav button:focus-visible {
    outline-color: #e8b850 !important;
    box-shadow: 0 0 0 3px #071b31 !important;
  }

  /* The runtime checker chooses these exact solid colors after compositing
     the visible background. Include the legacy dark-banner and pass-through
     scopes so earlier forced text rules cannot change its chosen result. */
  html body :is(.cn-text-on-dark,
      .cn-readability-dark-surface .cn-text-on-dark,
      #passThroughs .cn-text-on-dark) { color: #fff !important; opacity: 1 !important; }
  html body :is(.cn-text-on-light,
      .cn-readability-dark-surface .cn-text-on-light,
      #passThroughs .cn-text-on-light) { color: #0b2942 !important; opacity: 1 !important; }
  html body :is(.cn-text-on-black,
      .cn-readability-dark-surface .cn-text-on-black,
      #passThroughs .cn-text-on-black) { color: #000 !important; opacity: 1 !important; }
}

/* Module details and retained records also need clear text before the
   dynamic contrast audit runs. These selectors leave dark project headers,
   semantic status colors, uploaded artwork, and print output alone. */
@media screen {
  /* Inactive or void records still provide working review/edit actions.
     Their status labels, pale fills, and existing strikethrough remain. */
  html body .cn-user-table tr.inactive,
  html body .cn-aia-void,
  html body .cn-jc-ignored,
  html body .cn-friction-row.resolved {
    opacity: 1 !important;
  }
  html body .cn-user-table tr.inactive { background: #f3f6f8; }
  html body .cn-jc-ignored { color: #405a70; }

  /* Dates and completed events remain selectable. Selection in the
     estimate catalog is communicated by its checkboxes and row styling. */
  #calendar .calendar-day.outside { color: var(--cn-contrast-muted) !important; }
  #calendar .calendar-event.completed,
  #calendar .cn-calendar-event-meta,
  #estimating.cn-ew-enhanced .xe-catalog .cn-ew-grid .xe-unselected-line {
    opacity: 1 !important;
  }

  /* Only the portfolio's light-surface labels are recolored. The selected
     segment count keeps its white text on blue. Stage is a form label. */
  #projects .cn-project-portfolio-kicker,
  #projects .cn-project-overview span,
  #projects .cn-project-cell-label,
  #projects .cn-project-type,
  #projects .cn-project-stage-filter:not(.active),
  #projects .cn-project-date > span:last-child,
  #projects .cn-project-contract > span:last-child,
  #projects .cn-project-empty > small {
    color: var(--cn-contrast-muted) !important;
  }
  #projects .cn-project-segment:not(.active) span { color: #40576c !important; }

  #jobRadarRoot { --jr-muted: var(--cn-contrast-muted); }
  #jobRadarRoot .jr-stars { color: #8a5b00 !important; }
  .cn-procurement-app { --proc-muted: #52646d; }
  #passThroughs .pt-state-cell small { color: var(--cn-contrast-muted) !important; }
  #navigatornotes .notes-hero p { opacity: 1 !important; }

  .cn-tw-app .cn-tw-eyebrow { color: #805400 !important; }
  .cn-tw-status-card:not(.ready) .cn-tw-status-dot,
  .cn-tw-customer-file.blocked { color: var(--cn-contrast-muted) !important; }
  .cn-tkp-status-card:not(.ready) .cn-tkp-status-dot { color: #805400 !important; }

  /* Portal milestone numbers need an explicit foreground; they are divs,
     while completed milestones retain a white check on green. */
  html body .cnx-milestone .cnx-dot { color: #17324d !important; }
  html body .cnx-milestone.current .cnx-dot {
    background: #f2c267;
    color: #17324d !important;
  }
  html body .cnx-milestone.done .cnx-dot {
    background: #1f6d54;
    color: #fff !important;
  }
  .cn-portal-hero .cn-portal-stat { background: #214f72; color: #fff; }
  .cn-portal-hero .cn-portal-stat strong { color: #fff !important; opacity: 1 !important; }
  .cn-portal-hero .cn-portal-stat span { color: #e2edf5 !important; opacity: 1 !important; }

  /* Module-specific secondary copy sits on white or pale card backgrounds.
     Restrict summary selectors to labels so status badges keep their hues. */
  html body :is(
      .cn-user-switch-copy small,
      .cn-user-person small,
      .cn-user-title,
      .cn-user-dialog-head small,
      .cn-user-record-access small,
      .cn-user-permission-head small,
      .cn-company-logo-empty small,
      .cn-company-logo-help,
      .cn-commission-kpi .hint,
      .cn-commission-table .muted,
      .cn-commission-empty,
      .cn-aia-review-row small,
      .cn-aia-document-row small,
      .cn-jc-kpi span,
      .cn-portal-project-facts span,
      .cn-portal-login-note,
      .cn-sign-field-empty,
      .cn-subagreement-summary > div > span:first-child,
      .cn-subagreement-current small,
      .cn-subagreement-empty,
      .cn-onboarding-summary small,
      .cn-intake-document-title span,
      .cn-intake-section input[type="file"] + small,
      .cn-signature-guest-card dt,
      .cn-auth-divider) {
    color: var(--cn-contrast-muted) !important;
  }
  .cn-signature-guest-kicker { color: #805600 !important; }
}

@media screen and (max-width: 760px) {
  #passThroughs .pt-table tbody tr[data-open-pt-row] td::before {
    color: var(--cn-contrast-muted) !important;
  }
}
