:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #17324d;
  --muted: #6b7b8c;
  --border: #d7e0ea;
  --shadow: 0 10px 30px rgba(12, 32, 56, 0.08);
  --green: #22b573;
  --red: #d85a64;
  --gray: #8a99a8;
  --purple: #7a63ff;
  --blue: #4a87c8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.dashboard-page {
  background:
    radial-gradient(circle at top left, rgba(112, 161, 255, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(95, 211, 189, 0.14), transparent 24%),
    linear-gradient(180deg, #f8fbfe 0%, #eef4f9 100%);
}

.dashboard-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.dashboard-hero,
.dashboard-panel,
.metric-card,
.dashboard-modal-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #d7e3ef;
  border-radius: 22px;
  box-shadow: 0 18px 44px rgba(16, 36, 64, 0.08);
  backdrop-filter: blur(12px);
}

.dashboard-hero {
  padding: 24px 26px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.dashboard-kicker,
.panel-kicker,
.metric-label,
.detail-label,
.dashboard-modal-category {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6d8096;
}

.dashboard-hero h1,
.panel-header h2 {
  margin: 6px 0 0;
  letter-spacing: -0.03em;
}

.dashboard-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 70ch;
  line-height: 1.5;
}

.dashboard-link-btn,
.detail-link {
  color: #0f5ea8;
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.dashboard-link-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d3dfeb;
  border-radius: 999px;
  padding: 10px 14px;
  background: #f5f9fd;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

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

.metric-card {
  padding: 20px 22px;
}

.metric-value {
  margin-top: 10px;
  font-size: 2rem;
  font-weight: 800;
  color: #163e70;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.4fr);
  gap: 18px;
}

.dashboard-panel {
  padding: 20px 22px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dashboard-search {
  min-width: 240px;
  border: 1px solid #d4deea;
  border-radius: 14px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.96);
}

.faq-panel-header .dashboard-search {
  min-width: 420px;
  min-height: 56px;
  padding: 14px 18px;
  font-size: 17px;
  border-radius: 16px;
}

.dashboard-list-summary {
  color: var(--muted);
  margin-bottom: 12px;
}

.faq-callout {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #d8e3ef;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: #35526d;
  line-height: 1.55;
  box-shadow: 0 12px 28px rgba(16, 36, 64, 0.06);
}

.faq-panel-header {
  align-items: center;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.faq-card {
  border: 1px solid #dfe8f1;
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 26px rgba(16, 36, 64, 0.06);
}

.faq-card h3 {
  margin: 6px 0 0;
}

.faq-card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.faq-slug {
  font-size: 12px;
  color: #5d7388;
  background: #f5f9fd;
  border: 1px solid #d8e3ef;
  border-radius: 999px;
  padding: 7px 10px;
}

.faq-section + .faq-section {
  margin-top: 14px;
}

.faq-section p {
  margin: 6px 0 0;
  color: #35526d;
  line-height: 1.55;
}

.faq-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.faq-source-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d3dfeb;
  border-radius: 999px;
  padding: 8px 12px;
  background: #f5f9fd;
  color: #0f5ea8;
  font-weight: 700;
  text-decoration: none;
}

.target-pill {
  color: #35526d;
}

.research-grid {
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}

.research-summary-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.research-summary-body {
  min-height: 220px;
  color: #35526d;
  line-height: 1.65;
}

.research-summary-paragraph {
  margin: 0 0 12px;
}

.research-top-targets {
  margin-top: auto;
}

.paper-dashboard-search {
  min-width: 360px;
  min-height: 52px;
  padding: 13px 16px;
  font-size: 16px;
}

.dashboard-table-wrap {
  max-height: 760px;
  overflow: auto;
  border: 1px solid #e0e8f1;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
}

.dashboard-table th,
.dashboard-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #ebf0f5;
  vertical-align: top;
}

.dashboard-table th {
  position: sticky;
  top: 0;
  background: #f7fbff;
  z-index: 1;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6d8096;
}

.table-primary {
  font-weight: 700;
}

.table-secondary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.growth-chart {
  min-height: 340px;
  display: flex;
  align-items: stretch;
}

.growth-bars {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 2px 0;
}

.growth-bar-wrap {
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.growth-bar {
  width: 100%;
  max-width: 42px;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, #4a87c8 0%, #103b66 100%);
  box-shadow: 0 10px 24px rgba(16, 59, 102, 0.18);
}

.growth-bar-value {
  font-size: 18px;
  font-weight: 700;
  color: #37526d;
  line-height: 1;
}

.growth-bar-label {
  font-size: 16.5px;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  line-height: 1;
}

.dashboard-modal.hidden {
  display: none;
}

.dashboard-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.dashboard-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 24, 39, 0.42);
}

.dashboard-modal-card {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  padding: 22px 24px;
}

.dashboard-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.dashboard-modal-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  color: #57708c;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.detail-item {
  padding: 14px;
  border-radius: 14px;
  background: #f7fbff;
  border: 1px solid #e2ebf3;
}

.detail-value {
  margin-top: 6px;
  color: #17324d;
  line-height: 1.4;
}

.detail-section {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid #e2ebf3;
  background: #fbfdff;
}

.empty-state {
  color: var(--muted);
}

@media (max-width: 980px) {
  .dashboard-metrics,
  .dashboard-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero,
  .panel-header {
    flex-direction: column;
  }

  .dashboard-search {
    width: 100%;
    min-width: 0;
  }

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

@media (max-width: 640px) {
  .paper-metrics {
    grid-template-columns: 1fr;
  }
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  box-shadow: var(--shadow);
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  justify-content: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.control-group label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.control-hint {
  max-width: 100%;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

select,
.control-group input[type="number"],
.btn-primary {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.control-group input[type="number"] {
  color: #17324d;
}

.btn-primary {
  background: #103b66;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
}

.main-layout {
  display: grid;
  grid-template-columns: 1.4fr 420px;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 108px);
}

.graph-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.graph-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.tabbar {
  display: inline-flex;
  gap: 8px;
  padding: 8px 10px 0;
  order: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 0 12px 8px;
  color: var(--muted);
  font-size: 13px;
  order: 2;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #f6f9fc;
  color: #35526d;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.18s ease;
}

.tab-btn:hover {
  background: #eef4fa;
}

.tab-btn.active {
  background: #103b66;
  color: #fff;
  border-color: #103b66;
}

.view-panel {
  display: none;
  flex: 1;
  min-height: 0;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.dot,
.line {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }

.line {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--purple);
}

#cy {
  flex: 1;
  min-height: 720px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f9fbfd 0%, #eff4f8 100%);
}

.cell-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px 14px;
}

.cell-stage {
  position: relative;
  flex: 1;
  min-height: 720px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(93, 132, 179, 0.12), transparent 35%),
    linear-gradient(180deg, #f9fbfd 0%, #eff4f8 100%);
  border: 1px solid #e7edf4;
}

.cell-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cell-overlay {
  position: absolute;
  inset: 0;
}

.cell-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(122, 99, 255, 0.9);
  background: rgba(122, 99, 255, 0.14);
  box-shadow: 0 0 0 3px rgba(122, 99, 255, 0.08);
  cursor: pointer;
  transition: 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
}

.cell-hotspot:hover {
  background: rgba(122, 99, 255, 0.22);
  box-shadow: 0 0 0 5px rgba(122, 99, 255, 0.12);
}

.cell-hotspot.active {
  border-color: #103b66;
  background: rgba(16, 59, 102, 0.18);
  box-shadow: 0 0 0 6px rgba(16, 59, 102, 0.12);
}

.cell-hotspot-pulse {
  position: absolute;
  inset: 16%;
  border-radius: inherit;
  background: rgba(122, 99, 255, 0.18);
  animation: pulseRing 2.2s infinite;
  pointer-events: none;
}

.cell-hotspot.active .cell-hotspot-pulse {
  background: rgba(16, 59, 102, 0.2);
}

.cell-hotspot-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.cell-help {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 8px 2px;
}

.cell-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1280 / 922;
  min-height: unset;
  height: auto;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #f9fbfd 0%, #eff4f8 100%);
  border: 1px solid #e7edf4;
}

.cell-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.hotspot-key {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(122, 99, 255, 0.16);
  border: 2px solid rgba(122, 99, 255, 0.9);
  display: inline-block;
  flex: 0 0 auto;
}

.detail-panel {
  padding: 18px;
  overflow: auto;
}

.node-detail.empty {
  color: var(--muted);
}

.node-detail h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.node-header {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.node-image {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 3px solid #d7e0ea;
  object-fit: cover;
  background: #eef3f7;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 14px;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef4f9;
  color: #31506d;
  font-size: 12px;
  font-weight: 600;
}

.section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.kv-list,
.effect-list,
.history-list,
.test-list {
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdff;
}

.card strong {
  display: block;
  margin-bottom: 6px;
}

.small-muted {
  color: var(--muted);
  font-size: 13px;
}

.pill-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
}

.interventions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 440px;
}

ul.clean {
  margin: 8px 0 0 18px;
}

.mapped-node-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mapped-node-btn {
  border: 1px solid var(--border);
  background: #f6f9fc;
  color: #17324d;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.18s ease;
}

.mapped-node-btn:hover {
  background: #ecf3fb;
  border-color: #b7c9dc;
}

@keyframes pulseRing {
  0% {
    transform: scale(0.9);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.18);
    opacity: 0;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .faq-grid {
    grid-template-columns: 1fr;
  }

  #cy,
  .cell-stage {
    min-height: 560px;
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    justify-content: flex-start;
  }

  .cell-hotspot-label {
    font-size: 11px;
    padding: 5px 8px;
  }
}


.ask-bar {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #d9e2ea;
  border-radius: 14px;
  background: #f8fbfd;
}

.ask-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: #17324d;
}

.ask-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.ask-input {
  flex: 1;
  min-height: 74px;
  resize: vertical;
  border: 1px solid #c7d4df;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: #17324d;
  background: #fff;
}

.ask-input:focus {
  outline: none;
  border-color: #0f5ea8;
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.12);
}

.ask-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 110px;
}

.btn-secondary {
  border: 1px solid #c7d4df;
  background: #fff;
  color: #17324d;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.ask-answer {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ask-answer .answer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ask-answer .answer-body {
  line-height: 1.65;
  white-space: pre-wrap;
}

.ask-answer .answer-sources ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.ask-loading {
  color: #476987;
}

@media (max-width: 900px) {
  .ask-row {
    flex-direction: column;
  }

  .ask-actions {
    flex-direction: row;
    min-width: 0;
  }
}


.main-layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 420px;
  gap: 24px;
  align-items: start;
}

.graph-panel {
  min-width: 0;
}

.detail-panel {
  min-width: 0;
  overflow: auto;
}

#cellView {
  width: 100%;
}

.cell-stage {
  position: relative;
  width: 100%;
  max-width: 980px;
  aspect-ratio: 16 / 10;   /* adjust if your cell image uses a different shape */
  overflow: hidden;
  flex: 0 0 auto;
}

.cell-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  pointer-events: none;
}

.cell-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cell-stage {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.cell-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.cell-overlay {
  position: absolute;
  pointer-events: none; /* optional */
}

.cell-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.cell-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: unset;
}


.cell-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

.cell-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  border: 2px solid #7b6cff;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1;
}

.cell-stage {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  aspect-ratio: 1280 / 922; /* match the real image */
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #f9fbfd 0%, #eff4f8 100%);
  border: 1px solid #e7edf4;
}

.cell-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill; /* fill the same box the hotspots use */
  user-select: none;
  pointer-events: none;
}

.cell-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cell-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  border: 2px solid rgba(122, 99, 255, 0.9);
  background: rgba(122, 99, 255, 0.14);
  box-shadow: 0 0 0 3px rgba(122, 99, 255, 0.08);
  cursor: pointer;
  transition: 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1;
}

.cell-hotspot:hover {
  background: rgba(122, 99, 255, 0.22);
  box-shadow: 0 0 0 5px rgba(122, 99, 255, 0.12);
}

.cell-hotspot.active {
  border-color: #103b66;
  background: rgba(16, 59, 102, 0.18);
  box-shadow: 0 0 0 6px rgba(16, 59, 102, 0.12);
}

.cell-hotspot-pulse {
  position: absolute;
  inset: 16%;
  border-radius: inherit;
  background: rgba(122, 99, 255, 0.18);
  animation: pulseRing 2.2s infinite;
  pointer-events: none;
}

.cell-hotspot.active .cell-hotspot-pulse {
  background: rgba(16, 59, 102, 0.2);
}

.cell-hotspot-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}


.interventions-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 340px;
  max-width: 520px;
}

.interventions-toprow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.intervention-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4dde6;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #17324d;
}

.interventions-toggle-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.interventions-summary {
  font-size: 12px;
  color: #6f8297;
  min-height: 16px;
}

.selected-interventions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-interventions-label {
  font-size: 12px;
  font-weight: 700;
  color: #51667d;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.selected-interventions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-intervention-chip {
  border: none;
  background: #eaf3ff;
  color: #0f4f8c;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.selected-interventions-empty {
  font-size: 13px;
  color: #73879b;
  padding: 2px 0;
}

.better-interventions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.intervention-category-card {
  background: #fff;
  border: 1px solid #d8e1ea;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(18, 44, 70, 0.04);
}

.intervention-category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.intervention-category-title {
  font-size: 14px;
  font-weight: 700;
  color: #17324d;
}

.intervention-category-count {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #eef4f8;
  color: #4f6477;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.intervention-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.intervention-chip {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.intervention-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.intervention-chip-body {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d8e1ea;
  background: #f8fbfd;
  color: #17324d;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.intervention-chip input:checked + .intervention-chip-body {
  background: #17324d;
  color: #fff;
  border-color: #17324d;
}

.intervention-chip-body:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 50, 77, 0.08);
}

.intervention-chip-name {
  line-height: 1.2;
}

.intervention-common-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(122, 99, 255, 0.12);
  color: #6a57d8;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
}

.intervention-chip input:checked + .intervention-chip-body .intervention-common-badge {
  background: rgba(255,255,255,0.16);
  color: #fff;
}


.view-tabs {
  display: flex;
  justify-content: flex-start; /* THIS is the key */
  align-items: center;
  gap: 10px;
}

.patient-state-card {
  background: rgba(255,255,255,0.82);
  border: 1px solid #d9e4ef;
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 55px rgba(16, 36, 64, 0.08);
  border-radius: 22px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.labs-card {
  gap: 12px;
}

.labs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #35526d;
}

.labs-file-input {
  width: 100%;
  border: 1px dashed #c8d7e5;
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.labs-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.energy-score-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.uploaded-labs-list {
  display: grid;
  gap: 8px;
}

.uploaded-lab-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7fbff;
  border: 1px solid #d7e3ef;
  color: #35526d;
  font-size: 13px;
}

.labs-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(247, 251, 255, 0.92);
  border: 1px solid #d7e3ef;
}

.labs-summary.hidden {
  display: none;
}

.labs-score-line {
  font-weight: 700;
  color: #17324d;
}

.labs-driver-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.labs-driver-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d7e3ef;
  color: #35526d;
  font-size: 12px;
  font-weight: 700;
}

.patient-state-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.patient-state-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.patient-state-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patient-state-category-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6d8096;
}

.patient-state-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.patient-state-chip {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.patient-state-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.patient-state-chip-body {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d8e1ea;
  background: #f8fbfd;
  color: #17324d;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.patient-state-chip input:checked + .patient-state-chip-body {
  background: #8a5a2b;
  color: #fff;
  border-color: #8a5a2b;
}

.patient-state-chip-body:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 50, 77, 0.08);
}

.page-hero {
  margin-bottom: 10px;
  padding: 6px 6px 2px 6px;  /* MUCH tighter */
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.page-hero h1 {
  margin: 6px 0 4px 0;
  font-size: 32px;
}

.page-hero .subtitle {
  margin: 0;
  line-height: 1.4;
}

.page-hero::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(18,63,115,0.08), transparent 68%);
  pointer-events: none;
}

.page-ask-bar {
  margin-bottom: 20px;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.left-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 20px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.controls-stack-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  min-height: 0;
}

.controls-stack-card .control-group {
  min-width: 0;
}

.controls-stack-card .controls-footer {
  padding-top: 0;
  justify-content: stretch;
}

.controls-stack-card .controls-footer .btn-primary,
.controls-stack-card .controls-footer .btn-secondary {
  width: 100%;
}

.content-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.graph-panel--top {
  min-height: 0;
  padding: 18px;
}

.graph-top-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.energy-score-card {
  border: 1px solid #d9e4ec;
  border-radius: 18px;
  padding: 18px 20px;
  background:
    radial-gradient(circle at top right, rgba(45, 156, 116, 0.14), transparent 36%),
    linear-gradient(180deg, #fbfdff 0%, #f2f7fb 100%);
  box-shadow: 0 10px 24px rgba(19, 50, 77, 0.08);
}

.energy-score-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.energy-score-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4f6b84;
}

.energy-score-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.energy-score-info-btn {
  border: 1px solid #cfdde8;
  background: rgba(255, 255, 255, 0.9);
  color: #24557d;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.energy-score-info-btn:hover {
  background: #ffffff;
  border-color: #b6cbdb;
}

.energy-score-caption {
  margin-top: 6px;
  max-width: 760px;
  color: #547087;
  font-size: 13px;
  line-height: 1.45;
}

.energy-score-value-wrap {
  flex-shrink: 0;
  text-align: right;
}

.energy-score-value {
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1;
  font-weight: 800;
  color: #17324d;
}

.energy-score-band {
  margin-top: 6px;
  color: #547087;
  font-size: 13px;
  font-weight: 700;
}

.energy-score-meter {
  margin-top: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c84857 0%, #dc8a4c 28%, #d8c35c 52%, #6abb6e 76%, #1f9b5d 100%);
  overflow: hidden;
  position: relative;
}

.energy-score-meter::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.energy-score-meter-fill {
  position: absolute;
  inset: 0 0 0 auto;
  width: 100%;
  background: rgba(242, 247, 251, 0.82);
  transition: width 0.25s ease;
}

.energy-score-summary {
  margin-top: 14px;
  color: #17324d;
  font-size: 14px;
  line-height: 1.5;
}

.energy-score-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.energy-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #d7e2eb;
  color: #35526d;
  font-size: 12px;
  font-weight: 700;
}

.panel-top--stacked {
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.legend {
  width: 100%;
}

.detail-panel {
  min-height: 360px;
}

.patient-state-list,
.better-interventions {
  max-height: 320px;
}

@media (max-width: 1200px) {
  .workspace-layout {
    grid-template-columns: 340px minmax(0, 1fr);
  }
}

@media (max-width: 1080px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .left-sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .page-hero {
    padding: 20px 18px;
  }

  .workspace-layout {
    gap: 16px;
  }

  .left-sidebar {
    gap: 16px;
  }

  .energy-score-topline {
    flex-direction: column;
  }

  .energy-score-value-wrap {
    text-align: left;
  }
}


.ask-bar {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
}

.ask-input {
  flex: 1;
}

.ask-input textarea {
  width: 100%;
  min-height: 70px;
}

.ask-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}


/* ===== Detail modal ===== */

.hidden {
  display: none !important;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 24, 39, 0.42);
  backdrop-filter: blur(4px);
}

.detail-modal-dialog {
  position: relative;
  width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  background: rgba(255,255,255,0.96);
  border: 1px solid #d9e4ef;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(16, 36, 64, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.detail-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e3ebf3;
  background: linear-gradient(180deg, rgba(248,251,254,0.98), rgba(243,248,252,0.98));
}

.detail-modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #17324d;
}

.detail-modal-subtitle {
  margin-top: 4px;
  font-size: 0.88rem;
  color: #6b7b8c;
}

.detail-modal-close {
  border: 1px solid #d7e3ef;
  background: #ffffff;
  color: #17324d;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.detail-modal-close:hover {
  background: #f3f7fb;
}

.detail-modal-content {
  padding: 18px;
  overflow: auto;
  min-height: 0;
}

.detail-modal .node-detail {
  height: auto;
  min-height: 0;
  border-radius: 18px;
  background: rgba(255,255,255,0.82);
  border: 1px solid #e0e9f3;
  padding: 22px;
}

.detail-modal .node-detail.empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
}

.energy-score-explainer {
  display: grid;
  gap: 18px;
}

.energy-score-explainer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.energy-score-explainer-card {
  padding: 16px 18px;
  border-radius: 16px;
  background: #f7fbff;
  border: 1px solid #dde8f1;
}

.energy-score-explainer-card h3 {
  margin: 0 0 10px;
  color: #17324d;
}

.energy-score-explainer-card p,
.energy-score-explainer-card li {
  color: #35526d;
  line-height: 1.5;
}

.energy-score-explainer-card ul {
  margin: 0;
  padding-left: 18px;
}

.energy-score-formula {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #17324d;
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #d7e3ef;
  border-radius: 14px;
  padding: 12px 14px;
}

@media (max-width: 860px) {
  .energy-score-explainer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .detail-modal-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    margin: 10px auto;
    border-radius: 16px;
  }

  .detail-modal-header {
    padding: 14px 14px 12px;
  }

  .detail-modal-content {
    padding: 12px;
  }
}
