/* Earthing Grid control material: one visible frame, 12 px radius, restrained
   8 px blur / 110% saturation with a solid fallback. Reading surfaces stay opaque.
   Calculation, document and printed-report behaviour are unchanged. */
@media screen {
  body.page-earthing {
    --mi-surface: #fff;
    --mi-tint: rgba(255,255,255,.88);
    --mi-highlight: rgba(255,255,255,.98);
    --mi-edge: #8996a8;
    --mi-shadow: 0 2px 6px rgba(30,45,70,.06);
    --mi-selected: #dcecff;
    --mi-selected-ink: #0055a4;
  }
  html[data-theme="night"] body.page-earthing {
    --mi-surface: #2b2e39;
    --mi-tint: rgba(43,46,57,.94);
    --mi-highlight: rgba(62,66,82,.9);
    --mi-edge: #7d879c;
    --mi-shadow: 0 2px 6px rgba(0,0,0,.16);
    --mi-selected: #354f70;
    --mi-selected-ink: #d1e8ff;
  }
  body.page-earthing #earthing-inputs :is(.field, select.dd, .seg-radio, .vd-adv-toggle),
  body.page-earthing #earthing-analysis :is(.vd-tab, .lyr, .eg-zoom button, .earthing-review-input),
  body.page-earthing #earthing-document :is(.add-btn, .earthing-document-button),
  body.page-earthing #amp-workspace button {
    background: var(--mi-surface) !important;
    border: 1px solid var(--mi-edge) !important;
    border-radius: 12px !important;
    box-shadow: var(--mi-shadow) !important;
  }
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    body.page-earthing #earthing-inputs :is(.field, select.dd, .seg-radio, .vd-adv-toggle),
    body.page-earthing #earthing-analysis :is(.vd-tab, .lyr, .eg-zoom button, .earthing-review-input),
    body.page-earthing #earthing-document :is(.add-btn, .earthing-document-button),
    body.page-earthing #amp-workspace button {
      background: linear-gradient(160deg,var(--mi-highlight),var(--mi-tint)) !important;
      backdrop-filter: blur(8px) saturate(110%);
      -webkit-backdrop-filter: blur(8px) saturate(110%);
    }
  }
  body.page-earthing #earthing-inputs .field > input {
    border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; outline: none !important;
  }
  body.page-earthing #earthing-inputs .seg-radio label { border: 0 !important; background: transparent !important; box-shadow: none !important; border-radius: 9px !important; }
  body.page-earthing #earthing-inputs .seg-radio label.active,
  body.page-earthing #earthing-analysis .vd-tab.active,
  body.page-earthing #earthing-analysis .lyr[aria-pressed="true"] { background: var(--mi-selected) !important; color: var(--mi-selected-ink) !important; }
  body.page-earthing #earthing-document #earthing-document-save { background: var(--eg-accent) !important; color: var(--eg-on-accent) !important; border-color: var(--eg-accent) !important; }
  body.page-earthing #earthing-inputs .field:has(:focus-visible),
  body.page-earthing #earthing-inputs select.dd:focus-visible,
  body.page-earthing #earthing-inputs .vd-adv-toggle:focus-visible,
  body.page-earthing #earthing-analysis :is(button,summary,a,svg,[tabindex]):focus-visible,
  body.page-earthing #earthing-document :is(button,a,[contenteditable]):focus-visible,
  body.page-earthing #amp-workspace button:focus-visible,
  body.page-earthing :is(#amp-workspace-dialog,dialog.amp-workspace-dialog) :focus-visible {
    outline: 2px solid var(--eg-accent) !important; outline-offset: 3px;
  }
  body.page-earthing #earthing-inputs .seg-radio label:focus-within { outline: 2px solid var(--eg-accent) !important; outline-offset: -3px; }
  body.page-earthing #earthing-inputs select option { background: var(--mi-surface); color: var(--eg-ink); }
  body.page-earthing #earthing-inputs :is(.field:has([aria-invalid="true"]), select[aria-invalid="true"], .seg-radio:has([aria-invalid="true"])) {
    border-color: var(--eg-red) !important; box-shadow: inset 3px 0 0 var(--eg-red) !important;
  }
  @media (prefers-reduced-transparency:reduce), (prefers-contrast:more) {
    body.page-earthing #earthing-inputs :is(.field, select.dd, .seg-radio, .vd-adv-toggle),
    body.page-earthing #earthing-analysis :is(.vd-tab, .lyr, .eg-zoom button, .earthing-review-input),
    body.page-earthing #earthing-document :is(.add-btn, .earthing-document-button),
    body.page-earthing #amp-workspace button {
      background: var(--mi-surface) !important; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none !important;
    }
    body.page-earthing #earthing-inputs .seg-radio label.active,
    body.page-earthing #earthing-analysis .vd-tab.active,
    body.page-earthing #earthing-analysis .lyr[aria-pressed="true"] { background: var(--mi-selected) !important; }
  }
  @media (forced-colors:active) {
    /* Invalid fields and groups keep a non-colour frame: the forced frame above replaces the red border. */
    body.page-earthing :is(.field:has([aria-invalid="true"]), select[aria-invalid="true"], [data-invalid="true"]) { outline: 2px solid Mark !important; outline-offset: 1px; }
    body.page-earthing #earthing-inputs :is(.field, select.dd, .seg-radio, .vd-adv-toggle),
    body.page-earthing #earthing-analysis :is(.vd-tab, .lyr, .eg-zoom button, .earthing-review-input),
    body.page-earthing #earthing-document :is(.add-btn, .earthing-document-button),
    body.page-earthing #amp-workspace button {
      background: Canvas !important; border-color: ButtonText !important; box-shadow: none !important; backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    body.page-earthing #earthing-inputs .seg-radio label.active,
    body.page-earthing #earthing-analysis .vd-tab.active,
    body.page-earthing #earthing-analysis .lyr[aria-pressed="true"] { background: Highlight !important; color: HighlightText !important; forced-color-adjust: none; }
    body.page-earthing #earthing-inputs .field:has(:focus-visible), body.page-earthing #earthing-inputs select.dd:focus-visible { outline-color: Highlight !important; }
  }
}
