/* Internal documents include this after their page styles and the shared tokens.
   The public landing page also sets data-skin. Exclude both its root and body.
   Skin selection owns the palette; preferences.js reconciles the legacy mode. */
@scope (html[data-skin]:not([data-skin="original"]):not(.fci-public-scroll):has(> body:not(.fci-public-site))) {
  :scope {
    color-scheme: var(--skin-scheme);
    --control-edge: color-mix(in srgb, var(--skin-muted) 78%, var(--skin-border));
    --skin-tint: color-mix(in srgb, var(--skin-accent) 10%, var(--skin-surface));
    --skin-rim: color-mix(in srgb, var(--skin-accent) 30%, var(--skin-border));
  }

  /* Inherited aliases on html alone lose to body.light-mode, .ws-shell and
     the ID-scoped variables on workspace pages. Do not alias semantic colours:
     --accent, --green-primary, --solar, --warn, etc. also encode live data. */
  :scope > body:not(.fci-public-site), :scope > body :is(.ws-shell, .solar-app-root, .fci-page-inner[id],
      #page-profile, #page-security, #page-ticket-system, #page-fleetiq, #page-contractor-log,
      #page-weekly-briefing, #page-dashboard) {
    --bg: var(--skin-bg);
    --surface: var(--skin-surface);
    --bg-card: var(--skin-surface);
    --card: var(--skin-surface);
    --panel: var(--skin-surface);
    --bg-raised: var(--skin-surface-2);
    --bg-inset: var(--skin-surface-2);
    --bg-soft: var(--skin-tint);
    --tab-bg: var(--skin-surface-2);
    --input-bg: var(--skin-surface-2);
    --text: var(--skin-text);
    --text-primary: var(--skin-text);
    --text-body: var(--skin-text);
    --text-muted: var(--skin-muted);
    --text-light: var(--skin-muted);
    --t1: var(--skin-text);
    --t2: var(--skin-muted);
    --t3: var(--skin-muted);
    --muted: var(--skin-muted);
    --border: var(--skin-border);
    --border-light: var(--skin-border);
    --divider: var(--skin-border);
    --panel-bd: var(--skin-border);
    --border-hi: var(--control-edge);
    --ui-border: var(--skin-border);
    --ui-border-hi: var(--skin-rim);
    --mn-thead-bg: var(--skin-surface-2);
    --ft-bg: var(--skin-surface);
    --ph-bg: var(--skin-surface);
    --ph-h1: var(--skin-text);
    --ph-p: var(--skin-muted);
    --scrim-bg: color-mix(in srgb, var(--skin-bg) 84%, transparent);
  }

  :scope body { color: var(--skin-text); }
  /* Some shell pages and the legacy editorial skin set body paint !important.
     Embedded apps must keep the parent shell visible through the viewport. */
  :scope body:not(.fci-shell) { background: var(--skin-bg) !important; }
  :scope body.fci-shell { background: transparent !important; }
  :scope body #page-scrim { background: var(--scrim-bg); }
  :scope body #app-frame-cover { background: var(--skin-bg); }

  /* Login is a standalone gate, with its own nav, fields and painted card. */
  :scope #login-screen .login-card {
    background: var(--skin-surface);
    border-color: var(--skin-rim);
    color: var(--skin-text);
  }
  :scope #login-screen h2 { color: var(--skin-text); }
  :scope #login-screen label { color: var(--skin-muted); }
  :scope #login-dev-hint { color: var(--skin-muted) !important; }
  /* Keep the mark's original green gradient on a light backing in dark skins. */
  :scope[data-theme="dark"] #login-screen .login-logo a {
    background: var(--skin-text);
    border-radius: .4rem;
    padding: .3rem .6rem;
  }
  :scope #login-screen .login-back-link {
    color: var(--skin-accent);
    opacity: 1;
    text-decoration: underline;
    text-underline-offset: .18em;
  }
  /* Keep the existing red error ink readable on the light palettes too. */
  :scope #login-error:not(:empty) { background: #28191d; border-radius: .25em; }
  :scope #login-error a { text-decoration: underline; }

  /* fci-nav is light DOM. nav.js injects styles (and the phone lock) late.
     Only paint the chrome; the lock still owns visibility, geometry and hit areas. */
  :scope body :is(#login-site-nav, fci-nav, fci-nav .nav-inner) {
    background: var(--skin-nav) !important;
    color: var(--skin-nav-text);
    border-bottom-color: var(--skin-rim);
  }
  :scope body #login-site-nav :is(.lsn-link, .lsn-login-link, .lsn-theme-label),
  :scope body fci-nav :is(.nav-link, .nav-dropdown-toggle, .nav-user-name,
      .nav-theme-label, .fci-lang-label, .nav-menu-btn, .nav-user-btn, .nav-logout) {
    color: var(--skin-nav-text);
  }
  :scope #login-site-nav .lsn-disabled { opacity: .65; }
  :scope body fci-nav :is(.nav-user-btn, .nav-menu-btn, .nav-logout, .fci-lang-seg) {
    background: var(--skin-nav);
    border-color: color-mix(in srgb, var(--skin-nav-text) 56%, var(--skin-nav));
  }
  :scope body fci-nav .fci-lang-seg button { color: var(--skin-nav-text); background: transparent; }
  :scope body fci-nav .fci-lang-seg button.act {
    color: var(--skin-nav);
    background: var(--skin-nav-text);
  }
  :scope #login-site-nav .lsn-theme-track, :scope fci-nav .nav-theme-track {
    background: color-mix(in srgb, var(--skin-nav-text) 34%, var(--skin-nav));
  }
  :scope #login-site-nav .lsn-theme-thumb, :scope fci-nav .nav-theme-thumb { background: var(--skin-nav-text); }
  :scope[data-view-mode="phone"] body fci-nav .nav-items { background: var(--skin-nav) !important; }
  :scope body fci-nav :is(.nav-dropdown-menu, .nav-user-dropdown),
  :scope[data-view-mode="phone"] body fci-nav .nav-dropdown-menu {
    background: var(--skin-surface) !important;
    color: var(--skin-text);
    border-color: var(--skin-border) !important;
  }
  :scope body fci-nav :is(.nav-dropdown-menu, .nav-user-dropdown) :is(a, button),
  :scope[data-view-mode="phone"] body fci-nav .nav-dropdown-menu a {
    color: var(--skin-text) !important;
  }
  :scope body fci-nav :is(.nav-dropdown-menu, .nav-user-dropdown) :is(a, button):is(:hover, :focus-visible, .active),
  :scope[data-view-mode="phone"] body fci-nav .nav-dropdown-menu a:is(:hover, :focus-visible, .active) {
    background: var(--skin-surface-2) !important;
    color: var(--skin-accent) !important;
  }
  :scope body fci-nav .nav-user-sep { background: var(--skin-border); }

  /* Hero ink is painted with -webkit-text-fill-color in page-hero.css.
     Dashboard, profile and research each have higher-specificity versions. */
  :scope .page-header.ph-hero {
    --ph-accent-local: var(--skin-accent);
    --ph-accent-dim-local: color-mix(in srgb, var(--skin-accent) 12%, transparent);
    --ph-accent-glow-local: color-mix(in srgb, var(--skin-accent) 18%, transparent);
    --ph-border-local: var(--skin-rim);
    background: var(--skin-surface) !important;
    border-color: var(--skin-rim);
  }
  :scope .page-header.ph-hero :is(h1, .ph-title-text) {
    color: var(--skin-text) !important;
    -webkit-text-fill-color: var(--skin-text) !important;
  }
  :scope .page-header.ph-hero .ph-kicker { color: var(--skin-accent); }
  :scope .page-header.ph-hero .ph-body p { color: var(--skin-muted) !important; }

  /* Only neutral containers. Stateful variants (battery charging, fleet flags,
     selected rows), chart backplates and opaque canvas roots keep their paint. */
  :scope body :is(.fci-page-inner .card, .sidebar .panel, .page .panel, .wrap .card) {
    background-color: var(--skin-surface);
  }
  :scope :is(.glass, .main-card:not(.card-drag-ghost), .scc-card, .rc-main, .rc-rail,
      .rc-card, .ir-modal-card, .sh-modal-card, .rc-modal-card, .iam-modal,
      .rye-command-card, .rye-subnav, .rye-panel, .rm-section-combined,
      .fci-load-card, .pf-card, .sec-card, .ws-modal, .modal-box) {
    background: var(--skin-surface);
    color: var(--skin-text);
  }
  :scope .fci-load-card { background: var(--skin-surface) !important; border-color: var(--skin-border); }
  :scope .fci-load-card :is(.load-title, .load-logo) { color: var(--skin-text) !important; }
  :scope .fci-load-card :is(.load-ver, .load-pct, .load-step) { color: var(--skin-muted) !important; }
  :scope :is(.ftab.active, .hero-ctl-label, .live-updated) { color: var(--skin-muted); }
  :scope .filter-tabs .ftab.active { color: var(--skin-accent); border-bottom-color: var(--skin-accent); }
  :scope .filter-tabs { background: var(--skin-surface); }

  /* These dashboard labels keep their original status/series ink. Most are
     bright even in legacy light mode. Give just the label a dark backing;
     orange badges already use dark amber ink in that mode. */
  :scope[data-theme="light"] #page-dashboard {
    --signal-backing: color-mix(in srgb, var(--skin-text) 60%, black);
  }
  :scope[data-theme="dark"] #page-dashboard {
    --signal-backing: color-mix(in srgb, var(--skin-bg) 36%, black);
  }
  :scope #page-dashboard :is(.badge.green, .badge.blue, .badge.red,
      .card-change.positive, .card-change.negative, .dash-growth-leg-btn.active,
      .dash-growth-mode .active-live, .dash-growth-mode .active-sim, .dash-growth-ranges button.active,
      .fci-access-badge:not(.fci-access-badge--user), .dash-add-btn) {
    background: var(--signal-backing);
  }
  :scope #page-dashboard .dash-del-btn { background: var(--signal-backing) !important; }
  :scope[data-theme="light"] #page-dashboard .badge.orange { background: var(--skin-surface); }
  :scope #page-dashboard .card-change:is(.positive, .negative) {
    width: fit-content;
    border-radius: .25em;
    padding-inline: .35em;
  }
  :scope #page-dashboard .dash-growth-view-mode button.active-view {
    background: var(--skin-accent);
    color: var(--skin-surface);
  }

  /* Workspace aliases live on the id or .ws-shell itself, not the document. */
  :scope body :is(#page-ticket-system, #page-fleetiq, #page-contractor-log, #page-weekly-briefing, .ws-shell) {
    --tk-surface: var(--skin-surface); --tk-surface-2: var(--skin-surface-2);
    --cs-surface: var(--skin-surface); --cs-surface-2: var(--skin-surface-2);
    --cl-surface: var(--skin-surface); --cl-surface-2: var(--skin-surface-2);
    --wb-surface: var(--skin-surface); --wb-surface-2: var(--skin-surface-2);
    --tk-line: var(--skin-border); --tk-line-hi: var(--skin-rim);
    --cs-line: var(--skin-border); --cs-line-hi: var(--skin-rim);
    --cl-line: var(--skin-border); --cl-line-hi: var(--skin-rim);
    --wb-line: var(--skin-border); --wb-line-hi: var(--skin-rim);
    --ws-accent: var(--skin-accent);
    --ws-accent-soft: var(--skin-tint);
    --ws-accent-border: var(--skin-rim);
  }
  :scope body :is(.ws-pane, .ws-file, .ws-btn:not(.ws-btn-accent)),
  :scope body :is(#page-ticket-system .tk-pane, #page-weekly-briefing .wb-pane,
      #page-contractor-log .cl-card, #page-profile .pf-card, #page-security .sec-card) {
    background: var(--skin-surface);
    color: var(--skin-text);
    border-color: var(--skin-border);
  }
  :scope body .ws-shell :is(.ws-file-name, .ws-root-group-label, .ws-root, .ws-pane-title) { color: var(--skin-text); }
  :scope body .ws-shell :is(.ws-file-meta, .ws-root-group-hint, .ws-empty, .ws-pane-sub) { color: var(--skin-muted); }
  :scope body .ws-shell :is(.ws-file-ico, .ws-root.active), :scope body .ws-crumb button {
    color: var(--skin-accent);
    background: var(--skin-tint);
  }
  :scope body #page-ticket-system :is(.tk-pane-title, .tk-row-title, .tk-detail-head h2, .tk-empty h3) { color: var(--skin-text); }
  :scope body #page-ticket-system :is(.tk-pane-sub, .tk-id, .tk-row-date, .tk-window-note, .tk-section-label) { color: var(--skin-muted); }
  :scope body :is(#page-ticket-system, #page-dashboard, #iam-role-toggle, .fci-page-inner[id]) :is(.fci-role-seg, .dash-seg) button,
  :scope body #page-ticket-system .tk-pill {
    background: var(--skin-surface-2);
    color: var(--skin-text);
  }
  :scope body :is(#page-ticket-system, #page-dashboard, #iam-role-toggle, .fci-page-inner[id]) :is(.fci-role-seg, .dash-seg) button.act,
  :scope body #page-ticket-system .tk-pill.active {
    background: var(--skin-accent);
    color: var(--skin-surface);
  }

  :scope #tb-root .tb-btn.act,
  :scope #page-solar-array :is(.tb.act, .tb.act-g, .tb.act-snap, .vbtn.act) {
    color: var(--skin-surface);
    background: var(--skin-accent);
    border-color: var(--skin-accent);
  }
  :scope #iam-role-toggle .fci-role-seg button:focus-visible,
  :scope #tb-root .tb-btn:focus-visible,
  :scope #page-solar-array :is(.tb, .vbtn):focus-visible {
    outline: 2px solid var(--skin-accent);
    outline-offset: 2px;
  }

  /* Keep table records, selections, warning cells, disabled controls and chart
     legends intact. Style only the neutral header and text-entry controls. */
  :scope :is(.fci-page-inner, .page, .sidebar, .tablewrap, .tbl-wrap, .table-wrap) th:not([style]) {
    background: var(--skin-surface-2);
    color: var(--skin-text);
    border-color: var(--skin-border);
  }
  :scope body :is(input:not([type]), input[type="text"], input[type="search"], input[type="password"],
      input[type="email"], input[type="tel"], input[type="url"], input[type="number"],
      input[type="date"], input[type="month"], textarea, select):not([aria-invalid="true"]):not(:disabled) {
    background-color: var(--skin-surface-2);
    color: var(--skin-text);
    border-color: var(--control-edge);
  }
  :scope body :is(input, textarea)::placeholder { color: var(--skin-muted); opacity: 1; }
  :scope body select option { background: var(--skin-surface); color: var(--skin-text); }
  :scope body :is(.ws-search, .ws-editor, .search-bar) {
    color: var(--skin-text); background: var(--skin-surface-2); border-color: var(--control-edge);
  }
  :scope body :is(#page-profile, #page-security, #page-ticket-system) .ws-field
      :is(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea):not([aria-invalid="true"], :disabled),
  :scope body :is(.pf-fci-select-menu, .sec-fci-select-menu, .tk-fci-select-menu) {
    background: var(--skin-surface-2);
    color: var(--skin-text);
    border-color: var(--control-edge);
  }
  :scope body :is(#page-profile, #page-security) :is(.pf-card, .sec-card) h2 { color: var(--skin-text); }
  :scope body :is(#page-profile, #page-security, #page-ticket-system) :is(.ws-field label, .pf-note, .sec-note) {
    color: var(--skin-muted);
  }
  :scope #login-screen .login-field input {
    color: var(--skin-text);
    background: var(--skin-surface-2);
    border-color: var(--control-edge);
  }
  :scope #login-submit, :scope body :is(.btn-primary, .btn-accent, .ws-btn.ws-btn-accent) {
    color: var(--skin-surface) !important;
    background: var(--skin-accent) !important;
    border-color: var(--skin-accent);
  }
  :scope #login-submit:hover, :scope body :is(.btn-primary, .btn-accent, .ws-btn-accent):hover {
    box-shadow: inset 0 0 0 2px var(--skin-surface);
  }
  :scope :is(a, button, input, select, textarea, summary, [tabindex], [contenteditable="true"]):focus-visible {
    outline: 2px solid var(--skin-accent) !important;
    outline-offset: 2px;
  }
  :scope :is(#login-site-nav, fci-nav) :focus-visible { outline-color: var(--skin-nav-text) !important; }
  :scope fci-nav :is(.nav-dropdown-menu, .nav-user-dropdown) :focus-visible { outline-color: var(--skin-accent) !important; }

  /* Standalone tools without a shell (including the model in an iframe).
     Style the surrounding controls, never the rendered diagram, map or sky. */
  :scope body > header, :scope :is(#pseudoBar, #cloudExtract, #tools, #tb-dock-top.tb-top-bar) {
    color: var(--skin-text);
    background: var(--skin-surface);
    border-color: var(--skin-border);
  }
  :scope body:has(#pseudoBar) :is(header .hint, header .inline, #tools .label, .cx-hint) { color: var(--skin-muted); }
  :scope body:has(#pseudoBar) :is(#pseudoBar .field > b, #cloudExtract .cx-toolbar > b) { color: var(--skin-text); }
  :scope body:has(#pseudoBar) :is(header, #pseudoBar, #cloudExtract, #tools) button:not(#fusion-skin-trigger, #fusion-mode-toggle) {
    color: var(--skin-text); background: var(--skin-surface-2); border-color: var(--control-edge);
  }
  :scope body:has(#pseudoBar) :is(header, #pseudoBar, #cloudExtract, #tools) button:is(.active, .cx-open) {
    color: var(--skin-surface); background: var(--skin-accent);
  }
  :scope body:has(.diagram-wrap) :is(h1, td.val) { color: var(--skin-text); }
  :scope body:has(.diagram-wrap) :is(.subtitle, .legend-row, .note, .sidebar .card h3, td.desc) { color: var(--skin-muted); }
  :scope body:has(.diagram-wrap) .sidebar .card, :scope body > .image-container img { background: var(--skin-surface); }
  :scope body:has(#inp-settings) :is(.kpi, .dcfhead .big, .tabs, tr.grp td) {
    background: var(--skin-surface-2); color: var(--skin-text);
  }
  :scope body:has(#inp-settings) :is(.card h2, .kpi .v, td.lab, .field label, .isec, .revstats .s b) { color: var(--skin-text); }
  :scope body:has(#inp-settings) :is(.sub, .foot, .model-meta, .field .u, .kpi .l, .revstats .s, .legend) { color: var(--skin-muted); }
  :scope body:has(#inp-settings) :is(.tabs, .subtabs, .seg) button { color: var(--skin-text); background: var(--skin-surface); }
  :scope body:has(#inp-settings) :is(.tabs, .subtabs, .seg) button.active { color: var(--skin-surface); background: var(--skin-accent); }

  /* Paint the login card, page banner and neutral panel headings. Their base
     colour stays opaque. Data rows, icon tints and chart keys have their own ink. */
  :scope[data-skin="aurelia"] {
    --panel-finish: radial-gradient(circle at 100% 0%,
      transparent 2.6rem, var(--finish-line) 2.65rem, transparent 2.72rem 3.35rem,
      var(--finish-line) 3.4rem, transparent 3.47rem),
      linear-gradient(125deg, var(--finish-wash), transparent 56%);
  }
  :scope[data-skin="aurora"] {
    --panel-finish: radial-gradient(ellipse at 78% -38%,
      color-mix(in srgb, var(--skin-detail) 22%, transparent), transparent 62%),
      radial-gradient(ellipse at 0% 100%, var(--finish-wash), transparent 55%);
  }
  :scope[data-skin="sandstone"] {
    --panel-finish: linear-gradient(164deg, transparent 55%, var(--finish-wash) 55% 62%,
      transparent 62% 68%, var(--finish-line) 68% 68.3%, transparent 68.3% 76%,
      var(--finish-wash) 76%);
  }
  :scope[data-skin="ember"] {
    --panel-finish: linear-gradient(132deg, transparent 70%, var(--finish-wash) 70% 76%,
      transparent 76% 81%, var(--finish-line) 81% 81.4%, transparent 81.4%),
      radial-gradient(ellipse at 100% 100%, var(--finish-wash), transparent 58%);
  }
  :scope:is([data-skin="aurelia"], [data-skin="aurora"], [data-skin="sandstone"], [data-skin="ember"]) {
    --finish-wash: color-mix(in srgb, var(--skin-accent) 8%, transparent);
    --finish-line: color-mix(in srgb, var(--skin-ring) 26%, transparent);

    & #login-screen .login-card, & .page-header.ph-hero {
      background-image: var(--panel-finish) !important;
      border-color: var(--skin-rim);
    }
    & :is(.main-card > .card-toolbar, .ws-pane > .ws-pane-head, .glass > .mn-card-head) {
      background-color: var(--skin-surface);
      background-image: var(--panel-finish);
    }
    & #login-screen .login-card > .login-rim {
      background: conic-gradient(from var(--fci-login-glow),
        transparent 0deg 315deg, var(--finish-line) 340deg, var(--skin-accent) 350deg, transparent);
    }
  }

  /* Original uses the green mark, navigation and glass-edged cards of the
     intranet. Only the surface edge is tinted; sign-in keeps its paired ink. */
  :scope[data-skin="original"] {
    & #login-screen .login-card, & .page-header.ph-hero {
      border-color: var(--skin-rim);
      background-image: linear-gradient(155deg, var(--skin-tint), transparent 55%) !important;
    }
    & #login-screen .login-card {
      box-shadow: 0 8px 32px color-mix(in srgb, var(--skin-text) 12%, transparent),
        inset 0 1px var(--skin-rim);
    }
    & :is(.main-card > .card-toolbar, .ws-pane > .ws-pane-head, .glass > .mn-card-head) {
      border-bottom-color: var(--skin-rim);
    }
  }

  /* Desktop's solid scrim covers decorative shell canvases. The editors,
     charts and status animations are separate elements above it. */
  :scope[data-skin="desktop"] {
    scrollbar-color: var(--skin-border) transparent;
    & > body {
      color: var(--skin-text);
      accent-color: var(--skin-accent);
      --accent-blue: var(--skin-accent);
      --accent-glow: var(--skin-tint);
    }
    & body ::selection { background: var(--skin-text); color: var(--skin-surface); }
    & body #page-scrim { background: var(--skin-bg); }
    & #login-screen .login-card, & .page-header.ph-hero,
    & :is(.fci-page-inner .card, .page .main-card, .page .glass, .ws-pane, .tk-pane, .pf-card, .sec-card) {
      border-radius: 5px;
      box-shadow: none;
    }
    & #login-screen .login-card, & .page-header.ph-hero {
      border-color: var(--skin-border);
      background-image: none !important;
    }
    & img[src$="/logo_main.svg"], & fci-nav .nav-brand { filter: grayscale(1); }
    & #page-dashboard .ph-logo-wrap { animation: none; filter: grayscale(1); }
    & fci-nav .nav-user-avatar, & #pf-avatar { background: var(--skin-surface-2); }
    & #pf-sig-preview { border-color: var(--skin-border); }
    & #login-screen .login-back-chevrons { background: none; color: var(--skin-accent); }
    & #login-screen .login-field input:focus { box-shadow: 0 0 0 2px var(--skin-border); }
    & #login-error:not(:empty) { color: var(--skin-text); background: var(--skin-surface-2); }
    & #login-error a { color: var(--skin-accent) !important; }
    & #login-screen h2 {
      font: 600 1.25rem/1.35 system-ui, sans-serif;
      text-transform: none;
      letter-spacing: normal;
    }
    & #login-screen .login-rim, & #login-screen .login-card::after,
    & .page-header.ph-hero::before, & .page-header.ph-hero::after,
    & #page-dashboard .page-header h1:has(.ph-title-pulse)::after { background: none; box-shadow: none; }
    & #page-dashboard .page-header.ph-hero .ph-title-text.ph-title-pulse,
    & .page-header.ph-hero :is(.ph-kicker, .ph-accent-bar, .ph-title-text) {
      animation: none;
      filter: none;
      text-shadow: none;
    }
    /* Legacy widgets draw their own status inks, SVGs, emoji and chart keys. */
    & .live-status, & .scc-icon, & .dash-role, & .sh-role, & .fe-access-role,
    & .fci-load-glint, & .tk-empty-ico, & .tk-stat::before { filter: grayscale(1); }
    & body :is(#page-profile, #page-ticket-system) :is(.pf-fci-select-btn, .tk-fci-select-btn) { background: var(--skin-surface-2); }
    & #page-ticket-system :is(#tk-new, #tk-new-empty, .tk-pill.active) { box-shadow: none; }
    & body .tog-opt.active { color: var(--skin-accent); }
    & [aria-busy]:has(> .fci-load-glint) { background-color: var(--skin-bg) !important; }
    & #page-dashboard :is(.dash-kpi, .news-ico, .badge,
        .dash-growth-card, .dash-drive, .dash-add-btn, .dash-del-btn) { filter: grayscale(1); }
    & #page-dashboard .goal-item { background: var(--skin-surface-2); }
    & .page-header.ph-hero .ph-accent-bar { background: var(--skin-accent); }
    & :is(.main-card > .card-toolbar, .ws-pane > .ws-pane-head, .glass > .mn-card-head) {
      background: var(--skin-surface-2);
      border-bottom-color: var(--skin-border);
    }
  }

  @media (forced-colors: active) {
    :scope :focus-visible { outline-color: Highlight !important; }
  }
}

/* Native intranet review — narrow module navigation and text over data surfaces. */
@scope (html[data-skin]:not([data-skin="original"]):not(.fci-public-scroll):has(> body:not(.fci-public-site))) {
  /* The valuation sidebar becomes a horizontal rail at this source breakpoint. */
  @media (max-width: 860px) {
    :scope #rc-rail .rc-rail-btn { width: auto; }
  }

  /* Desktop's monochrome finish also desaturated the five-series plot and key.
     The native canvas has a transparent field; darken its ink on light cards. */
  :scope[data-skin="desktop"] #page-dashboard [data-card-id="dash-growth"] { filter: none; }
  :scope[data-theme="light"] #page-dashboard #dash-growth-chart {
    --skin-muted: var(--skin-text);
    filter: brightness(.66);
  }

  /* Keep the status hue in the ink and edge without relying on translucent
     badges to provide contrast over every page and skin. */
  :scope #page-ticket-system :is(.ws-prio-medium, .ws-status-in-progress) { --status-hue: #c77708; }
  :scope #page-ticket-system .ws-status-resolved { --status-hue: #199651; }
  :scope #page-ticket-system .ws-prio-high { --status-hue: #df4545; }
  :scope body #page-ticket-system :is(.ws-prio-medium, .ws-prio-high, .ws-status-in-progress, .ws-status-resolved) {
    color: color-mix(in srgb, var(--status-hue) 34%, var(--skin-text));
    background: color-mix(in srgb, var(--status-hue) 7%, var(--skin-surface));
  }

  :scope #page-solar-array .abadge { --asset-hue: #db4949; }
  :scope #page-solar-array .abadge.ab { --asset-hue: #199651; }
  :scope #page-solar-array .abadge.mdc { --asset-hue: #427cda; }
  :scope #page-solar-array .abadge.bld { --asset-hue: #b57412; }
  /* UTL is inline in the source, and the legacy light rule for BLD is important. */
  :scope #page-solar-array .abadge {
    color: color-mix(in srgb, var(--asset-hue) 34%, var(--skin-text)) !important;
    background: color-mix(in srgb, var(--asset-hue) 7%, var(--skin-surface)) !important;
  }
  :scope #page-solar-array :is(.ph-title, #sun-az, #dock-snap-btn, .tb.act .ti) { color: var(--skin-text); }
  :scope #page-solar-array .btn-sync.g {
    background: var(--skin-accent);
    color: var(--skin-surface);
  }

  /* The values accompany named series and their existing coloured swatches.
     Change the printed values independently of the canvas, lines and arrows. */
  :scope #monitoring-card-grid :is(#flow-load, #pf-val-load) { --reading-hue: var(--load, #db4848); }
  :scope #monitoring-card-grid :is(#flow-pv, #pf-val-solar, #ard-watts, #ard2-watts) { --reading-hue: var(--solar, #199651); }
  :scope #monitoring-card-grid :is(#flow-load, #pf-val-load, #flow-pv, #pf-val-solar, #ard-watts, #ard2-watts) {
    color: color-mix(in srgb, var(--reading-hue) 26%, var(--skin-text)) !important;
  }
  :scope #monitoring-card-grid .chart-card-head h2 span[style*="color"] {
    background: #111822;
    padding-inline: .2em;
    border-radius: .2em;
  }
  :scope #monitoring-card-grid .chart-panel-close {
    color: var(--skin-text);
    background: var(--skin-surface-2);
    opacity: 1;
  }
  :scope body .hero-toolbar-controls #sm-chart-toolbar .sm-chart-toolbar-label {
    color: var(--skin-muted);
    opacity: 1;
  }
  :scope #monitoring-card-grid #wx-mdc-react-title {
    color: var(--skin-text);
    background: var(--skin-surface);
    opacity: 1;
  }
  :scope #monitoring-card-grid :is(.sm-wx-range-btn.active, #pf-chart-ranges button.active),
  :scope #page-research-yield-engine :is(.rye-detail-btn, .rye-mobile-tab, .rye-goal-btn, .rye-scenario-btn).active {
    background: var(--skin-accent);
    color: var(--skin-surface);
    border-color: var(--skin-accent);
  }
  :scope[data-theme="light"] #page-research-yield-engine :is(.rye-conf, .rye-verdict-badge) {
    color: var(--skin-text);
  }
}
