* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; margin: 0; color: #111; background: #f6f7fb; }
header { background: #1f2937; color: #fff; padding: 12px 20px; }
header h1 { font-size: 18px; margin: 0; }
.header-content { display: flex; align-items: center; justify-content: space-between; max-width: 1400px; margin: 0 auto; }
.header-left { display: flex; align-items: center; gap: 20px; }
.dataset-selector { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.dataset-selector label { color: rgba(255,255,255,0.7); }
.dataset-selector select { padding: 4px 8px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: #fff; border-radius: 4px; font-size: 13px; cursor: pointer; }
.dataset-selector select:hover { background: rgba(255,255,255,0.2); }
.dataset-selector select:focus { outline: none; border-color: rgba(255,255,255,0.5); }
.dataset-selector select option { background: #1f2937; color: #fff; }
.main-nav { display: flex; gap: 4px; }
.nav-btn { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #fff; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.nav-btn:hover { background: rgba(255,255,255,0.1); }
.nav-btn.active { background: #fff; color: #1f2937; border-color: #fff; font-weight: 600; }
.main-view { display: none; }
.main-view.active { display: block; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.controls input { flex: 1 1 280px; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; }
.controls button { padding: 8px 12px; border: 1px solid #111827; background: #111827; color: #fff; border-radius: 6px; cursor: pointer; }
.controls button:hover { background: #374151; border-color: #374151; }
.settings-card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; color: #374151; }
.settings-card h3 { margin: 0 0 6px; font-size: 14px; }
.settings-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.settings-section { min-width: 220px; max-width: 360px; }
.settings-section-title { font-weight: 600; margin-bottom: 4px; }
.settings-note { margin: 4px 0 0 0; font-size: 12px; color: #6b7280; }
.correction-controls { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #374151; }
.correction-controls label { display: flex; align-items: center; gap: 4px; }
.group-controls { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #374151; flex-wrap: wrap; }
.group-controls label { display: flex; align-items: center; gap: 4px; }
.group-label { font-weight: 500; }
.status { font-size: 13px; color: #374151; min-height: 20px; margin: 6px 0; }
.status.error { color: #b91c1c; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; min-height: 280px; position: relative; }
@media (max-width: 1100px) { .grid3, .grid2 { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 4px; margin: 8px 0 12px; border-bottom: 1px solid #e5e7eb; }
.tab { border: none; background: transparent; padding: 6px 10px; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; color: #4b5563; }
.tab.active { border-bottom-color: #111827; font-weight: 600; color: #111827; }
.tab-content { display: none; margin-top: 4px; }
.tab-content.active { display: block; }
#a6Table { width: 100%; border-collapse: collapse; font-size: 13px; }
#a6Table th, #a6Table td { border: 1px solid #e5e7eb; padding: 4px 6px; text-align: right; }
#a6Table th:first-child, #a6Table td:first-child { text-align: left; }
#agePlot, #appPlot, #tauPlot, #pairPlot, #a6Volcano, #braakStagePlot, #amyloidStagePlot { height: 380px; }
#corrHeatmap { height: 420px; }
#synHeatmap { height: 420px; }
.grid-stage { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-top: 12px; }
.card-amyloid { min-width: 280px; }
.card-braak { min-width: 400px; }
@media (max-width: 900px) { .grid-stage { grid-template-columns: 1fr; } }
.controls-inline { display: flex; gap: 6px; margin-bottom: 8px; }
.controls-inline input { flex: 1; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 13px; }
.controls-inline button { padding: 6px 10px; border: 1px solid #111827; background: #111827; color: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }

/* Association table styling */
.a6-summary { margin-bottom: 12px; }
.a6-summary .sig-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0; }
.a6-summary .sig-badge.sig { background: #fee2e2; color: #b91c1c; }
.a6-summary .sig-badge.not-sig { background: #f3f4f6; color: #6b7280; }
.a6-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.a6-table th, .a6-table td { border: 1px solid #e5e7eb; padding: 6px 8px; }
.a6-table th { background: #f9fafb; text-align: left; font-weight: 600; }
.a6-table td { text-align: right; }
.a6-table td:first-child { text-align: left; font-weight: 500; }
.a6-table .section-header { background: #1f2937; color: white; font-weight: 600; text-align: left !important; }
.a6-table .sig-cell { background: #fef2f2; color: #b91c1c; font-weight: 600; }
.a6-table .beta-pos { color: #059669; }
.a6-table .beta-neg { color: #dc2626; }
.card-volcano { min-height: 320px; }
#volcanoApp, #volcanoMapt, #volcanoAge { height: 280px; }

/* Cell Markers tab */
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1200px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid4 { grid-template-columns: 1fr; } }
.card-markers { min-height: 600px; }
.card-pca { min-height: 300px; }
#markerCorrPlot { height: 580px; }
#markerScatterPlot { height: 580px; }
#pcaPlot1, #pcaPlot2, #pcaPlot3, #pcaPlot4 { height: 280px; }

/* Differential Correlations tab */
.diffcorr-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.diffcorr-controls select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 13px; background: #fff; }
.diffcorr-controls button { padding: 6px 12px; border: 1px solid #111827; background: #111827; color: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.diffcorr-controls button:hover { background: #374151; }
.diffcorr-label { font-weight: 500; color: #374151; }
.card-diffcorr { min-height: 500px; }
.diffcorr-note { font-size: 12px; color: #6b7280; margin: 0 0 8px 0; }
#diffCorrPlot { height: 480px; }

/* Association Explorer */
.view-subtitle { color: #6b7280; font-size: 13px; margin: -8px 0 12px 0; }
.assoc-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; padding: 10px; background: #f9fafb; border-radius: 6px; }
.assoc-control-group { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.assoc-control-group label { font-weight: 500; color: #374151; }
.assoc-control-group select, .assoc-control-group input[type="text"], .assoc-control-group input[type="number"] { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 13px; }
.assoc-control-group button { padding: 5px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; }
.assoc-control-group button:hover { background: #f3f4f6; }
.assoc-dataset-meta { color: #6b7280; font-size: 12px; line-height: 1.25; }
.assoc-dataset-meta .meta-title { font-weight: 600; color: #374151; }
.assoc-table-container { max-height: 600px; overflow: auto; border: 1px solid #e5e7eb; border-radius: 6px; }
.assoc-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.assoc-table th { position: sticky; top: 0; background: #1f2937; color: #fff; padding: 8px 6px; text-align: left; cursor: pointer; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assoc-table th:hover { background: #374151; }
.assoc-table th .sort-arrow { margin-left: 4px; opacity: 0.5; }
.assoc-table th.sorted .sort-arrow { opacity: 1; }
.assoc-table th.sorted { background: #111827; }
.assoc-table th.volcano-p { border-bottom: 3px solid #f59e0b; }
.assoc-table th.volcano-beta { border-bottom: 3px solid #3b82f6; }
.assoc-table th.volcano-fdr { border-bottom: 3px solid #b91c1c; }
.assoc-table td { padding: 6px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assoc-table th, .assoc-table td { min-width: 110px; }
.assoc-table tr:hover { background: #f9fafb; }
.assoc-table tr.clickable { cursor: pointer; }
.assoc-table th[data-key="protein"], .assoc-table td.protein-cell { width: 140px; }
.assoc-table th[data-key="unique_id"], .assoc-table td.id-cell { width: 220px; }
.assoc-table .protein-cell { font-weight: 600; color: #1f2937; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assoc-table .id-cell { color: #374151; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assoc-table .pval-sig { font-weight: 700; color: #b91c1c; }
.assoc-table .pval-nonsig { color: #6b7280; }
.assoc-table .beta-cell { display: flex; align-items: center; gap: 2px; width: 90px; }
.assoc-table .beta-bar-container { width: 40px; height: 12px; position: relative; }
.assoc-table .beta-bar { height: 12px; border-radius: 2px; position: absolute; top: 0; }
.assoc-table .beta-pos { background: #3b82f6; left: 50%; }
.assoc-table .beta-neg { background: #dc2626; right: 50%; }
.assoc-table .beta-zero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #9ca3af; }
.assoc-table .beta-val { font-size: 11px; min-width: 45px; text-align: right; }
.assoc-footer { padding: 8px 0; font-size: 12px; color: #6b7280; }
.assoc-layout { display: flex; gap: 16px; }
.assoc-table-section { flex: 1; min-width: 0; }
.assoc-volcano-section { width: 420px; flex-shrink: 0; }
.volcano-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.volcano-controls label { font-weight: 500; color: #374151; }
.volcano-controls select { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 13px; }
.volcano-plot { height: 540px; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }
.assoc-bottom-section { display: flex; gap: 16px; margin-top: 16px; }
.assoc-corr-section { flex: 2; min-width: 0; }
.corr-header, .scatter-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.corr-title, .scatter-title { font-size: 13px; font-weight: 500; color: #374151; }
.assoc-corr-settings { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
.assoc-corr-settings .settings-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.assoc-corr-settings .settings-row:last-child { margin-bottom: 0; }
.assoc-corr-settings .settings-label { font-weight: 600; color: #374151; min-width: 75px; }
.assoc-corr-settings label { display: flex; align-items: center; gap: 3px; color: #4b5563; cursor: pointer; }
.assoc-corr-settings input[type="checkbox"] { margin: 0; }
.btn-small { padding: 4px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 4px; cursor: pointer; font-size: 11px; color: #374151; }
.btn-small:hover { background: #f3f4f6; border-color: #9ca3af; }
.assoc-heatmap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .assoc-heatmap-grid { grid-template-columns: 1fr; } }
.assoc-heatmap-title { font-size: 12px; font-weight: 600; color: #374151; margin: 6px 0; }
.assoc-corr-heatmap { height: 480px; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }
.assoc-scatter-section { flex: 1; min-width: 0; }
.assoc-scatter-plot { height: 380px; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; color: #9ca3af; }
.assoc-table tr.hovered { background: #fef3c7 !important; }
.assoc-table tr.clickable:hover { background: #f3f4f6; }

/* Loading progress bar */
.loading-bar-container { width: 100%; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; margin: 8px 0; }
.loading-bar { height: 100%; width: 30%; background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6); background-size: 200% 100%; animation: loading-slide 1.5s ease-in-out infinite; border-radius: 2px; }
@keyframes loading-slide { 0% { margin-left: 0; width: 30%; } 50% { margin-left: 35%; width: 30%; } 100% { margin-left: 70%; width: 30%; } }
.status.loading { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* Loading spinner for SVG viewer */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* SVG viewer controls */
.svg-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
}
.svg-controls .btn-small {
  text-decoration: none;
}

.plot-loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  z-index: 5;
}
.plot-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.plot-loading-overlay .loading-spinner {
  width: 34px;
  height: 34px;
  border-width: 3px;
}
.plot-loading-text {
  font-size: 12px;
  color: #4b5563;
  text-align: center;
  max-width: 260px;
  line-height: 1.3;
}

/* Site Footer */
.site-footer {
  background: #1f2937;
  color: #e5e7eb;
  padding: 24px 20px;
  margin-top: 32px;
}
.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}
.footer-section {
  flex: 1;
  min-width: 280px;
}
.footer-section h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.citation-section {
  flex: 2;
}
.citation-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #d1d5db;
}
.citation-text em {
  color: #fff;
}
.citation-text a {
  color: #60a5fa;
  text-decoration: none;
}
.citation-text a:hover {
  text-decoration: underline;
}
.license-section p {
  margin: 0;
}
.license-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.license-link:hover {
  color: #fff;
}
.license-badge {
  height: 22px;
  width: auto;
  border-radius: 3px;
}
@media (max-width: 700px) {
  .footer-content {
    flex-direction: column;
    gap: 20px;
  }
}
