:root {
  --ink: #17232e;
  --muted: #64717d;
  --line: #dce4e8;
  --paper: #ffffff;
  --wash: #f3f7f7;
  --navy: #173b4d;
  --teal: #117c7a;
  --teal-soft: #e3f3f1;
  --gold: #e3a849;
  --danger: #b94b52;
  --shadow: 0 18px 55px rgba(23, 59, 77, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.sbio-sitebar {
  min-height: 76px; padding: 8px 28px; display: flex; align-items: center; gap: 24px;
  border-bottom: 1px solid #dce8ea; background: #fff; color: #102b59;
}
.sbio-brand { display: flex; align-items: center; gap: 11px; color: #102b59; text-decoration: none; }
.sbio-brand img { width: 58px; height: 58px; object-fit: contain; }
.sbio-brand strong { font: 800 17px Arial, Helvetica, sans-serif; }
.sbio-sitebar nav { margin-left: auto; display: flex; gap: 20px; }
.sbio-sitebar nav a { color: #52616c; text-decoration: none; font-size: 13px; font-weight: 700; }
.sbio-sitebar nav a:hover { color: #117c7a; }

.topbar {
  height: 82px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  background: linear-gradient(115deg, #102f40 0%, #174f5a 58%, #117c7a 100%);
  box-shadow: 0 6px 22px rgba(15, 48, 64, .2);
}
.topbar h1 { margin: 0; font: 700 19px Arial, Helvetica, sans-serif; letter-spacing: .02em; }
.topbar p { margin: 2px 0 0; color: #c7dcdf; font-size: 13px; }
.dataset-badge {
  margin-left: auto; padding: 9px 13px; border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px; background: rgba(255,255,255,.08); color: #d9e9ea; font-size: 12px;
}

.app-shell { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: calc(100vh - 158px); }
.sidebar {
  padding: 28px 22px 40px;
  border-right: 1px solid var(--line);
  background: #fbfdfd;
  position: sticky; top: 0; height: calc(100vh - 158px); overflow-y: auto;
}
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar h2, .workspace h2 { margin: 6px 0 5px; font-family: Arial, Helvetica, sans-serif; font-weight: 700; }
.sidebar-heading p, .selection-card p, .plot-heading p { color: var(--muted); line-height: 1.5; margin: 6px 0 0; font-size: 13px; }

.search-box { display: block; margin: 23px 0 14px; }
.search-box span, .control-field > span { display: block; margin-bottom: 7px; color: #53616c; font-size: 12px; font-weight: 700; }
input[type="search"], select {
  width: 100%; min-height: 42px; padding: 0 12px;
  border: 1px solid #cdd8dd; border-radius: 9px; outline: none; background: white; color: var(--ink);
}
input[type="search"]:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(17,124,122,.12); }
.search-results { border: 1px solid var(--line); background: white; border-radius: 10px; margin-bottom: 14px; max-height: 285px; overflow-y: auto; box-shadow: var(--shadow); }

.root-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 14px 0; }
.root-button {
  border: 1px solid #cbd9dc; border-radius: 10px; padding: 10px 6px; background: white;
  color: var(--navy); font-weight: 800; font-size: 12px;
}
.root-button.active, .root-button:hover { color: white; background: var(--teal); border-color: var(--teal); }
.breadcrumb { display: flex; gap: 5px; flex-wrap: wrap; min-height: 25px; margin: 12px 0; }
.crumb { border: 0; padding: 3px 0; background: transparent; color: var(--teal); font-size: 11px; }
.crumb:not(:last-child)::after { content: " /"; color: #9ba8ae; }
.tree-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 8px; border-top: 1px solid var(--line); font-weight: 800; font-size: 12px; }
.count-pill { padding: 3px 8px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); }
.children-list { display: grid; gap: 7px; }
.term-button, .search-item {
  width: 100%; border: 1px solid transparent; background: white; border-radius: 9px;
  padding: 10px 11px; text-align: left; color: var(--ink);
}
.term-button:hover, .search-item:hover { border-color: #b7d7d4; background: #f0f8f7; }
.term-line { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; line-height: 1.35; }
.term-meta { margin-top: 4px; color: var(--muted); font-size: 10px; }
.record-count { white-space: nowrap; color: var(--teal); font-size: 10px; }

.workspace { padding: 28px; min-width: 0; }
.selection-card, .controls-card, .plot-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.selection-card { display: flex; justify-content: space-between; gap: 25px; align-items: center; padding: 21px 23px; border-left: 5px solid var(--gold); }
.selection-card h2 { font-size: 24px; }
.switch-row { display: flex; align-items: center; gap: 9px; min-width: max-content; color: #53616c; font-size: 12px; font-weight: 700; }
.switch-row input { position: absolute; opacity: 0; }
.switch { width: 38px; height: 22px; border-radius: 20px; background: #bec9ce; position: relative; transition: .2s; }
.switch::after { content: ""; width: 16px; height: 16px; border-radius: 50%; background: white; position: absolute; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch-row input:checked + .switch { background: var(--teal); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }

.controls-card, .plot-card { margin-top: 20px; padding: 23px; }
.section-title, .plot-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.section-title h2, .plot-heading h2 { font-size: 21px; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-top: 21px; }
.filter-card { border: 1px solid var(--line); border-radius: 11px; padding: 11px; background: #fbfcfc; }
.filter-card strong { display: block; margin-bottom: 7px; font-size: 12px; }
.filter-options { display: grid; gap: 5px; max-height: 116px; overflow-y: auto; }
.filter-option { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 11px; background: white; }
.filter-option:hover { background: var(--teal-soft); }
.filter-option input { accent-color: var(--teal); }
.filter-option.disabled { opacity: .42; }
.filter-option-count { margin-left: auto; color: var(--teal); font-size: 10px; }
.filter-card small { display: block; margin-top: 6px; color: var(--muted); }
.availability-panel { margin-top: 13px; padding: 12px 14px; border-radius: 10px; background: #edf6f5; color: #41545c; font-size: 11px; line-height: 1.55; }
.availability-panel strong { color: var(--navy); }
.gene-compare-field { display: block; margin-top: 17px; }
.gene-compare-field > span { display: block; margin-bottom: 7px; color: #53616c; font-size: 12px; font-weight: 800; }
.gene-compare-field textarea { width: 100%; min-height: 58px; padding: 11px 12px; resize: vertical; border: 1px solid #cdd8dd; border-radius: 9px; outline: none; color: var(--ink); background: #fff; font: 13px Arial, Helvetica, sans-serif; }
.gene-compare-field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(17,124,122,.12); }
.gene-compare-field small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.control-divider { height: 1px; background: var(--line); margin: 21px 0; }
.analysis-grid { display: grid; grid-template-columns: minmax(300px, 1.8fr) repeat(3, minmax(130px, .7fr)); gap: 18px; align-items: end; }
.grouping-fieldset { border: 0; margin: 0; padding: 0; }
.grouping-fieldset legend { margin-bottom: 9px; font-size: 12px; font-weight: 800; }
.grouping-fieldset p { color: var(--muted); font-size: 10px; margin: 7px 0 0; }
.check-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.check-chip input { position: absolute; opacity: 0; }
.check-chip span { display: inline-flex; padding: 8px 10px; border: 1px solid #cdd8dd; border-radius: 8px; font-size: 11px; font-weight: 700; background: white; }
.check-chip input:checked + span { color: white; background: var(--navy); border-color: var(--navy); }
.button { border: 0; border-radius: 9px; padding: 10px 14px; font-weight: 800; font-size: 12px; }
.button.primary { margin-top: 22px; width: 100%; display: flex; justify-content: center; gap: 12px; color: white; background: var(--teal); font-size: 14px; }
.button.primary:hover { background: #0d6c6a; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.ghost { color: var(--navy); background: #edf3f4; }
.plot-actions { display: flex; gap: 8px; }

.plot-status { min-height: 360px; }
.empty-state { display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.empty-state.small { min-height: 110px; font-size: 11px; }
.empty-icon { font-size: 42px; color: #94afb4; }
.heatmap-wrap { position: relative; margin-top: 18px; overflow: auto; max-height: 760px; border: 1px solid var(--line); border-radius: 10px; background: white; }
#heatmapCanvas { display: block; }
.tooltip { position: fixed; z-index: 30; pointer-events: none; padding: 9px 11px; border-radius: 8px; color: white; background: rgba(20,36,46,.94); font-size: 11px; line-height: 1.45; box-shadow: 0 8px 25px rgba(0,0,0,.2); }
.legend { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 11px; }
.legend-bar { width: 180px; height: 9px; border-radius: 999px; background: linear-gradient(90deg, #173b8f, #f5f3e9, #b5263b); }
.spinner { width: 28px; height: 28px; border: 3px solid #cee4e2; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.error { color: var(--danger); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .analysis-grid { grid-template-columns: 1fr 1fr; }
  .grouping-fieldset { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .dataset-badge { display: none; }
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { padding: 16px; }
  .selection-card, .section-title, .plot-heading { flex-direction: column; align-items: stretch; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .plot-actions { width: 100%; }
}
