body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #212529;
  background: #f8f9fa;
}
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
header {
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
}
.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.secondary-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
}
main { padding: 8px 16px 12px 16px; }
.top-bar {
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  padding: 8px 16px;
}
#axis-top { display: block; height: 36px; padding: 0 16px; }
#bifocal-bar { display: block; height: 28px; padding: 0 16px; }
#chart-container {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 8px;
  overflow: visible;
  min-height: 400px;
  margin-top: 8px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}
.row-line { stroke: #e9ecef; stroke-width: 1; }
.ip-label { font-size: 10px; fill: #343a40; }
.time-axis text { font-size: 10px; fill: #000; }
.time-axis path, .time-axis line { stroke: #000; }
.arc { fill: none; stroke-opacity: 0.8; pointer-events: stroke; }
.arc:hover { stroke-opacity: 1; }
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #dee2e6; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hint { color: #6c757d; font-size: 12px; }
#status { color: #6c757d; font-size: 12px; margin-left: auto; white-space: nowrap; }
.tooltip { position: fixed; background: rgba(0,0,0,0.85); color: #fff; padding: 8px 10px; border-radius: 4px; font-size: 12px; pointer-events: none; display: none; z-index: 99999; }

/* Floating Legend Panel */
.legend-panel {
  position: fixed;
  top: 150px;
  right: 20px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 1000;
  min-width: 200px;
  max-width: 280px;
  max-height: 70vh;
  overflow: hidden;
}

.legend-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.legend-panel-header span:first-child {
  font-size: 11px;
  font-weight: 600;
}

.legend-panel-header:hover {
  background: #e9ecef;
}

.legend-panel.collapsed .legend-panel-header {
  border-bottom: none;
}

.legend-panel-body {
  padding: 6px 8px;
  max-height: calc(70vh - 35px);
  overflow-y: auto;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.legend-panel.collapsed .legend-panel-body {
  max-height: 0;
  padding: 0 8px;
  overflow: hidden;
}

.legend-panel.collapsed #legendCollapseIcon {
  transform: rotate(-90deg);
}

.legend-panel .legend {
  flex-direction: column;
  gap: 2px;
  align-items: stretch;
}

.legend-panel .legend-item {
  padding: 3px 6px;
  border-radius: 3px;
  transition: background-color 0.15s;
  font-size: 10px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: left;
}

.legend-panel .legend-item .swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
}

.legend-panel .legend-item span {
  flex: 1;
  text-align: left !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-panel .legend-item:hover {
  background-color: rgba(0,0,0,0.03);
}

/* Force-directed layout mode */
.force-layout-layer { pointer-events: all; }
.force-node circle { stroke-width: 1.5; cursor: grab; transition: r 0.3s; }
.force-node circle:hover { stroke-width: 2.5; }
.force-node.dragging circle { cursor: grabbing; }
.force-node text { font: 10px 'Courier New', monospace; fill: #343a40; pointer-events: none; }
.force-link { fill: none; stroke-opacity: 0.6; pointer-events: stroke; }
.force-link:hover { stroke-opacity: 1; }
.timearcs-layer { pointer-events: all; }
