* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #eef1f6; color: #1f2733;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  user-select: none;
}

#topbar {
  background: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,.08);
  padding: 6px 14px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
#topbar h1 { font-size: 14px; color: #4a7396; font-weight: 700; }

#exp-select {
  padding: 5px 10px; border: 1px solid rgba(74,115,150,.3);
  border-radius: 6px; background: #ffffff; color: #1f2733;
  font-size: 12px; font-weight: 600; cursor: pointer;
  min-width: 220px;
}
#exp-select optgroup { background: #f4f6fa; color: #4a7396; font-weight: 700; }
#exp-select option { background: #ffffff; color: #1f2733; padding: 2px 6px; }

.filter-group { margin-left: 16px; display: flex; gap: 6px; align-items: center; }
.filter-label { font-size: 11px; opacity: .5; }
.filter-btn {
  padding: 3px 10px; border: 1px solid rgba(0,0,0,.12);
  border-radius: 5px; background: transparent; color: #556;
  font-size: 11px; cursor: pointer; transition: .12s;
}
.filter-btn:hover { border-color: rgba(0,0,0,.25); }
.filter-btn.active { background: rgba(74,115,150,.1); color: #3f6b91; border-color: rgba(74,115,150,.4); }

#main { flex: 1; display: flex; min-height: 0; }

#viewport { flex: 1; position: relative; min-height: 0; }
canvas { display: block; width: 100%!important; height: 100%!important; cursor: grab; }
canvas:active { cursor: grabbing; }

#tooltip {
  position: absolute; pointer-events: none; display: none;
  background: rgba(255,255,255,.96); border: 1px solid rgba(74,115,150,.25);
  border-radius: 8px; padding: 10px 14px; z-index: 30;
  font-size: 12px; line-height: 1.6; max-width: 320px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  color: #1f2733;
}
#tooltip .tt-task { font-weight: 700; color: #3f6b91; font-size: 13px; }
/* auto width, not a fixed column — some labels are full phrases and would be clipped */
#tooltip .tt-label { opacity: .55; margin-right: 4px; }
#tooltip .tt-id { font-weight: 600; }
#tooltip .tt-bar { height: 6px; border-radius: 3px; margin-top: 4px; }

#sidebar {
  width: 310px; flex-shrink: 0;
  background: #ffffff;
  border-left: 1px solid rgba(0,0,0,.08);
  overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.sb-title {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  opacity: .5; margin-bottom: 4px;
}
.sb-divider { height: 1px; background: rgba(0,0,0,.08); }
.sb-note { font-size: 11px; line-height: 1.55; opacity: .62; }
.sb-note + .sb-note { margin-top: 5px; }
.sb-note b { opacity: .85; }

.stat-row { display: flex; gap: 6px; }
.stat-box {
  /* min-width:0 so three boxes share the sidebar instead of overflowing it */
  flex: 1; min-width: 0;
  border: 1px solid rgba(0,0,0,.08); border-radius: 8px;
  padding: 8px 6px; text-align: center;
}
.stat-val { font-size: 18px; font-weight: 700; }
.stat-lbl { font-size: 10px; opacity: .5; margin-top: 2px; }
.stat-sub { font-size: 10px; opacity: .4; }

.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-swatch {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,.15); flex-shrink: 0;
}

.factor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.factor-cell {
  border-radius: 5px; padding: 4px 8px;
  font-size: 11px; display: flex; justify-content: space-between;
  border: 1px solid rgba(0,0,0,.06);
}
.factor-cell .fc-name { opacity: .65; }
.factor-cell .fc-val { font-weight: 600; }

.pair-row { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; }
.pair-label { opacity: .55; }
.pair-val { font-weight: 600; }

.axis-legend { font-size: 11px; opacity: .55; padding: 2px 0; }
.axis-label { font-weight: 700; display: inline-block; width: 18px; color: #4a7396; }

.layer-section { display: flex; flex-direction: column; gap: 4px; }
.layer-row { display: flex; align-items: center; gap: 6px; }
.layer-axis-label { font-size: 11px; font-weight: 700; opacity: .55; width: 14px; }
.layer-dots { display: flex; gap: 4px; }
.ldot {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(74,115,150,.5); background: rgba(74,115,150,.15);
  transition: .12s; font-size: 8px; text-align: center; line-height: 14px;
  color: rgba(74,115,150,.7);
}
.ldot:hover { transform: scale(1.15); }
.ldot.hidden { background: transparent; border-color: rgba(0,0,0,.12); color: rgba(0,0,0,.25); }
.show-all-btn {
  padding: 4px 10px; border: none; border-radius: 5px;
  background: #e8ecf4; color: #4a7396; font-size: 11px;
  cursor: pointer; transition: .1s;
}
.show-all-btn:hover { opacity: .8; }

#viewer-status {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  z-index: 5;
  color: #1f2733;
  background: #ffffff;
  padding: 16px;
  border-radius: 6px;
}
