:root {
  --bg: #f7f2ea;
  --panel: rgba(255, 250, 243, 0.84);
  --text: #17324d;
  --muted: #61748f;
  --border: rgba(17, 43, 73, 0.1);
  --shadow: 0 18px 38px rgba(17, 43, 73, 0.08);
  --green: #22b573;
  --red: #d85a64;
  --gray: #8a99a8;
  --purple: #7a63ff;
  --blue: #2d68c4;
  --navy: #112b49;
  --teal: #0d9b8a;
  --gold: #d78f2b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.dashboard-page {
  background:
    radial-gradient(circle at top left, rgba(45, 104, 196, 0.14), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(13, 155, 138, 0.18), transparent 20%),
    linear-gradient(180deg, #efe6d8 0%, #f9f4ec 24%, #f7f4ef 100%);
}

.dashboard-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 0 40px;
}

.dashboard-hero,
.dashboard-panel,
.metric-card,
.dashboard-modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.dashboard-hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 250, 243, 0.92), rgba(244, 250, 249, 0.84)),
    #fff;
}

.dashboard-hero::before,
.dashboard-hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.dashboard-hero::before {
  width: 220px;
  height: 220px;
  right: -72px;
  top: -72px;
  background: radial-gradient(circle, rgba(45, 104, 196, 0.16), transparent 68%);
}

.dashboard-hero::after {
  width: 180px;
  height: 180px;
  left: -54px;
  bottom: -60px;
  background: radial-gradient(circle, rgba(13, 155, 138, 0.16), transparent 70%);
}

.dashboard-kicker,
.panel-kicker,
.metric-label,
.detail-label,
.dashboard-modal-category {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--navy);
}

.dashboard-hero h1,
.panel-header h2 {
  margin: 6px 0 0;
  letter-spacing: -0.04em;
  line-height: 0.98;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

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

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

.dashboard-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(17, 43, 73, 0.14);
  border-radius: 999px;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.62);
  text-align: center;
}

.dashboard-modal-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(17, 43, 73, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.dashboard-modal-trigger:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(28, 46, 74, 0.1);
  background: #fff;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: flex-end;
  max-width: 500px;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(4, 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: var(--navy);
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -0.05em;
}

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

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

.chart-panel {
  min-height: 420px;
}

.dashboard-list-panel {
  margin-top: 18px;
}

.intervention-admin-panel {
  margin-top: 18px;
}

.intervention-admin-header {
  margin-bottom: 10px;
}

.intervention-admin-copy {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 78ch;
}

.intervention-admin-form {
  display: grid;
  gap: 14px;
}

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

.intervention-admin-field {
  display: grid;
  gap: 8px;
}

.intervention-admin-label {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #637892;
}

.intervention-admin-inline-form {
  margin-top: 14px;
}

.intervention-admin-checkbox-field {
  align-content: start;
}

.intervention-admin-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(17, 43, 73, 0.1);
  background: rgba(255, 255, 255, 0.72);
  color: #334a63;
}

.intervention-admin-checkbox input {
  width: 16px;
  height: 16px;
}

.intervention-admin-textarea {
  min-height: 132px;
  padding: 14px 16px;
  resize: vertical;
}

.intervention-admin-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.intervention-admin-status {
  color: #5f4a37;
  font-size: 0.95rem;
  line-height: 1.45;
}

.intervention-admin-status.is-error {
  color: #8f2f2f;
}

.intervention-admin-results {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.92);
  border: 1px solid rgba(17, 43, 73, 0.1);
}

.intervention-admin-result-summary,
.intervention-admin-queue {
  color: #5f4a37;
  line-height: 1.5;
}

.intervention-admin-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.intervention-admin-result-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(17, 43, 73, 0.08);
}

.intervention-admin-result-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b5845;
}

.intervention-admin-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.intervention-admin-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(246, 236, 223, 0.92);
  border: 1px solid rgba(138, 90, 43, 0.18);
  color: #5c4531;
  font-size: 12px;
  font-weight: 700;
}

.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 rgba(17, 43, 73, 0.14);
  border-radius: 14px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.96);
}

.dashboard-list-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard-filter-btn {
  border: 1px solid rgba(17, 43, 73, 0.14);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.dashboard-filter-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-color: transparent;
  color: #fff;
}

.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 rgba(138, 90, 43, 0.18);
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.92);
  color: #5f4a37;
  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-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.faq-load-more-btn {
  min-width: 180px;
}

.faq-card {
  border: 1px solid rgba(17, 43, 73, 0.1);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 250, 243, 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: #6b5845;
  background: rgba(246, 236, 223, 0.92);
  border: 1px solid rgba(138, 90, 43, 0.18);
  border-radius: 999px;
  padding: 7px 10px;
}

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

.faq-section p {
  margin: 6px 0 0;
  color: #5f4a37;
  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 rgba(138, 90, 43, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(246, 236, 223, 0.9);
  color: #5c4531;
  font-weight: 700;
  text-decoration: none;
}

.target-pill {
  color: #5f4a37;
}

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

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

.research-summary-body {
  min-height: 220px;
  color: #5f4a37;
  font-size: 17px;
  line-height: 1.65;
}

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

.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 rgba(17, 43, 73, 0.1);
  border-radius: 16px;
  background: rgba(255, 250, 243, 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 rgba(17, 43, 73, 0.08);
  vertical-align: top;
}

.dashboard-table th {
  position: sticky;
  top: 0;
  background: rgba(246, 236, 223, 0.92);
  z-index: 1;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b5845;
}

.dashboard-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.dashboard-sort-btn:hover,
.dashboard-sort-btn:focus-visible {
  color: #8a5a2b;
  outline: none;
}

.dashboard-sort-btn.is-active {
  color: #8a5a2b;
}

.dashboard-sort-indicator {
  min-width: 12px;
  font-size: 11px;
}

.dashboard-flag-header {
  min-width: 132px;
}

.dashboard-flag-cell {
  text-align: center;
  vertical-align: middle;
}

.dashboard-flag-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.dashboard-flag-checkbox:disabled {
  cursor: wait;
}

.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%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  overflow: hidden;
  padding: 8px 2px 0;
}

.growth-bar-wrap {
  min-width: 0;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.growth-bar {
  width: 100%;
  max-width: 42px;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, #d8b37a 0%, #8a5a2b 100%);
  box-shadow: 0 10px 24px rgba(138, 90, 43, 0.18);
}

.growth-bar-value {
  min-height: 24px;
  font-size: 18px;
  font-weight: 700;
  color: #6b5845;
  line-height: 1;
}

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

.growth-bars-dense {
  gap: 4px;
  padding-right: 24px;
}

.growth-bars-dense .growth-bar-wrap {
  gap: 6px;
}

.growth-bars-dense .growth-bar {
  max-width: none;
  border-radius: 8px 8px 3px 3px;
}

.growth-bars-dense .growth-bar-label {
  min-height: 42px;
  font-size: 12px;
}

.growth-bar-value-hidden {
  visibility: hidden;
  font-size: 12px;
}

.growth-bars-dense .growth-bar-wrap-last {
  align-items: flex-end;
}

.growth-bars-dense .growth-bar-value-last {
  width: max-content;
  max-width: none;
  text-align: right;
  transform: translateX(-8px);
}

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

.cumulative-chart-shell {
  width: 100%;
  min-height: 340px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.94), rgba(248, 242, 233, 0.88));
  border: 1px solid rgba(138, 90, 43, 0.12);
  padding: 12px 14px 6px;
}

.cumulative-chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cumulative-chart-line {
  filter: drop-shadow(0 8px 14px rgba(138, 90, 43, 0.18));
}

.cumulative-chart-point {
  fill: #d8b37a;
  stroke: #fffaf3;
  stroke-width: 3;
}

.cumulative-chart-point-last {
  fill: #8a5a2b;
}

.cumulative-chart-label {
  fill: #61748f;
  font-size: 12px;
  font-weight: 700;
}

.cumulative-chart-total {
  fill: #5c4531;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

@media (max-width: 1400px) {
  .research-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .research-grid {
    grid-template-columns: 1fr;
  }
}

.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: rgba(255, 248, 239, 0.92);
  border: 1px solid rgba(17, 43, 73, 0.1);
}

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

.detail-section {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(17, 43, 73, 0.1);
  background: rgba(255, 250, 243, 0.96);
}

.intervention-admin-detail-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(17, 43, 73, 0.08);
}

.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;
  }

  .intervention-admin-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-list-controls {
    width: 100%;
    align-items: stretch;
  }

  .dashboard-actions {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
  }

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

  .dashboard-list-panel {
    margin-top: 16px;
  }

  .intervention-admin-actions {
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .paper-metrics {
    grid-template-columns: 1fr;
  }
}

button,
select,
input,
textarea {
  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: linear-gradient(135deg, var(--navy), #8a5a2b);
  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: rgba(246, 236, 223, 0.82);
  color: #5f4a37;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.18s ease;
}

.tab-btn:hover {
  background: rgba(240, 225, 208, 0.9);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--navy), #8a5a2b);
  color: #fff;
  border-color: transparent;
}

.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, #fffaf3 0%, #f4ecdf 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(215, 143, 43, 0.12), transparent 35%),
    linear-gradient(180deg, #fffaf3 0%, #f4ecdf 100%);
  border: 1px solid rgba(17, 43, 73, 0.08);
}

.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(138, 90, 43, 0.85);
  background: rgba(215, 143, 43, 0.14);
  box-shadow: 0 0 0 3px rgba(138, 90, 43, 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(215, 143, 43, 0.22);
  box-shadow: 0 0 0 5px rgba(138, 90, 43, 0.12);
}

.cell-hotspot.active {
  border-color: var(--navy);
  background: rgba(17, 43, 73, 0.16);
  box-shadow: 0 0 0 6px rgba(17, 43, 73, 0.1);
}

.cell-hotspot-pulse {
  position: absolute;
  inset: 16%;
  border-radius: inherit;
  background: rgba(215, 143, 43, 0.18);
  animation: pulseRing 2.2s infinite;
  pointer-events: none;
}

.cell-hotspot.active .cell-hotspot-pulse {
  background: rgba(17, 43, 73, 0.18);
}

.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: rgba(246, 236, 223, 0.92);
  color: #5c4531;
  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 rgba(17, 43, 73, 0.1);
  border-radius: 14px;
  background: rgba(255, 250, 243, 0.94);
}

.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: #8a5a2b;
  box-shadow: 0 0 0 3px rgba(138, 90, 43, 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-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.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: rgba(246, 236, 223, 0.96);
  color: #5c4531;
  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 rgba(17, 43, 73, 0.1);
  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: rgba(246, 236, 223, 0.92);
  color: #6b5845;
  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 rgba(17, 43, 73, 0.1);
  background: rgba(255, 248, 239, 0.92);
  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: linear-gradient(135deg, var(--navy), #8a5a2b);
  color: #fff;
  border-color: transparent;
}

.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(215, 143, 43, 0.16);
  color: #8a5a2b;
  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 rgba(17, 43, 73, 0.1);
  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: #5f4a37;
}

.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;
}

.energy-score-submit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.energy-score-side #submitMapStateBtn,
.energy-score-side #generateReportBtn {
  width: 172px;
  text-align: center;
  line-height: 1.2;
}

.energy-score-inline-info {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(138, 90, 43, 0.18);
  background: rgba(255, 252, 247, 0.94);
  color: #8a5a2b;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  box-shadow: 0 4px 12px rgba(17, 43, 73, 0.06);
}

.energy-score-inline-info:hover {
  background: #ffffff;
  border-color: rgba(138, 90, 43, 0.28);
}

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

.uploaded-lab-item {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 250, 244, 0.96), rgba(247, 239, 228, 0.96));
  border: 1px solid rgba(17, 43, 73, 0.1);
  box-shadow: 0 10px 24px rgba(17, 43, 73, 0.06);
  color: #5f4a37;
  font-size: 13px;
}

.uploaded-lab-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.uploaded-lab-copy > span:first-child {
  font-size: 1.08rem;
  line-height: 1.35;
  font-weight: 700;
  color: #17324d;
  overflow-wrap: anywhere;
}

.uploaded-lab-copy .small-muted {
  color: #7d6a57;
  font-size: 0.9rem;
  line-height: 1.4;
}

.uploaded-lab-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.uploaded-lab-score {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(17, 43, 73, 0.08);
  font-size: 12px;
  font-weight: 700;
  color: #61748f;
  white-space: nowrap;
}

.uploaded-lab-score.is-positive {
  color: #177245;
}

.uploaded-lab-score.is-negative {
  color: #8b3f2d;
}

.labs-remove-btn {
  border: 1px solid rgba(140, 63, 44, 0.18);
  background: rgba(255, 255, 255, 0.88);
  color: #8b3f2d;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.labs-remove-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.labs-summary {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 248, 239, 0.92);
  border: 1px solid rgba(17, 43, 73, 0.1);
}

.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 rgba(17, 43, 73, 0.1);
  color: #5f4a37;
  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 rgba(17, 43, 73, 0.1);
  background: rgba(255, 248, 239, 0.92);
  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);
}

.dashboard-panel,
.detail-item,
.detail-section,
.badge,
.ask-bar,
.energy-score-explainer-card,
.energy-score-formula,
.map-submit-input,
.map-submit-modal-dialog,
.detail-modal-dialog,
.detail-modal .node-detail {
  border-color: rgba(17, 43, 73, 0.1);
}

.detail-item,
.energy-score-explainer-card,
.detail-section,
.detail-modal .node-detail {
  background: rgba(255, 248, 239, 0.94);
}

.badge,
.energy-score-pill,
.labs-driver-chip,
.faq-source-link,
.dashboard-link-btn,
.dashboard-filter-btn {
  background: rgba(246, 236, 223, 0.92);
  border-color: rgba(138, 90, 43, 0.18);
  color: #5c4531;
}

.dashboard-link-btn,
.dashboard-filter-btn,
.faq-source-link,
.dashboard-modal-trigger,
.detail-link {
  color: #5c4531;
}

.dashboard-filter-btn[aria-pressed="true"],
.btn-primary,
.tab-btn.active {
  background: linear-gradient(135deg, var(--navy), #8a5a2b);
  border-color: transparent;
}

.btn-secondary,
.tab-btn,
.ask-bar,
.map-submit-input,
.dashboard-table th,
.dashboard-table-wrap,
.energy-score-formula {
  background: rgba(255, 250, 243, 0.94);
}

.dashboard-table th {
  color: #6b5845;
}

.map-submit-input:focus,
.ask-input:focus {
  border-color: #8a5a2b;
  box-shadow: 0 0 0 4px rgba(138, 90, 43, 0.12);
}

.energy-score-card {
  border-color: rgba(138, 90, 43, 0.16);
  background:
    radial-gradient(circle at top right, rgba(215, 143, 43, 0.14), transparent 36%),
    linear-gradient(180deg, #fffaf3 0%, #f4ecdf 100%);
  box-shadow: 0 10px 24px rgba(138, 90, 43, 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-preference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 12px 16px;
  margin-top: 16px;
}

.energy-preference-grid .control-group {
  margin: 0;
}

.energy-preference-help {
  margin-top: 10px;
}

.energy-preference-total {
  margin-top: 8px;
  font-weight: 700;
  color: #35526d;
}

.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-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

.energy-score-details-btn {
  white-space: nowrap;
}

.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-preference-grid {
    grid-template-columns: 1fr;
  }

  .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;
}

.interventions-modal-dialog {
  width: min(980px, calc(100vw - 56px));
}

.interventions-modal-content {
  padding: 20px;
  overflow: auto;
}

.interventions-modal-shell {
  min-width: 0;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  gap: 14px;
}

.interventions-modal-shell .better-interventions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-height: none;
  max-width: none;
  min-height: 420px;
  overflow: visible;
  padding-right: 6px;
}

.interventions-modal-shell .intervention-category-card {
  width: 100%;
  padding: 14px;
}

.interventions-modal-shell .intervention-chip-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
}

.interventions-modal-shell .intervention-item-row {
  grid-template-columns: minmax(280px, 460px) auto auto;
  justify-content: center;
}

.interventions-modal-shell .intervention-chip {
  display: flex;
  width: 100%;
  max-width: 460px;
}

.interventions-modal-shell .intervention-chip-body {
  width: 100%;
  justify-content: space-between;
}

.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: rgba(255, 248, 239, 0.92);
  border: 1px solid rgba(17, 43, 73, 0.1);
}

.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 rgba(17, 43, 73, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
}

.map-submit-modal-dialog {
  width: min(560px, calc(100vw - 40px));
}

.map-submit-modal-header {
  padding-bottom: 16px;
}

.map-submit-modal-content {
  padding: 22px;
}

.map-submit-form {
  display: grid;
  gap: 12px;
}

.map-submit-label {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #637892;
}

.map-submit-input {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid rgba(17, 43, 73, 0.12);
  background: linear-gradient(180deg, rgba(255,250,243,0.98), rgba(247,240,230,0.98));
  color: #17324d;
  font: inherit;
  font-weight: 600;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.map-submit-textarea {
  min-height: 108px;
  padding: 14px 16px;
  resize: vertical;
}

.map-submit-input:focus {
  border-color: #8a5a2b;
  box-shadow: 0 0 0 4px rgba(138, 90, 43, 0.12);
  transform: translateY(-1px);
}

.map-submit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #17324d;
  font-weight: 700;
}

.map-submit-checkbox input {
  width: 18px;
  height: 18px;
}

.map-submit-help {
  color: #6b7b8c;
  font-size: 0.92rem;
  line-height: 1.45;
}

.map-submit-error {
  padding: 11px 13px;
  border-radius: 14px;
  background: rgba(182, 61, 61, 0.08);
  border: 1px solid rgba(182, 61, 61, 0.16);
  color: #b63d3d;
  font-size: 0.92rem;
  line-height: 1.45;
}

.map-submit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-clear-modal-dialog {
  width: min(520px, calc(100vw - 40px));
}

.confirm-clear-modal-content {
  padding: 22px;
}

.confirm-clear-body {
  display: grid;
  gap: 14px;
}

.confirm-clear-callout {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(182, 61, 61, 0.16);
  background: linear-gradient(180deg, rgba(255, 246, 244, 0.96), rgba(255, 240, 236, 0.98));
  color: #7a3f36;
  line-height: 1.5;
}

.confirm-clear-message {
  color: #5e7188;
  line-height: 1.6;
}

.confirm-clear-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

@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;
  }

  .map-submit-modal-content {
    padding: 16px;
  }

  .map-submit-actions {
    flex-direction: column;
  }

  .interventions-card-actions {
    width: 100%;
    justify-content: stretch;
  }

  .interventions-card-actions .btn-secondary {
    flex: 1 1 0;
  }

  .interventions-toprow {
    flex-wrap: wrap;
  }

  .interventions-toggle-btn {
    width: 100%;
  }

  .interventions-modal-shell .better-interventions {
    min-height: 280px;
    max-height: none;
  }

  .interventions-modal-shell .intervention-chip-grid {
    grid-template-columns: 1fr;
  }

  .interventions-modal-shell .intervention-item-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .interventions-modal-shell .intervention-chip {
    max-width: none;
  }
}

@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .controls,
  .control-group {
    width: 100%;
  }

  .control-group {
    min-width: 0;
  }

  .tabbar,
  .view-tabs,
  .energy-score-submit-row,
  .patient-state-heading {
    width: 100%;
    flex-wrap: wrap;
  }

  .main-layout {
    padding: 12px 0 0;
    gap: 12px;
  }

  #cy {
    min-height: 420px;
  }

  .cell-stage {
    max-width: 100%;
  }

  .cell-hotspot-label {
    max-width: min(160px, calc(100vw - 56px));
    white-space: normal;
    text-align: center;
  }

  .interventions-shell,
  .faq-panel-header .dashboard-search,
  .paper-dashboard-search,
  .dashboard-search {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .interventions-shell {
    max-width: none;
  }

  .energy-score-side {
    width: 100%;
    align-items: stretch;
  }

  .energy-score-side #submitMapStateBtn,
  .energy-score-side #generateReportBtn,
  .energy-score-submit-row .btn-secondary,
  .energy-score-submit-row .btn-primary {
    width: 100%;
  }

  .detail-panel,
  .dashboard-panel,
  .metric-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .dashboard-table th,
  .dashboard-table td {
    padding: 12px;
  }
}

@media (max-width: 560px) {
  .dashboard-shell {
    padding-bottom: 24px;
  }

  .dashboard-hero,
  .dashboard-panel,
  .metric-card,
  .dashboard-modal-card,
  .detail-panel,
  .graph-panel,
  .topbar {
    border-radius: 18px;
  }

  .dashboard-hero,
  .panel-header,
  .node-header,
  .detail-modal-header,
  .dashboard-modal-header {
    gap: 10px;
  }

  .dashboard-actions,
  .dashboard-list-controls,
  .intervention-admin-actions,
  .map-submit-actions,
  .confirm-clear-actions,
  .ask-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-actions > *,
  .dashboard-list-controls > *,
  .intervention-admin-actions > *,
  .map-submit-actions > *,
  .confirm-clear-actions > *,
  .ask-actions > * {
    width: 100%;
  }

  .ask-bar,
  .ask-row {
    flex-direction: column;
  }

  .ask-actions {
    min-width: 0;
  }

  .cell-help,
  .legend {
    gap: 8px;
  }

  .cell-hotspot {
    min-width: 22px;
    min-height: 22px;
  }

  .detail-modal .node-detail {
    padding: 16px;
  }

  .detail-modal-close {
    width: 38px;
    height: 38px;
  }
}
