/* v0.6.57 — Refinement of the existing v0501/v0650 design system.
 * Presentation only. No grid/page rearrangement, module handles, report
 * document styles, evidence values, chart series, or saved preferences. */

/* v058's high-specificity type rule reads this inherited variable. Bind it
 * to the Studio's actual sizes, including nested labels and the specimen.
 * Don't alter the compact rail's label visibility or flyout geometry. */
#appShell[data-re655-main-icons] #sidebar :is(.re315-navigation>.nav-link,.re85-group-toggle,#ownerNavGroup .nav-link),
#appShell .re655-sample-main {
  --ruction-body-size:var(--re650-font,14px);
}
#appShell[data-re655-fly-icons] .re650-nav-card,
#appShell .re655-sample-sub {
  --ruction-body-size:var(--re650-flyFont,14px);
}
#appShell #sidebar .re85-chevron {--ruction-body-size:20px}
#appShell[data-re655-main-icons] #sidebar :is(.re315-navigation>.nav-link,.re85-group-toggle,#ownerNavGroup .nav-link):focus-visible,
#appShell .re650-nav-card:focus-visible {
  outline:2px solid currentColor!important;
  outline-offset:-3px!important;
}

/* Map the older v0427 dashboard aliases to the already approved brand roles.
 * Restrict the alias to dashboard views, not the Team directory's own
 * appearance preferences, report studio, or the black shell. */
#appShell[data-theme] :is(#overviewView,#analyticsView,#performanceDashboardView,#opportunitiesDashboardView,#pageRankingsView) {
  --re427-ink:var(--ruction-text-primary);
  --re427-muted:var(--ruction-text-muted);
  --re427-surface:var(--ruction-surface-card);
  --re427-subtle:var(--ruction-surface-raised);
  --re427-line:var(--ruction-border);
  --re427-accent:var(--ruction-interactive-ink);
  --re427-accent-wash:color-mix(in srgb,var(--ruction-elements-blue) 10%,var(--ruction-surface-card));
  --re427-teal:var(--ruction-elements-teal);
  --re427-shadow:var(--v09-shadow);
}
#appShell[data-theme] #overviewView {
  --re429-surface:var(--ruction-surface-card);
  --re429-inset:var(--ruction-surface-raised);
  --re429-text:var(--ruction-text-primary);
  --re429-muted:var(--ruction-text-muted);
  --re429-line:var(--ruction-border);
  --re429-primary:var(--ruction-action);
}
#appShell #overviewView .re423-outcome:not([data-re431-styled]):not([data-re431-styled] *) {
  background-image:none!important;
  background-color:var(--ruction-surface-card)!important;
  border-color:var(--ruction-border)!important;
}

/* Restore the intended metric hierarchy lost under the legacy 13px rule.
 * Use local inherited values, rather than another global !important reset. */
#appShell #overviewView .re423-pillar .re429-pillar-body>strong {
  --ruction-body-size:clamp(19px,2vw,25px);
  --ruction-metric-size:var(--ruction-body-size);
  font-variant-numeric:tabular-nums;
}
#appShell #overviewView .re429-pillar-metrics b {
  --ruction-body-size:clamp(17px,1.5vw,20px);
  font-variant-numeric:tabular-nums;
}
#appShell #analyticsView .re405-value {
  --ruction-body-size:clamp(18px,2vw,28px);
  font-variant-numeric:tabular-nums;
}
#appShell #pageRankingsView .re2a-kpis strong {
  --ruction-body-size:24px;
  font-variant-numeric:tabular-nums;
}
#appShell #pageRankingsView .re2a-kpis {
  flex-wrap:wrap;
}
#appShell #pageRankingsView .re2a-kpis>div {
  min-width:0;
  flex:1 1 92px;
  background:var(--ruction-surface-raised);
  border-color:var(--ruction-border);
  color:var(--ruction-text-primary);
}

/* Fixed Impact: retain every card, control, chart color, and grid position. */
#appShell #impactView .re505-page {
  background-image:none;
}
#appShell #impactView .re505-kpi {
  background-image:none!important;
}
#appShell #impactView .re505-kpi strong {
  --ruction-body-size:clamp(20px,1.8vw,25px);
  font-variant-numeric:tabular-nums;
  min-width:0;
  overflow-wrap:anywhere;
}
#appShell #impactView #re505SourceTable :is(td,th) {
  font-variant-numeric:tabular-nums;
}

/* The recognized native primary actions remain Elements blue, with a white
 * foreground that meets 4.5:1. Explicit per-module button themes win. */
#appShell #overviewView :is(.re423-card-links button,.re407-shortcut-open,.re56-tiny-link,.re56-linkbutton,.re429-primary):not([data-re431-buttons='1'] *),
#appShell .re655-studio>.re650-fly-head>.re650-control {
  background:var(--ruction-action)!important;
  border-color:var(--ruction-action)!important;
  color:var(--ruction-action-text)!important;
}
#appShell #overviewView :is(.re423-card-links button,.re407-shortcut-open,.re56-tiny-link,.re56-linkbutton,.re429-primary):not([data-re431-buttons='1'] *):hover,
#appShell .re655-studio>.re650-fly-head>.re650-control:hover {
  background:var(--ruction-action-hover)!important;
  border-color:var(--ruction-action-hover)!important;
}

/* Studio: calmer spacing, conspicuous active section and keyboard focus.
 * The preview uses the exact same saved state; no new storage or controls. */
#appShell .re655-studio>.re650-fly-head {
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  flex-wrap:wrap;
}
#appShell .re655-studio .re655-tabs button[aria-pressed=true] {
  background:var(--ruction-surface-raised);
  color:var(--ruction-interactive-ink);
  border-color:var(--ruction-interactive-ink)!important;
  box-shadow:inset 0 -3px var(--ruction-interactive-ink);
}
#appShell .re655-studio :is(button,input,select):focus-visible {
  outline:2px solid var(--ruction-interactive-ink)!important;
  outline-offset:2px;
}
#appShell .re655-studio :is(.re655-label,.re655-field-head)>:is(span,strong) {
  white-space:normal;overflow-wrap:anywhere;
}
#appShell .re655-studio .re655-field {
  padding-block:12px;
}
#appShell .re655-studio .re655-status {line-height:1.5}

/* The native module options dialog is appended to body, not #appShell.
 * Its old always-navy background leaked into light mode. Use the same
 * approved tokens (provided by v0501), only on the actual options dialog. */
body:has(#appShell) .re376-dialog.re402-options {
  color:var(--ruction-text-primary)!important;
  background:var(--ruction-surface-card)!important;
  border-color:var(--ruction-border)!important;
}
body:has(#appShell) .re376-dialog.re402-options :is(label,legend,h3,p,span,small,output,strong) {
  color:var(--ruction-text-primary)!important;
}
body:has(#appShell) .re376-dialog.re402-options :is(.re431-help,.re432-preset-note,.re402-content-note) {
  color:var(--ruction-text-muted)!important;
}
body:has(#appShell) .re376-dialog.re402-options :is(.re431-style-settings,.re402-content-settings) {
  background:var(--ruction-surface-raised);
  border-color:var(--ruction-border);
}
body:has(#appShell) .re376-dialog.re402-options :is(select,input:not([type=checkbox]):not([type=radio]):not([type=color])) {
  background:var(--ruction-surface-card)!important;
  color:var(--ruction-text-primary)!important;
  border-color:var(--ruction-border)!important;
}
body:has(#appShell) .re376-dialog.re402-options input::placeholder {
  color:var(--ruction-text-muted)!important;
}
body:has(#appShell) .re376-dialog.re402-options .re376-dialog-actions {
  background:var(--ruction-surface-card);
}
body:has(#appShell) .re376-dialog.re402-options :is(.re376-dialog-actions button[type=button],.re431-reset-style) {
  background:var(--ruction-surface-raised)!important;
  color:var(--ruction-text-primary)!important;
  border-color:var(--ruction-border)!important;
}
body:has(#appShell) .re376-dialog.re402-options .re376-dialog-actions button[type=submit] {
  background:var(--ruction-action)!important;
  color:var(--ruction-action-text)!important;
  border-color:var(--ruction-action)!important;
}
body:has(#appShell) .re376-dialog.re402-options .re376-dialog-actions button[type=submit]:hover {
  background:var(--ruction-action-hover)!important;
  border-color:var(--ruction-action-hover)!important;
}
body:has(#appShell) .re376-dialog.re402-options :is(button,select,input):focus-visible {
  outline:2px solid var(--ruction-interactive-ink)!important;
  outline-offset:2px;
}
@media(max-width:480px) {
  #appShell .re655-studio .re655-color-line {
    grid-template-columns:44px minmax(0,1fr);
  }
  #appShell .re655-studio .re655-color-line .re655-label:last-child {
    grid-column:1/-1;
  }
  #appShell .re655-studio .re655-toolbar .re655-label {
    min-width:0;max-width:100%;
  }
  #appShell .re655-studio .re655-label span {flex:0 1 auto}
}
@media(prefers-reduced-motion:reduce) {
  #appShell .re655-studio :is(button,input,select) {transition:none!important}
}
