    * { box-sizing: border-box; margin: 0; padding: 0; }

    html, body {
      height: 100%;
    }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

    #chartsRegion {
      display: flex;
      flex-direction: column;
      height: 100vh;
      padding: 0.5rem;
      gap: 0.5rem;
    }

    #wrapper0 {
  height: auto;
  min-height: 0;
}

    /* ---- accordion ---- */
    #accordionHeader {
      flex-shrink: 0;
    }

    .accordion-item {
      border: 1px solid #ddd;
      border-radius: 6px;
      margin-bottom: 0.5rem;
      overflow: visible;
    }

    .accordion-header {
      width: 100%;
      background: #f0f0f0;
      border: none;
      text-align: left;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0.5rem 1rem;
      font-size: 0.9rem;
      position: relative;
    }

    .accordion-header:hover { background: #e0e0e0; }

    .chevron { font-size: 1rem; transition: transform 0.3s; }
    .accordion-item.open .chevron { transform: rotate(180deg); }

    .accordion-content {
      max-height: 0;
      overflow: visible;
      opacity: 0;
      pointer-events: none;
      transition: max-height 0.3s ease, opacity 0.3s ease;
    }

    .accordion-item.open .accordion-content {
      max-height: 500px;
      opacity: 1;
      pointer-events: auto;
    }

    .chart-placeholder {
      background: #e8f4e8;
      /* border: 1px dashed #aaa; */
      border-radius: 4px;
      height: 200px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #666;
      margin: 0.5rem;
    }

:root {
  --chart-height: 400px;
}

.chart-wrapper {
  height: var(--chart-height);
}

.accordion-item.open .accordion-content {
  max-height: calc(var(--chart-height) + 60px);  /* 60px for any padding/margins inside */
}

    /* ---- flexible layer5 below accordion ---- */
    #layer5Wrapper {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: var(--chart-height);
      border: none;
      border-radius: 6px;
      overflow: hidden;
    }

    #layer5Wrapper h3 {
      flex-shrink: 0;
      padding: 0.5rem 1rem;
      background: #f9f9f9;
      border-bottom: 1px solid #ddd;
      font-size: 0.9rem;
      display: flex;
      align-items: center;
      gap: 12px;
    }

    #wrapper5 {
      flex: 1;
      min-height: 0;
      /* background: #f0e8f4; */
      border: 1px solid #aaa;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #666;
    }


/* fancy headers */

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  /* existing styles */
}

.accordion-name {
  flex: 0 0 auto;
  margin-right: 1rem;
}

.accordion-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
}

.accordion-unique {
  display: flex;
  gap: 0.4rem;
  padding-right: 0.5rem;
  border-right: 1px solid #ccc;
  margin-right: 0.5rem;
}

.accordion-actions {
  display: flex;
  gap: 0.2rem;
}

.accordion-view {
  padding-left: 0.5rem;
  border-left: 1px solid #ccc;
  margin-left: 0.5rem;
}

.ctrl-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #444;
  line-height: 1.4;
}

.ctrl-btn:hover {
  background: #ddd;
  border-color: #bbb;
}

/* tooltip */
.ctrl-btn[data-tooltip] {
  position: relative;
}

.ctrl-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 99999;
}


.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
}
.legend-item:hover { background: #eee; }
.legend-item-selected { font-weight: bold; border-bottom: 2px solid currentColor; }
.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 3px;
}

.ctrl-btn-active {
  background: #666;
  color: white;
  border-color: #444;
}

.accordion-stats {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: #444;
}

.stat-item {
  padding: 2px 6px;
  background: #f0f0f0;
  border-radius: 3px;
}

/* outcome reporting */

/* .accordion-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}
.stat-ticker {
  font-weight: bold;
  font-size: 0.85rem;
  color: #264653;
}
.stat-divider {
  color: #ccc;
  padding: 0 2px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.stat-label {
  color: #999;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-value {
  font-weight: 600;
  color: #264653;
} */

.stat-divider { display: none; }

.accordion-stats {
  display: flex;
  align-items: center;
  gap: 4px;  /* was 8px */
  font-size: 0.68rem;  /* was 0.75rem */
}
.stat-label {
  font-size: 0.58rem;  /* was 0.65rem */
    text-transform: uppercase;
}
.stat-value {
  font-size: 0.72rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  padding: 0 2px;  /* minimal padding */
}


.accordion-stats { cursor: pointer; }
.accordion-stats:hover { background: #f9f9f9; border-radius: 4px; }


.ctrl-label-input {
  width: 70px;
  font-size: 0.72rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 1px 3px;
  text-align: right;
  background: #fafafa;
}

.ctrl-label-input:focus {
  outline: none;
  border-color: #888;
  background: #fff;
}


/* ── guided tour ─────────────────────────────────────────── */

.tour-overlay {
  position:   fixed;
  inset:      0;
  background: rgba(0, 0, 0, 0.35);
  z-index:    9998;
  cursor:     pointer;
  pointer-events:none;
}

.tour-highlight {
  position:      relative;
  z-index:       9999;
  outline:       3px solid #3b82f6;
  outline-offset: 4px;
  border-radius: 4px;
  pointer-events: all;
}

.tour-tip {
  position:      absolute;
  z-index:       10000;
  background:    #1e293b;
  color:         #f1f5f9;
  padding:       14px 16px;
  border-radius: 10px;
  max-width:     350px;
  min-width:     350px;
  font-size:     0.8rem;
  box-shadow:    0 6px 24px rgba(0, 0, 0, 0.4);
  pointer-events: all;
}

.tour-tip-header {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  margin-bottom:   6px;
}

.tour-tip-header strong {
  font-size:   0.9rem;
  color:       #93c5fd;
}

.tour-close {
  background:  none;
  border:      none;
  color:       #94a3b8;
  cursor:      pointer;
  font-size:   0.85rem;
  padding:     0 2px;
  line-height: 1;
}

.tour-close:hover { color: #f1f5f9; }

.tour-tip-text {
  margin:      4px 0 10px;
  line-height: 1.5;
  color:       #cbd5e1;
}

.tour-nav {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  gap:             8px;
}

.tour-counter {
  font-size: 0.72rem;
  color:     #64748b;
}

.tour-btn {
  background:    #3b82f6;
  color:         #fff;
  border:        none;
  border-radius: 5px;
  padding:       4px 10px;
  font-size:     0.75rem;
  cursor:        pointer;
  transition:    background 0.15s;
}

.tour-btn:hover    { background: #2563eb; }
.tour-btn:disabled { opacity: 0.3; cursor: default; }

/* tour trigger button in layer5 header */
.tour-trigger {
  background:    none;
  border:        1px solid #94a3b8;
  border-radius: 50%;
  width:         20px;
  height:        20px;
  font-size:     0.75rem;
  color:         #64748b;
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  padding:       0;
  line-height:   1;
  transition:    all 0.15s;
}

.tour-trigger:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}



.tour-detail {
  display:    none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #334155;
  color:      #cbd5e1;
  font-size:  0.78rem;
  line-height: 1.6;
  max-height: 40vh;
  overflow-y: auto;
}

.tour-detail.tour-detail-open {
  display: block;
}

.tour-detail p  { margin: 0 0 8px; }
.tour-detail ul { margin: 0 0 8px; padding-left: 16px; }
.tour-detail li { margin-bottom: 4px; }
.tour-detail strong { color: #93c5fd; }
.tour-detail em     { color: #86efac; }

.tour-more-btn {
  background:  none;
  border:      none;
  color:       #3b82f6;
  font-size:   0.72rem;
  cursor:      pointer;
  padding:     2px 0;
  margin-top:  4px;
  display:     block;
}

.tour-more-btn:hover { color: #93c5fd; }

.tour-trigger.tour-attract {
  animation: tour-attract 2s ease-in-out 1s 10;  /* delay 1s, 3 pulses */
}

@keyframes tour-attract {
  0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
  50%  { box-shadow: 0 0 0 60px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}



.chart-wrapper > div {
  width: 100%;
  height: 100%;
}






/* .u-cursor-y {
  display: none !important;
}
#layer4 .u-cursor-y {
  display: true !important;
} */
/* #layer4 .u-cursor-y {
  display: none !important;
}
#layer4 .u-cursor-y {
  display: none !important;
} */




/* --- Global uPlot Styles --- */

/* Hide all grid lines by default */
.u-grid {
  display: none;
}

/* Default axis text and line color */
.u-axis .u-label, 
.u-axis .u-value {
  color: black;
  font-size: 12px;
}

/* Customise the vertical crosshair (x) for all charts */
.u-cursor-x {
  border-right: 1px dashed rgba(0,0,0,0.3) !important;
}
/* 
Change the vertical crosshair to a solid red line
.u-cursor-x {
  border-right: 2px dashed red !important;
} */

/* Change the horizontal crosshair to a solid blue line */
.u-cursor-y {
  /* border-right: 1px solid rgba(0,0,0,0.3) !important; */
  border-bottom: 1px dashed rgba(0,0,0,0.3) !important;
}

/* --- Layer Specific Styles --- */

/* Hide Y crosshair only on layer4 */
#layer1 .u-cursor-y {
  display: none !important;
}

#layer2 .u-cursor-y {
  display: none !important;
}

#layer3 .u-cursor-y {
  display: none !important;
}

/* Hide the Y axis value bubble/tooltip for layer4 if needed */
#layer4 .u-cursor-y .u-value {
  /* display: none !important; */
}

/* If layer4 needs a specific background or border */
#layer4 .u-over {
  /* background: #fafafa; */
}


.uplot-overlay {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Target uPlot legend values */
.u-legend .u-value {
  font-family: monospace;      /* prevents width jitter */
  display: inline-block;       /* allows fixed width */
  min-width: 6ch;              /* enough for 0.000 */
  text-align: left;           /* aligns decimals */
}
/* Force 4 decimal places visually
.u-legend .u-value::after {
  content: attr(data-fixed);
  visibility: hidden;
} */
