/* Race Lens Research workspace */

/* Chart shell + equity line toggles. Base rules first - the range-chart
   overrides further down rely on being more specific, not on order. */
.rl-hist-chart--full {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 12px 14px 10px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(127, 156, 180, 0.2);
  box-sizing: border-box;
}
.rl-hist-chart-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.rl-hist-chart-head--equity {
  flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.rl-hist-chart-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; opacity: 0.75;
}

.rl-equity-toggles {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rl-equity-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(127,156,180,0.35);
  background: rgba(255,255,255,0.8);
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.45;
}
.rl-equity-toggle.on { opacity: 1; border-color: rgba(127,156,180,0.7); }
.rl-equity-swatch {
  width: 14px; height: 3px; border-radius: 1px;
  background: var(--swatch, #57606a);
  flex: 0 0 auto;
}
.rl-equity-toggle.dashed .rl-equity-swatch {
  background: repeating-linear-gradient(
    90deg,
    var(--swatch, #57606a) 0 5px,
    transparent 5px 8px
  );
}
.rl-equity-toggle-label { font-weight: 600; }
.rl-equity-toggle-total {
  font-variant-numeric: tabular-nums; font-weight: 700;
}

.rl-chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}
.rl-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.rl-view-cards,
.rl-view-research {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  flex: 1 1 auto;
  min-width: 0;
}
.rl-view-research {
  gap: 10px;
  padding: 0 0 8px;
}
.rl-research-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rl-border, #ddd);
}
.rl-research-dims {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.rl-research-dim {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--rl-text-muted, #666);
}
.rl-research-dim select {
  min-width: 140px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
}
.rl-research-actions {
  margin-left: auto;
}
.rl-research-run {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  border: 0;
  background: var(--blue-accent, #2563eb);
  color: #fff;
  cursor: pointer;
}
.rl-research-run:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.rl-research-meta {
  margin: 0;
  font-size: 12px;
  color: var(--rl-text-muted, #666);
}
.rl-research-pnl {
  border: 1px solid var(--rl-border, #ddd);
  background: var(--rl-bg-tab, #f7f7f7);
  padding: 10px 12px;
}
.rl-research-pnl-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.rl-research-pnl-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
}
.rl-research-pnl-grid .k {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: #777;
  font-weight: 600;
}
.rl-research-pnl-grid .v {
  font-size: 15px;
  font-weight: 700;
}
.rl-research-table-wrap {
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
  border: 1px solid var(--rl-border, #ddd);
}
.rl-research-table {
  width: 100%;
  font-size: 12px;
}
.rl-research-table th,
.rl-research-table td {
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}
.rl-research-table th {
  position: sticky;
  top: 0;
  background: var(--rl-bg-tab, #f0f0f0);
  z-index: 1;
}
.rl-research-empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: var(--gray-lightesty, #ececec);
  border-radius: 2px;
}
.rl-research-empty-inner {
  max-width: 420px;
  text-align: center;
  padding: 24px;
  color: #444;
}
.rl-research-empty-inner h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.rl-research-empty-inner p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.rl-research-side-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

.rl-research-project {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.rl-research-project-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rl-text-muted, #666);
}
.rl-research-project-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--rl-text, #222);
}
.rl-research-dims-summary {
  font-size: 12px;
  color: var(--rl-text-muted, #666);
}

.rl-research-charts {
  flex: 0 0 auto;
  min-height: 0;
}
.rl-research-equity-chart {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--rl-border, #ddd);
  border-radius: 3px;
  background: var(--rl-bg-panel, #fff);
}
.rl-research-equity-chart canvas {
  width: 100% !important;
  max-height: 220px;
}

.rl-research-run-side {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  box-sizing: border-box;
}
/* Filters changed since the last run: chart picks set the filter, you press Run. */
.rl-research-run.is-stale {
  outline: 2px solid rgba(191, 135, 0, 0.9);
  outline-offset: -2px;
}
.rl-research-charts-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
  flex: 0 0 auto;
  min-height: 0;
}
.rl-research-charts-row .rl-research-equity-chart {
  flex: 1 1 420px;
  min-width: 0;
  margin: 0;
}
.rl-research-stats {
  flex: 0 1 260px;
  min-width: 220px;
  max-width: 300px;
  border: 1px solid var(--rl-border, #ddd);
  border-radius: 3px;
  background: var(--rl-bg-panel, #fff);
  padding: 10px 12px;
}
.rl-research-stats-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0 0 8px;
  color: var(--rl-text-muted, #666);
}
.rl-research-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rl-research-stats-table th,
.rl-research-stats-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(127,156,180,0.18);
  text-align: right;
}
.rl-research-stats-table th.lbl,
.rl-research-stats-table td.lbl {
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--rl-text-muted, #666);
}
.rl-research-stats-table thead th {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--rl-text-muted, #666);
}
.rl-research-stats-title { display: none; }

.rl-research-charts-stack {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  /* flex-direction: column; */
  gap: 12px;
}
.rl-research-charts-stack .rl-research-equity-chart {
  /* flex: 0 0 auto; */
  /* width: 100%; */
}
.rl-research-quals {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--rl-border, #ddd);
  border-radius: 3px;
  background: var(--rl-bg-panel, #fff);
  flex: 1 1 auto;
  min-height: min(420px, calc(100vh - 340px));
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.rl-research-quals-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 6px;
}
.rl-research-quals-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rl-research-quals-stub {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--rl-text-muted, #666);
}
.rl-research-sens-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
  margin: 12px 0 0;
}
.rl-research-sens-chart {
  flex: 1 1 320px;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--rl-border, #ddd);
  border-radius: 3px;
  background: var(--rl-bg-panel, #fff);
}
.rl-research-sens-chart .rl-chart-wrap--bar {
  height: 200px;
  max-height: 220px;
}

.rl-research-quals-table {
  width: 100%;
  font-size: 12px;
}
.rl-research-quals-table th,
.rl-research-quals-table td {
  padding: 4px 6px;
  text-align: left;
  white-space: nowrap;
}
.rl-research-quals .rl-research-table-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  margin-top: 6px;
}
.rl-research-quals-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.rl-research-quals-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex: 0 0 auto;
}
.rl-research-page-size select {
  margin-left: 4px;
  font-size: 12px;
}
.rl-research-quals-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.rl-research-quals-table th.sortable:hover {
  color: var(--rl-text, #222);
}
.rl-research-quals-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
.rl-research-quals-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
.rl-btn-tiny {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--rl-border, #ccc);
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
}
.rl-btn-tiny:disabled {
  opacity: 0.45;
  cursor: default;
}

.rl-research-stats-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.rl-quals-open-btn { font-weight: 600; }
.rl-quals-dialog {
  border: 1px solid var(--rl-border, #ccc);
  border-radius: 3px;
  padding: 0;
  max-width: min(1200px, 96vw);
  width: min(1200px, 96vw);
  max-height: 90vh;
  overflow: hidden;
}
.rl-quals-dialog::backdrop { background: rgba(0,0,0,.35); }
.rl-quals-panel {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.rl-quals-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.rl-quals-head h2 { margin: 0; font-size: 15px; }
.rl-quals-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.rl-quals-dialog .rl-research-quals {
  margin: 0;
  min-height: 0;
  flex: 1 1 auto;
  max-height: calc(90vh - 56px);
}
.rl-research-chart-area-title {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rl-text-muted, #666);
}
.rl-research-tolerance-row,
.rl-research-ranges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
}
.rl-research-range-chart {
  flex: 1 1 320px;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--rl-border, #ddd);
  border-radius: 3px;
  background: var(--rl-bg-panel, #fff);
}
.rl-research-range-chart .rl-chart-wrap--bar { height: 200px; max-height: 220px; }
.rl-research-range-chart .rl-chart-wrap:not(.rl-chart-wrap--bar) { height: 220px; }
/* Slice rows reuse .rl-filter-row and .rl-check from style.css, so they read exactly
   like the Race context rows. Only what is slice-specific lives here: a control that
   can be a list, and the wrap that gives that list the full row width. */
#rl-root .rl-slice-row {
  flex-wrap: wrap;
  row-gap: 4px;
}
#rl-root .rl-slice-chart {
  user-select: none;
}
/* Course and Class titles are long enough to need a wrap rather than an overflow. */
#rl-root .rl-slice-chart span {
  min-width: 0;
  overflow-wrap: break-word;
}
/* A filter with a value is doing something to the search: say so quietly. */
#rl-root .rl-slice-row.in-use .rl-slice-chart span {

}
#rl-root .rl-slice-control {
  flex: 0 0 auto;
  min-width: 0;
}
.rl-slice-control select,
.rl-slice-range input {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--rl-border, #ccc);
}
.rl-slice-range { display: flex; align-items: center; gap: 4px; }
.rl-slice-range input { width: 56px; min-width: 0; }
/* Lists wrap onto their own line under the label rather than a cramped column. */
#rl-root .rl-slice-control--wide {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rl-slice-multiselect {
  display: flex;
  /* flex-wrap: wrap; */
  flex-direction: column;
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
}
.rl-slice-multiselect option {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--rl-border, #ccc);
  border-radius: 2px;
  cursor: pointer;
  list-style: none;
}
.rl-slice-multiselect option.on {
  background: var(--blue-accent, #2563eb);
  color: #fff;
  border-color: transparent;
}
.rl-slice-compact-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rl-slice-list-toggle {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--rl-border, #ccc);
  border-radius: 2px;
  background: var(--rl-bg-panel, #fff);
  cursor: pointer;
  width: 100%;
}
.rl-slice-chips {
  display: flex;
  flex-direction: column;
  /* flex-wrap: wrap; */
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rl-slice-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 4px 2px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--blue-accent, #2563eb);
  color: #fff;
  cursor: pointer;
}
.rl-slice-chip-x {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.rl-research-range-chart .rl-hist-chart-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rl-research-range-chart .rl-hist-chart-label { flex: 1 1 auto; min-width: 0; }
.rl-chart-display {
  font-size: 11px;
  padding: 1px 4px;
  border: 1px solid var(--rl-border, #ccc);
  background: var(--rl-bg-panel, #fff);
}
.rl-chart-table-wrap {
  height: 200px;
  max-height: 220px;
  overflow: auto;
}
.rl-chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.rl-chart-table th,
.rl-chart-table td {
  padding: 2px 6px;
  text-align: right;
  border-bottom: 1px solid var(--rl-border, #eee);
  white-space: nowrap;
}
.rl-chart-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--rl-bg-panel, #fff);
  font-weight: 700;
  color: var(--rl-text-muted, #666);
}
.rl-chart-table th.sortable { cursor: pointer; user-select: none; }
.rl-chart-table th.sorted { color: var(--blue-accent, #2563eb); }
.rl-chart-table .rl-chart-table-grp { text-align: left; }
.rl-chart-table .rl-chart-table-inc { text-align: center; width: 32px; }
.rl-chart-table tbody tr.on { background: rgba(37, 99, 235, 0.08); }
