/* CPGCBL EMD R11.5.3 | Theme B / Neon Control Room Dark
   CALM-BORDER CORRECTION ONLY: no markup, JavaScript, backend, or Work Form changes.
   Keep readable text, status hues, selected-state meaning and keyboard focus.
   Loaded LAST, after R11.5.2 drawer styling. */

/* 1. Reduce the underlying dark-theme line/glow tokens used by Assets,
      Inspections, Greasing, Spares and Reports. No other theme is affected. */
body.r107-ui[data-theme="dark"] {
  --line: #193a4c !important;
  --r113-edge: #1b3b4e;
  --r113-glow: rgba(5, 177, 211, .055);
  --r1152-asset-edge: #1b3b4e;
}

/* 2. Daily Work: one consistent, low-contrast edge throughout the dashboard.
      The former 52% tinted KPI border competed with the numbers and statuses. */
body.r107-ui[data-theme="dark"] #content .r114-dashboard {
  --dw-line: #1a3b4d;
  --dw-status-line: #285657;
  --dw-glow: 0 3px 14px rgba(0, 0, 0, .17);
  --dw-shadow: 0 4px 16px rgba(0, 0, 0, .19);
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard :is(
  .r114-hero, .r114-filters, .r114-panel, .r114-today-stat,
  .r114-table-scroll, .r114-control, .r114-btn, .r114-quick,
  .r114-date-badge, .r114-view
) {
  border-color: #1a3b4d !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard :is(
  .r114-hero, .r114-filters, .r114-panel, .r114-today-stat
) {
  box-shadow: 0 4px 17px rgba(0, 0, 0, .17) !important;
}
/* KPI outlines: no coloured full rectangles; keep the accent on its icon. */
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi {
  border: 1px solid #203b4d !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .018),
              0 4px 13px rgba(0, 0, 0, .17) !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi::before {
  height: 2px !important;
  opacity: .24 !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi:hover {
  border-color: #315567 !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .23) !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi.chosen {
  border-color: #3d7080 !important;
  box-shadow: inset 2px 0 0 var(--kpi-tone), 0 6px 17px rgba(0, 0, 0, .21) !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi.chosen::before {
  opacity: .5 !important;
}
/* Active filters must remain distinct, without a bright neon outline. */
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-quick.active {
  background: #123749 !important;
  border-color: #326073 !important;
  color: #f1fbff !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-quick:hover {
  border-color: #386277 !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-status-note {
  border-color: #285658 !important;
  box-shadow: none !important;
}
/* Keyboard use still gets a clearly visible focus state. */
body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-control:focus-within {
  border-color: #159eb0 !important;
  box-shadow: 0 0 0 2px rgba(12, 202, 226, .22) !important;
}
body.r107-ui[data-theme="dark"] #content .r114-dashboard :is(
  .r114-kpi, .r114-quick, .r114-btn, .r114-view
):focus-visible {
  outline: 2px solid #55deea !important;
  outline-offset: 2px !important;
}

/* 3. Old-style cards, asset details and the drawer's stat fields had an
      additional border/glow. Reduce only structural edges, not active badges. */
body.r107-ui[data-theme="dark"] #content :is(
  .r5-detail, .detail, .tech-field, .r79-spec-card, .r5-mini,
  .r5-card, .card, .r79-panel-card,
  .r5-kpi, .r4-kpi, .parity-kpi, .kpi, .r79-kpi
),
body.r107-ui[data-theme="dark"] #drawer:not(.r1152-workdrawer) .drawerbody :is(
  .r5-detail, .detail, .tech-field, .r79-spec-card, .r79-dim-grid > div,
  .r5-mini, .r5-drawer-section, .r79-media-card
) {
  border-color: #1c3e51 !important;
  box-shadow: none !important;
}
body.r107-ui[data-theme="dark"] #content :is(
  .r5-card, .card, .r79-panel-card
) {
  box-shadow: 0 4px 15px rgba(0, 0, 0, .15) !important;
}
body.r107-ui[data-theme="dark"] #content :is(
  .r5-kpi, .r4-kpi, .parity-kpi, .kpi, .r79-kpi
) {
  border-top-color: #275365 !important;
}
body.r107-ui[data-theme="dark"] #content :is(
  .r5-kpi, .r4-kpi, .parity-kpi, .kpi
)::after {
  opacity: .28 !important;
}
body.r107-ui[data-theme="dark"] #content :is(
  input:not([type="checkbox"]), select, textarea, .r112-editor
) {
  border-color: #1d4053 !important;
}
body.r107-ui[data-theme="dark"] #content :is(
  input, select, textarea, .r112-editor
):focus-visible {
  border-color: #20a9c0 !important;
  outline: 2px solid rgba(44, 205, 231, .5) !important;
  outline-offset: 2px !important;
}

/* 4. Retain the R11.5.2 reference-layout drawer: no layout or JS changes. */
body.r107-ui[data-theme="dark"] #drawer.r1152-workdrawer {
  --r1152-border: #1a384a;
}
/* The danger zone deliberately keeps its warning border and readable text. */
body.r107-ui[data-theme="dark"] #drawer.r1152-workdrawer .r104-danger-zone {
  border-color: #614251 !important;
  border-left-color: #eb8194 !important;
}
/* Reports use subtler card outlines; the KPI numbers retain their colours. */
body.r107-ui[data-theme="dark"] #content .r115-report :is(
  .r115-card, .r115-hero, .r115-kpi, .r115-today > div, .r115-table-scroll
) {
  border-color: #1d4052 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15) !important;
}
body.r107-ui[data-theme="dark"] #content .r115-report .r115-kpi::before {
  opacity: .32 !important;
}
/* Preserve the visual priority of the primary action and side-nav indicator.
   The surrounding button/side-border should not look like another KPI. */
body.r107-ui[data-theme="dark"] .top :is(.btn, .profile-chip, .freshness) {
  border-color: #244759 !important;
}
body.r107-ui[data-theme="dark"] .side .navbtn.active {
  border-color: #2a6577 !important;
}
@media (prefers-contrast: more) {
  body.r107-ui[data-theme="dark"] #content .r114-dashboard .r114-kpi,
  body.r107-ui[data-theme="dark"] #content .r114-dashboard :is(.r114-control,.r114-panel,.r114-filters) {
    border-color: #5a8da3 !important;
  }
}
