:root {
  --bg-color: #f1f5f9;
  --panel-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #10b981;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: 320px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title-input {
  font-size: 1.25rem;
  margin-bottom: 16px;
  font-weight: 600;
  background: transparent;
  color: var(--text-main);
  border: 1px solid transparent;
  border-bottom: 1px solid transparent;
  width: 100%;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.sidebar-title-input:focus, .sidebar-title-input:hover {
  cursor: text;
}

.sidebar-title-input:focus {
  border-bottom: 1px solid var(--accent);
}

.btn-group {
  display: flex;
  gap: 8px;
}

button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.primary-btn {
  background: var(--accent);
  color: white;
  flex: 1;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.secondary-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px;
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.folder-path {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.test-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.test-item-container {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.test-list li {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 4px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.test-list li:hover {
  background: rgba(0, 0, 0, 0.05);
}

.test-list li.active {
  background: var(--accent);
  color: white;
}

.test-list li.active .test-name-input {
  color: white;
}

.test-list li.bw-calib {
  border-left: 4px solid #3b82f6;
}

.test-name-input {
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  cursor: pointer;
}

.test-list li.hidden-test .test-name-input {
  text-decoration: line-through;
  opacity: 0.6;
}

.hide-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: opacity 0.2s;
  color: inherit;
}

.map-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  background: transparent;
  border-radius: 50%;
  /* Border color will be set dynamically via JS */
  border: 2px solid var(--accent); 
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: grab;
  z-index: 10;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.8), inset 0 0 0 1px rgba(255,255,255,0.8);
}

.map-marker::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background-color: currentColor; /* Inherits from dynamic inline color */
  border-radius: 50%;
}

.map-marker:active {
  cursor: grabbing;
}

.map-marker-label {
  position: absolute;
  left: 100%;
  top: -50%;
  margin-left: 6px;
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  pointer-events: none;
  white-space: nowrap;
}

.test-selector-menu {
  position: absolute;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  min-width: 150px;
}

.test-selector-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.test-selector-item:last-child {
  border-bottom: none;
}

.map-legend {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.map-legend h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(0,0,0,0.05);
  cursor: pointer;
}

.legend-item:last-child {
  border-bottom: none;
}

.legend-item:hover {
  color: var(--accent);
}

.legend-swatch {
  width: 18px;
  height: 18px;
  min-width: 18px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: bold;
}

.map-marker:hover .map-marker-label {
  z-index: 100;
  transform: scale(1.1);
}

.map-marker::after {
  content: attr(data-name);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  margin-top: 8px;
  z-index: 20;
}

.map-marker:hover::after {
  opacity: 1;
}

.test-list li.active .test-name-input {
  cursor: text;
}

.test-name-input:focus {
  border-bottom: 1px solid var(--accent);
  cursor: text;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 32px;
}

.content-header {
  margin-bottom: 24px;
}

.content-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

#testTitleDot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #ccc;
  cursor: pointer;
  display: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  margin-bottom: 16px;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.metadata-item {
  background: var(--panel-bg);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.metadata-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.metadata-value {
  font-size: 1.125rem;
  font-weight: 600;
}

.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-box {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  min-height: 350px;
  position: relative;
}

.chart-box h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  font-weight: 500;
  color: var(--text-muted);
}

.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

.overall-chart {
  grid-column: 1 / -1;
  min-height: 450px;
}

.table-container h3 {
  font-size: 1.125rem;
  margin-bottom: 16px;
  font-weight: 600;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: rgba(0,0,0,0.02);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.data-table tr:hover td {
  background: rgba(0,0,0,0.01);
}

.data-table td {
  font-size: 0.875rem;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--panel-bg);
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}
.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--danger);
}
.modal-body {
  padding: 20px;
  font-size: 0.875rem;
  line-height: 1.6;
}
.modal-body p {
  margin-bottom: 8px;
}

#dropZoneOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(37, 99, 235, 0.85); /* Accent color */
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}

#dropZoneOverlay h2 {
  font-size: 2.5rem;
  font-weight: 700;
  pointer-events: none;
  border: 4px dashed rgba(255, 255, 255, 0.6);
  padding: 40px 80px;
  border-radius: 24px;
}

#dropZoneOverlay.active {
  opacity: 1;
  pointer-events: all;
}
