:root {
  --header-height: 52px;
  --sidebar-width: 316px;
  --header-background: #0B1020;
  --page-background: #edf1f5;
  --panel-background: #ffffff;
  --border: #d6dde6;
  --border-strong: #aeb9c8;
  --ink: #182438;
  --muted: #59687d;
  --accent: #1769aa;
  --accent-dark: #0c4d80;
  --danger: #b42318;
  --success: #18794e;
  --warning: #9a6700;
  --card-radius: 6px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page-background);
}

body {
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 34px;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.65;
}

a {
  color: var(--accent-dark);
}

.app-shell {
  min-height: 100vh;
}

.site-header {
  align-items: center;
  background: var(--header-background);
  color: #f5f8fc;
  display: flex;
  height: var(--header-height);
  padding: 0 12px;
}

.site-header__primary {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.site-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.header-icon-button:hover,
.header-icon-button:focus-visible {
  background: #1c2941;
  border-color: #52627d;
  outline: none;
}

.header-icon-button__bars {
  display: grid;
  gap: 4px;
  width: 16px;
}

.header-icon-button__bars span {
  background: currentColor;
  display: block;
  height: 2px;
  width: 16px;
}

.workspace {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(250px, var(--sidebar-width)) minmax(0, 1fr);
  padding: 10px 12px 20px;
}

.app-shell.is-sidebar-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.is-sidebar-collapsed .sidebar-shell {
  display: none;
}

.sidebar-shell {
  align-self: start;
  background: var(--panel-background);
  border: 1px solid var(--border);
  min-width: 0;
}

.sidebar-overview,
.list-item {
  border-radius: 6px;
}

.sidebar-overview {
  padding: 17px 17px 14px;
}

.portal-kicker,
.kicker {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-overview h1 {
  font-size: 20px;
  line-height: 1.2;
  margin: 5px 0 10px;
}

.sidebar-overview p,
.section-note,
.small-note,
.muted {
  color: var(--muted);
}

.sidebar-overview p {
  font-size: 13px;
  margin: 0;
}

.sidebar-stats {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 15px;
}

.sidebar-stat {
  background: #f5f8fb;
  border: 1px solid #e2e8f0;
  min-height: 62px;
  padding: 8px;
}

.sidebar-stat__value {
  color: #123d66;
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.05;
}

.sidebar-stat__label {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 4px;
}

.sidebar-readouts {
  border-top: 1px solid var(--border);
  padding: 14px 17px 16px;
}

.sidebar-readouts__button,
.button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: #1a2a40;
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  justify-content: center;
  line-height: 1.15;
  min-height: 34px;
  padding: 7px 10px;
  text-decoration: none;
}

.sidebar-readouts__button:hover,
.button:hover {
  background: #f1f6fb;
  border-color: var(--accent);
}

.sidebar-download,
.button.primary {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}

.sidebar-download:hover,
.button.primary:hover {
  background: #083a62;
  border-color: #083a62;
}

.button.small {
  font-size: 12px;
  min-height: 30px;
  padding: 6px 9px;
}

.button.danger {
  color: var(--danger);
}

.sidebar-readouts__button {
  width: 100%;
}

.sidebar-readouts__list {
  color: #35465d;
  font-size: 12px;
  margin: 12px 0 9px;
  padding-left: 18px;
}

.sidebar-readouts__list li {
  margin: 5px 0;
}

.sidebar-dynamic {
  border-top: 1px solid var(--border);
  padding: 14px 17px 17px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid #e4e9f0;
  margin-top: 13px;
  padding-top: 13px;
}

.sidebar-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-section h2 {
  font-size: 15px;
  line-height: 1.25;
  margin: 4px 0 9px;
}

.content-shell,
.content-frame {
  min-width: 0;
}

.content-frame {
  background: var(--panel-background);
  border: 1px solid var(--border);
}

.tabbar {
  border-bottom: 3px solid var(--header-background);
  display: flex;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 6px;
  white-space: nowrap;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: #40516a;
  flex: 0 0 auto;
  padding: 8px 10px 9px;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: -3px;
  min-height: 42px;
}

.tab:hover,
.tab:focus-visible {
  background: #f1f5f9;
  color: var(--accent-dark);
  outline: none;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: #102a43;
}

.content-body {
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel > div {
  min-height: 490px;
  padding: 18px;
}

.section-head {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.section-head h2 {
  font-size: 22px;
  line-height: 1.14;
  margin: 2px 0 0;
}

.section-head h3,
.card h3,
.mini-panel h3 {
  font-size: 15px;
  line-height: 1.25;
  margin: 0;
}

.section-note {
  font-size: 13px;
  margin: 10px 0 15px;
  max-width: 1000px;
}

.summary-chip,
.status-chip {
  border: 1px solid #b9c7d8;
  color: #25466b;
  display: inline-block;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 7px;
}

.control-card,
.card,
.mini-panel,
.status-panel,
.download-section,
.table-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}

.control-card {
  background: #f8fafc;
  padding: 13px;
}

.control-grid {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
}

.control-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.control-field label,
.label {
  color: #4d5c70;
  font-size: 12px;
  font-weight: 700;
}

.control,
input,
select,
button.linkish {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: 14px;
  min-height: 34px;
  padding: 6px 8px;
  width: 100%;
}

select[multiple] {
  min-height: 92px;
}

.toolbar-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 9px;
}

.grid-2,
.grid-3,
.grid-4,
.split {
  display: grid;
  gap: 12px;
}

.grid-2,
.split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.mini-panel {
  padding: 13px;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  min-height: 74px;
  padding: 10px;
}

.stat-value {
  color: #123d66;
  font-size: 21px;
  font-weight: 750;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  margin-top: 5px;
}

.metric-stack {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 13px;
}

.metric-box {
  border-left: 3px solid #95b8d6;
  min-width: 0;
  padding: 5px 7px;
}

.metric-box .val {
  color: #20334d;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.metric-box .lab {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.gene-chip-wrap,
.chip-wrap,
.button-row,
.status-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gene-chip {
  background: #eaf2fa;
  border: 1px solid #c6dbef;
  color: #174b75;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 6px;
}

.list {
  display: grid;
  gap: 7px;
}

.list-item {
  background: #f8fafc;
  border: 1px solid #e1e8ef;
  font-size: 12px;
  padding: 8px;
}

.bar-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(86px, 0.75fr) minmax(100px, 1.7fr) minmax(42px, auto);
  min-width: 0;
}

.bar-label,
.bar-value {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: #e8edf3;
  display: block;
  height: 14px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  background: #2374b6;
  display: block;
  height: 100%;
  width: var(--bar-fill-size, 0%);
}

.bar-fill.negative {
  background: #b54b5d;
}

.bar-track.signed {
  background: linear-gradient(90deg, #edf1f6 0 49.5%, #dfe6ee 49.5% 50.5%, #edf1f6 50.5% 100%);
}

.bar-track.signed .bar-fill {
  bottom: 0;
  position: absolute;
  top: 0;
}

.bar-track.signed .bar-fill.positive {
  left: 50%;
}

.bar-track.signed .bar-fill.negative {
  right: 50%;
}

.bar-zero {
  background: #64748b;
  bottom: 0;
  display: block;
  left: calc(50% - 0.5px);
  position: absolute;
  top: 0;
  width: 1px;
  z-index: 2;
}

.selection-summary {
  color: #35465d;
  font-size: 12px;
  line-height: 1.5;
  min-height: 57px;
}

.spatial-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.45fr);
  margin-top: 14px;
}

.spatial-canvas-wrap,
.matrix-wrap,
.umap-wrap {
  background: #070b10;
  border: 1px solid #27364a;
  min-width: 0;
  position: relative;
}

.spatial-canvas {
  display: block;
  height: auto;
  max-width: 100%;
  width: 100%;
}

.spatial-canvas {
  aspect-ratio: 1;
}

.matrix-canvas {
  background: #ffffff;
  display: block;
  height: auto;
  max-width: none;
  min-height: 0;
  width: auto;
}

.matrix-wrap {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.canvas-tooltip {
  background: #101b2b;
  border: 1px solid #95a9c1;
  color: #ffffff;
  display: none;
  font-size: 11px;
  max-width: 220px;
  padding: 7px;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.status-panel {
  min-height: 84px;
  padding: 10px;
}

.status-panel[data-state="loading"] {
  border-left: 4px solid var(--accent);
}

.status-panel[data-state="ready"] {
  border-left: 4px solid var(--success);
}

.status-panel[data-state="empty"] {
  border-left: 4px solid #95a9c1;
}

.status-panel[data-state="error"] {
  border-left: 4px solid var(--danger);
}

.status-title {
  font-size: 12px;
  font-weight: 750;
}

.status-text {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.legend-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  margin-top: 8px;
}

.dot-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(17px, 1fr));
  margin-top: 10px;
}

.dot {
  background: #367fb4;
  border: 1px solid #174b75;
  border-radius: 50%;
  min-height: 17px;
  padding: 0;
}

.dot:hover,
.dot:focus-visible {
  border-color: #0a1c2f;
  outline: 2px solid #e1a24e;
}

.dot.negative {
  background: #bc5962;
  border-color: #7c2933;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
}

.table-scroll {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.table-caption {
  color: #34465f;
  font-size: 13px;
  padding: 10px 10px 0;
}

table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 680px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f5f8fb;
  color: #3d4d63;
  font-size: 11px;
  font-weight: 750;
}

tbody tr:hover {
  background: #f8fbfe;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: end;
  margin-top: 9px;
}

.pagination span {
  color: var(--muted);
  font-size: 12px;
}

.nested-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  margin-bottom: 13px;
  overflow-x: auto;
}

.nested-tab {
  background: #f5f8fb;
  border: 1px solid var(--border);
  border-bottom: 0;
  color: #40516a;
  font-size: 12px;
  min-height: 32px;
  padding: 6px 9px;
}

.nested-tab.active {
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 750;
}

.species-heatmap {
  display: grid;
  gap: 1px;
  grid-template-columns: minmax(130px, 1fr) repeat(3, minmax(72px, 0.45fr));
  margin-top: 10px;
}

.heat-cell {
  background: #eef4f9;
  color: #23364f;
  font-size: 11px;
  min-height: 28px;
  overflow: hidden;
  padding: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heat-cell.score-negative {
  background: #f4d9d9;
}

.heat-cell.score-positive {
  background: #cfe5f4;
}

.umap-wrap {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 400px;
}

.umap-image {
  display: block;
  height: auto;
  max-width: 100%;
  width: min(620px, 100%);
}

.download-section + .download-section {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 16px;
}

.download-section {
  border: 0;
  padding: 0;
}

.download-section h3 {
  font-size: 16px;
  margin: 0;
}

.download-section > p {
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 10px;
}

.download-row {
  align-items: center;
  border: 1px solid var(--border);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 8px;
  padding: 10px;
}

.download-row h4 {
  font-size: 13px;
  margin: 0;
}

.download-row p,
.download-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.neighborhood-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.neighborhood-curve {
  overflow-x: auto;
}

.neighborhood-curve svg,
.neighborhood-network svg {
  display: block;
  min-width: 660px;
  width: 100%;
}

.neighborhood-matrix-wrap {
  overflow: auto;
}

.neighborhood-network {
  overflow-x: auto;
}

.neighborhood-axis-line,
.neighborhood-zero-line,
.neighborhood-grid-line {
  stroke: #c9d5e2;
  stroke-width: 1;
}

.neighborhood-zero-line {
  stroke: #73859a;
  stroke-dasharray: 4 3;
}

.neighborhood-grid-line {
  stroke: #e4ebf2;
}

.neighborhood-curve-line {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 2.5;
}

.neighborhood-curve-point {
  fill: #ffffff;
  stroke: var(--accent-dark);
  stroke-width: 2;
}

.neighborhood-axis-label {
  fill: #4d5c70;
  font-size: 11px;
}

.neighborhood-network-label {
  fill: #34485f;
  font-size: 10px;
}

.neighborhood-network-center-label {
  fill: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.loading-block,
.error-block,
.empty-block {
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--muted);
  min-height: 100px;
  padding: 18px;
}

.view-skeleton {
  min-height: 420px;
}

.skeleton-control,
.skeleton-panel {
  background: #edf2f7;
  border: 1px solid var(--border);
}

.skeleton-control {
  border-radius: 4px;
  height: 64px;
}

.skeleton-panel {
  min-height: 260px;
}

.error-block {
  border-left: 4px solid var(--danger);
  color: #7d1c15;
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spatial-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .workspace {
    display: block;
    padding: 8px;
  }

  .sidebar-shell {
    margin-bottom: 8px;
  }

  .app-shell.is-sidebar-collapsed .sidebar-shell {
    display: none;
  }

  .content-frame {
    min-width: 0;
  }

  .tab-panel > div {
    padding: 13px;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }

  .section-head h2 {
    font-size: 20px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .download-row {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
  }

  .bar-row {
    grid-template-columns: minmax(78px, 0.8fr) minmax(84px, 1.5fr) minmax(38px, auto);
  }
}
