:root {
  color-scheme: light;
  --bg: #f2f4f1;
  --surface: #ffffff;
  --line: #d8ded3;
  --line-soft: #e9eee6;
  --ink: #1e2920;
  --muted: #637064;
  --accent: #147d73;
  --accent-dark: #0f625a;
  --warn: #8a4a12;
  --shadow: 0 10px 30px rgba(31, 47, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1rem;
}

.topbar p,
.panelHead span {
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(272px, 320px) minmax(0, 1fr);
  padding: 14px;
}

.controls,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(31, 47, 35, 0.03);
}

.controls {
  align-self: start;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 14px;
  position: sticky;
  top: 84px;
}

.controls section {
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
}

.controls section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.84rem;
  gap: 5px;
}

.labelTitle {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  line-height: 1.25;
  width: max-content;
}

input,
select,
button {
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  font: inherit;
  min-height: 36px;
}

input,
select {
  background: #fbfcfa;
  padding: 6px 9px;
  width: 100%;
}

select[multiple] {
  min-height: 132px;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
  padding: 7px 12px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondaryButton {
  background: #eef3ec;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}

button.secondaryButton:hover {
  background: #e3ebe0;
}

button.needsRun {
  box-shadow: 0 0 0 3px rgba(20, 125, 115, 0.18);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.segmented {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr;
}

.segmentButton {
  background: #eef3ec;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}

.segmentButton:hover {
  background: #e3ebe0;
}

.segmentButton.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pendingNotice {
  background: #fff8e8;
  border: 1px solid #e5c889;
  border-radius: 5px;
  color: var(--warn);
  font-size: 0.86rem;
  padding: 8px 10px;
  text-align: center;
}

.topActions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.topActions label {
  color: var(--muted);
  font-size: 0.78rem;
}

.topActions input,
.topActions select {
  min-height: 32px;
}

.autoRefreshTop {
  color: var(--ink);
  min-width: auto;
  white-space: nowrap;
}

.chipList {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 96px;
  overflow: auto;
}

.chip {
  align-items: center;
  background: #e3f0ed;
  border: 1px solid #b9d8d2;
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 0.78rem;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 9px;
}

.chip:hover {
  background: #d7e9e5;
}

.chip span {
  font-weight: 800;
}

.chipHint,
.emptyMini {
  color: var(--muted);
  font-size: 0.82rem;
}

.checkList {
  border: 1px solid var(--line);
  border-radius: 5px;
  max-height: 280px;
  overflow: auto;
}

.checkItem {
  align-items: flex-start;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr;
  padding: 8px;
}

.checkItem:last-child {
  border-bottom: 0;
}

.checkItem:hover {
  background: #f8faf7;
}

.checkItem input {
  margin-top: 3px;
  min-height: auto;
  width: auto;
}

.checkItem b {
  display: block;
  font-size: 0.82rem;
  line-height: 1.3;
}

.checkItem small {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  line-height: 1.25;
  margin-top: 2px;
}

.emptyMini {
  padding: 10px;
}

.help {
  align-items: center;
  background: #eef3ec;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 700;
  height: 17px;
  justify-content: center;
  min-height: 17px;
  min-width: 17px;
  padding: 0;
  width: 17px;
}

.help:hover {
  background: #e3ebe0;
  color: var(--ink);
}

.helpPopover {
  background: rgba(30, 41, 32, 0.96);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(30, 41, 32, 0.16);
  color: white;
  direction: rtl;
  font-size: 0.86rem;
  line-height: 1.45;
  max-width: 320px;
  padding: 10px 12px;
  position: fixed;
  z-index: 30;
}

.resetBox {
  padding-top: 4px;
}

.resetBox button {
  width: 100%;
}

.aboutDialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  direction: rtl;
  max-width: 680px;
  padding: 22px 24px;
  width: min(680px, calc(100vw - 32px));
}

.aboutDialog::backdrop {
  background: rgba(30, 41, 32, 0.32);
}

.aboutDialog h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.aboutDialog p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 10px;
}

.aboutDialog a {
  color: var(--accent-dark);
  font-weight: 700;
}

.dialogClose {
  background: #eef3ec;
  border-color: var(--line);
  color: var(--ink);
  float: left;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  min-height: 30px;
  padding: 0 9px;
}

.grid2 {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.checkline {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.checkline input {
  min-height: auto;
  width: auto;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panelHead {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panelHead select {
  max-width: 360px;
}

.chartControls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.chartControls label {
  min-width: 145px;
}

.chartControls .checkline {
  min-width: auto;
}

.message {
  background: #fff8e8;
  border: 1px solid #e5c889;
  border-radius: 8px;
  color: var(--warn);
  padding: 10px 12px;
}

.chart {
  direction: ltr;
  min-height: 460px;
  overflow: hidden;
  position: relative;
}

.chart.facetedChart {
  direction: rtl;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 0;
  overflow: visible;
}

.chart > svg {
  display: block;
  height: 440px;
  width: 100%;
}

.axis,
.grid {
  stroke: #cfd8cf;
  stroke-width: 1;
}

.grid {
  stroke-dasharray: 3 6;
}

.seriesLine {
  fill: none;
  pointer-events: stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.seriesLine[data-fund-id],
.seriesPoint,
tr[data-fund-id],
.legendItem[data-fund-id] {
  cursor: pointer;
}

.seriesPoint {
  opacity: 0.9;
  stroke: var(--surface);
  stroke-width: 1.25;
}

.seriesPoint:hover {
  r: 5;
}

.chart > svg text {
  direction: rtl;
  fill: var(--muted);
  font-size: 12px;
}

.chart > svg .endLabel {
  fill: #49554b;
  font-size: 11px;
  font-weight: 650;
}

.js-plotly-plot .modebar-btn {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  min-height: auto;
  padding: 3px 4px;
}

.js-plotly-plot .modebar-btn:hover {
  background: transparent;
}

.js-plotly-plot .modebar-btn svg {
  display: inline-block;
  height: 1em;
  width: 1em;
}

.emptyState {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 360px;
  padding: 24px;
  text-align: center;
}

.emptyState b {
  color: var(--ink);
  font-size: 1rem;
}

.facetPanel {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  min-width: 0;
  padding: 10px;
}

.facetPanel h3 {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.25;
  margin: 0 0 6px;
  text-align: right;
}

.facetPlot {
  direction: ltr;
  min-height: 285px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin-top: 8px;
}

.legendItem {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.82rem;
  gap: 6px;
  min-height: auto;
  padding: 0;
}

.legendItem:hover {
  background: transparent;
  color: var(--ink);
}

.chartTooltip {
  background: rgba(30, 41, 32, 0.94);
  border-radius: 6px;
  color: white;
  direction: rtl;
  display: grid;
  font-size: 0.82rem;
  gap: 2px;
  max-width: 260px;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  z-index: 3;
}

.chartTooltip b {
  font-size: 0.84rem;
}

.swatch {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.summaryItem {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
}

.summaryItem b {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.summaryItem span {
  display: block;
}

.summaryItem small {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  margin-top: 3px;
}

.tableWrap {
  max-height: 620px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  direction: ltr;
  font-size: 0.82rem;
  min-width: 900px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 7px 9px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #eef3ec;
  box-shadow: inset 0 -1px 0 var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f8faf7;
}

td.textCell,
th.textCell {
  direction: rtl;
  text-align: right;
}

@media (max-width: 1400px) {
  .chart.facetedChart {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .chart.facetedChart {
    grid-template-columns: 1fr;
  }

  .controls {
    max-height: none;
    position: static;
  }

  .topbar {
    position: static;
  }
}
