/*
 * SHARED_BUILDER_001 — compact Report Setup and workspace-mode isolation.
 *
 * Scope:
 *   - Main System Builder Report Setup and Selection Logic readability.
 *   - Race Profiler Profile Areas compaction.
 *   - Pro-only Race Qualification report-group isolation.
 *
 * No report, filter, saved-state or Pro Canvas behaviour is changed.
 */

/* ======================================================================
   SHARED REPORT / PROFILE SETUP — EVIDENCE FIRST, ACTIONS SECOND
   ====================================================================== */
body[data-workspace-mode="system_builder"] #builder-actions > .section-body,
body[data-workspace-mode="race_profiler"] #builder-actions > .section-body{
  padding:10px 12px 12px!important;
}

body[data-workspace-mode="system_builder"] #builder-actions .builder-action-grid.report-groups-layout,
body[data-workspace-mode="race_profiler"] #builder-actions .builder-action-grid.report-groups-layout{
  display:grid!important;
  align-items:stretch!important;
  gap:9px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .builder-action-grid.report-groups-layout{
  grid-template-columns:minmax(0,1.35fr) minmax(300px,.65fr)!important;
  grid-template-areas:
    "groups groups"
    "reports management"!important;
}
body[data-workspace-mode="race_profiler"] #builder-actions .builder-action-grid.report-groups-layout{
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-areas:
    "groups"
    "reports"!important;
}

body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-card,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-card{
  grid-area:groups!important;
  min-width:0!important;
  min-height:0!important;
  padding:9px 10px!important;
  border:1px solid rgba(26,174,173,.24)!important;
  border-radius:13px!important;
  background:
    linear-gradient(135deg,rgba(255,255,255,.96),rgba(239,250,255,.88) 56%,rgba(232,252,247,.84))!important;
  box-shadow:0 9px 22px rgba(26,55,105,.045),inset 0 1px 0 rgba(255,255,255,.95)!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-control-card,
body[data-workspace-mode="race_profiler"] #builder-actions .report-control-card{
  grid-area:reports!important;
  min-width:0!important;
  min-height:0!important;
  padding:9px 10px!important;
  border:1px solid rgba(65,105,190,.18)!important;
  border-radius:13px!important;
  background:linear-gradient(145deg,rgba(255,255,255,.96),rgba(244,248,255,.92))!important;
  box-shadow:0 9px 22px rgba(26,55,105,.04),inset 0 1px 0 rgba(255,255,255,.95)!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .system-management-card{
  grid-area:management!important;
  min-width:0!important;
  min-height:0!important;
  display:grid!important;
  grid-template-rows:auto minmax(0,1fr) auto!important;
  align-items:start!important;
  gap:6px!important;
  padding:9px 10px!important;
  border:1px solid rgba(74,119,196,.18)!important;
  border-radius:13px!important;
  background:linear-gradient(145deg,rgba(255,255,255,.96),rgba(241,247,255,.90))!important;
  box-shadow:0 9px 22px rgba(26,55,105,.04),inset 0 1px 0 rgba(255,255,255,.95)!important;
}
body[data-workspace-mode="race_profiler"] #builder-actions .system-management-card,
body[data-workspace-mode="system_builder"] #builder-actions #proSnapshotCard,
body[data-workspace-mode="race_profiler"] #builder-actions #proSnapshotCard{
  display:none!important;
}

body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-header,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-header{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) auto!important;
  align-items:center!important;
  gap:9px!important;
  margin:0 0 7px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-header .card-title,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-header .card-title,
body[data-workspace-mode="system_builder"] #builder-actions .report-card-heading,
body[data-workspace-mode="race_profiler"] #builder-actions .report-card-heading,
body[data-workspace-mode="system_builder"] #builder-actions .system-management-card > .card-title{
  margin:0!important;
  color:#17345d!important;
  font-size:9.5px!important;
  line-height:1.1!important;
  font-weight:950!important;
  letter-spacing:.11em!important;
  text-transform:uppercase!important;
}
body[data-workspace-mode="system_builder"] #builder-actions :is(.report-table-groups-header p,.report-table-groups-intro),
body[data-workspace-mode="race_profiler"] #builder-actions :is(.report-table-groups-header p,.report-table-groups-intro){
  max-width:none!important;
  margin:3px 0 0!important;
  color:#506883!important;
  font-size:8.8px!important;
  line-height:1.25!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-table-group-count,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-group-count{
  min-height:23px!important;
  padding:4px 8px!important;
  border-radius:999px!important;
  font-size:8px!important;
  line-height:1!important;
}

body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-list,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-list{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:5px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-toggle,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-toggle{
  min-width:0!important;
  min-height:32px!important;
  grid-template-columns:14px minmax(0,1fr) auto 17px!important;
  gap:6px!important;
  padding:5px 7px!important;
  border-radius:9px!important;
  color:#18395f!important;
  font-size:8.8px!important;
  line-height:1.15!important;
  box-shadow:0 4px 11px rgba(20,48,91,.025)!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-toggle input,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-toggle input{
  width:14px!important;
  height:14px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-toggle > span:first-of-type,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-toggle > span:first-of-type{
  min-width:0!important;
  overflow:visible!important;
  text-overflow:clip!important;
  white-space:normal!important;
  line-height:1.15!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-toggle small,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-toggle small{
  font-size:7.6px!important;
  white-space:nowrap!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-toggle em,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-toggle em{
  padding:2px 5px!important;
  font-size:7px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-group-help,
body[data-workspace-mode="race_profiler"] #builder-actions .report-group-help{
  width:17px!important;
  height:17px!important;
  font-size:8px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-note,
body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-note{
  margin-top:6px!important;
  padding:5px 7px!important;
  min-height:0!important;
  border-radius:8px!important;
  font-size:7.9px!important;
  line-height:1.2!important;
}

/* Keep Stage-5 report choices exclusively inside Professional Systems Builder. */
body[data-workspace-mode="system_builder"] #reportTableGroupsList .pro-only-report-group,
body[data-workspace-mode="race_profiler"] #reportTableGroupsList .pro-only-report-group{
  display:none!important;
}
body[data-workspace-mode="pro_system_builder"] #reportTableGroupsList .pro-only-report-group:not([hidden]){
  display:grid!important;
}

/* ======================================================================
   COMPACT REPORT ACTIONS / SYSTEM MANAGEMENT
   ====================================================================== */
body[data-workspace-mode="system_builder"] #builder-actions .report-card-heading,
body[data-workspace-mode="race_profiler"] #builder-actions .report-card-heading{
  margin-bottom:6px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-option-list,
body[data-workspace-mode="race_profiler"] #builder-actions .report-option-list{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:7px!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-option,
body[data-workspace-mode="race_profiler"] #builder-actions .report-option{
  min-width:0!important;
  min-height:84px!important;
  display:grid!important;
  grid-template-rows:auto minmax(0,1fr)!important;
  align-content:start!important;
  gap:5px!important;
  padding:7px 8px!important;
  border:1px solid rgba(80,113,176,.16)!important;
  border-radius:10px!important;
  background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(241,247,255,.90))!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-option button,
body[data-workspace-mode="race_profiler"] #builder-actions .report-option button{
  min-width:0!important;
  min-height:32px!important;
  height:32px!important;
  padding:6px 9px!important;
  border-radius:9px!important;
  font-size:8.8px!important;
  line-height:1.05!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .report-option-copy,
body[data-workspace-mode="race_profiler"] #builder-actions .report-option-copy{
  margin:0!important;
  color:#526a84!important;
  font-size:8.2px!important;
  line-height:1.27!important;
}

body[data-workspace-mode="system_builder"] #builder-actions .system-management-card .management-copy{
  margin:0!important;
  color:#526a84!important;
  font-size:8.4px!important;
  line-height:1.28!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .system-management-card .action-row{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  justify-content:stretch!important;
  align-items:stretch!important;
  gap:6px!important;
  margin:0!important;
}
body[data-workspace-mode="system_builder"] #builder-actions .system-management-card .action-row .btn{
  min-width:0!important;
  min-height:31px!important;
  height:31px!important;
  padding:5px 7px!important;
  border-radius:9px!important;
  font-size:8.5px!important;
  line-height:1!important;
}

/* ======================================================================
   MAIN SYSTEM BUILDER — SELECTION LOGIC READABILITY
   ====================================================================== */
body[data-workspace-mode="system_builder"] #system .refined-selection-tile{
  color:#112b4d!important;
  border:1px solid rgba(38,137,205,.23)!important;
  background:
    radial-gradient(circle at 100% 0%,rgba(39,205,194,.16),transparent 38%),
    linear-gradient(145deg,rgba(232,246,255,.98),rgba(235,253,248,.94))!important;
  box-shadow:0 10px 24px rgba(21,63,112,.055),inset 0 1px 0 rgba(255,255,255,.95)!important;
}
body[data-workspace-mode="system_builder"] #system .refined-selection-tile .mini{
  color:#2f6590!important;
}
body[data-workspace-mode="system_builder"] #system .refined-selection-tile strong{
  color:#10294c!important;
  text-shadow:none!important;
}
body[data-workspace-mode="system_builder"] #system .refined-selection-tile p{
  color:#435f7c!important;
  text-shadow:none!important;
}
body[data-workspace-mode="system_builder"] #system .selection-mode-buttons .mode-button{
  color:#263f64!important;
  border-color:rgba(60,97,162,.18)!important;
  background:rgba(255,255,255,.88)!important;
  box-shadow:0 5px 13px rgba(24,55,101,.04)!important;
}
body[data-workspace-mode="system_builder"] #system .selection-mode-buttons .mode-button.selected{
  color:#fff!important;
  border-color:rgba(38,121,211,.38)!important;
  background:linear-gradient(135deg,#285ec7,#3b79df 58%,#14a8b7)!important;
  box-shadow:0 8px 18px rgba(38,94,190,.18)!important;
}
body[data-workspace-mode="system_builder"] #system :is(.ranking-card,.rank-range-card){
  color:#152f51!important;
  background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(246,249,255,.93))!important;
}
body[data-workspace-mode="system_builder"] #system :is(.ranking-card,.rank-range-card) .card-title{
  color:#24466e!important;
}
body[data-workspace-mode="system_builder"] #system :is(.ranking-card,.rank-range-card) .card-copy{
  color:#60748c!important;
}
body[data-workspace-mode="system_builder"] #system .ranking-methods .chip{
  color:#2e4b70!important;
  border-color:rgba(75,106,165,.17)!important;
  background:rgba(255,255,255,.88)!important;
}
body[data-workspace-mode="system_builder"] #system .ranking-methods .chip.selected{
  color:#08736d!important;
  border-color:rgba(13,145,141,.30)!important;
  background:linear-gradient(180deg,rgba(226,252,247,.96),rgba(213,247,240,.90))!important;
}
body[data-workspace-mode="system_builder"] #system .ranking-methods .chip.disabled,
body[data-workspace-mode="system_builder"] #system .ranking-methods .chip[aria-disabled="true"],
body[data-workspace-mode="system_builder"] #system .ranking-methods .chip.control-disabled{
  opacity:.68!important;
  color:#75859a!important;
  border-color:rgba(112,132,165,.14)!important;
  background:rgba(242,246,251,.80)!important;
}
body[data-workspace-mode="system_builder"] #system .rank-helper{
  color:#4d6380!important;
  background:rgba(246,249,253,.90)!important;
}

/* ======================================================================
   RESPONSIVE REPORT SETUP CONTRACT
   ====================================================================== */
@media(max-width:1900px){
  body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-list,
  body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-list{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
}
@media(max-width:1220px){
  body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-list,
  body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-list{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  body[data-workspace-mode="system_builder"] #builder-actions .builder-action-grid.report-groups-layout{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-areas:
      "groups"
      "reports"
      "management"!important;
  }
  body[data-workspace-mode="system_builder"] #builder-actions .system-management-card .action-row{
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
  }
}
@media(max-width:1000px){
  body[data-workspace-mode="system_builder"] #builder-actions .report-table-groups-list,
  body[data-workspace-mode="race_profiler"] #builder-actions .report-table-groups-list,
  body[data-workspace-mode="system_builder"] #builder-actions .report-option-list,
  body[data-workspace-mode="race_profiler"] #builder-actions .report-option-list{
    grid-template-columns:1fr!important;
  }
  body[data-workspace-mode="system_builder"] #builder-actions .system-management-card .action-row{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
