:root {
  --ink: #1f2523;
  --muted: #65716d;
  --paper: #fbfcfa;
  --surface: #ffffff;
  --line: #dbe2de;
  --soft: #eef3ef;
  --teal: #0f766e;
  --teal-soft: #e0f2ef;
  --major: #c9342e;
  --major-soft: #fee2df;
  --moderate: #c77911;
  --moderate-soft: #fff2cf;
  --minor: #39744d;
  --minor-soft: #e3f3e7;
  --unknown: #77817d;
  --unknown-soft: #ecefed;
  --pathway: #61558e;
  --pathway-soft: #ece9f8;
  --shadow: 0 18px 60px rgba(21, 33, 28, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06), transparent 31%),
    linear-gradient(180deg, #f5f7f2 0%, #eef3ef 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
  min-height: 100vh;
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--line);
}

.brand-block h1,
.status-bar h2,
.panel-title h2,
.section-heading h2,
.source-note h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1 {
  max-width: 280px;
  font-size: clamp(1.85rem, 2.7vw, 2.45rem);
  line-height: 1.03;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.search-form {
  display: grid;
  gap: 10px;
}

.search-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 8px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

input {
  min-height: 44px;
  padding: 0 12px;
}

select {
  min-height: 38px;
  padding: 0 34px 0 12px;
}

input:focus,
select:focus,
button:focus-visible,
.graph-node:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 800;
}

button:hover {
  filter: brightness(0.96);
}

.ghost-button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--soft);
}

.selected-section,
.source-note {
  display: grid;
  gap: 12px;
}

.section-heading,
.panel-title,
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.source-note h2 {
  font-size: 1rem;
}

.selected-meds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
}

.med-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 34px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(31, 37, 35, 0.04);
}

.med-chip.has-caution.major {
  border-color: rgba(201, 52, 46, 0.42);
  background: var(--major-soft);
}

.med-chip.has-caution.moderate {
  border-color: rgba(199, 121, 17, 0.42);
  background: var(--moderate-soft);
}

.med-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  display: grid;
  width: 24px;
  min-height: 24px;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--soft);
  font-size: 0.8rem;
}

.source-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
}

.source-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  padding: 28px;
}

.status-bar,
.graph-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.status-bar {
  padding: 18px 20px;
}

.status-bar h2,
.panel-title h2 {
  font-size: 1.22rem;
}

.risk-badge {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 9px 13px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 900;
}

.risk-badge.major,
.severity-pill.major {
  color: #8a1f1a;
  background: var(--major-soft);
}

.risk-badge.moderate,
.severity-pill.moderate {
  color: #804a00;
  background: var(--moderate-soft);
}

.risk-badge.minor,
.severity-pill.minor {
  color: #245734;
  background: var(--minor-soft);
}

.risk-badge.unknown,
.severity-pill.unknown {
  color: #4c5551;
  background: var(--unknown-soft);
}

.graph-panel {
  display: grid;
  grid-template-rows: auto minmax(330px, 46vh);
  overflow: hidden;
}

.panel-title {
  padding: 18px 20px 10px;
}

.panel-title.compact {
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.major {
  background: var(--major);
}

.legend-dot.moderate {
  background: var(--moderate);
}

.legend-dot.minor {
  background: var(--minor);
}

.legend-dot.unknown {
  background: var(--unknown);
}

.graph-stage {
  position: relative;
  min-height: 330px;
  padding: 4px 16px 18px;
}

#interactionGraph {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.graph-edge {
  stroke-linecap: round;
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.graph-edge-hit {
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
}

.graph-edge.selected {
  stroke-width: 7;
}

.graph-node {
  cursor: pointer;
}

.node-ring {
  fill: #ffffff;
  stroke: #b9c4bf;
  stroke-width: 2;
  filter: drop-shadow(0 10px 18px rgba(31, 37, 35, 0.16));
}

.node-ring.med-caution.major {
  stroke: var(--major);
  stroke-width: 4;
}

.node-ring.med-caution.moderate {
  stroke: var(--moderate);
  stroke-width: 4;
}

.node-core {
  fill: var(--teal-soft);
  stroke: var(--teal);
  stroke-width: 2;
}

.node-label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-anchor: middle;
  pointer-events: none;
}

.node-sub {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

.empty-graph-text {
  fill: var(--muted);
  font-size: 18px;
  font-weight: 750;
  text-anchor: middle;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.3fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.detail-panel {
  min-width: 0;
  overflow: hidden;
}

.watch-panel {
  grid-column: 1 / -1;
}

.interaction-list,
.pathway-list,
.watch-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.interaction-card,
.pathway-card,
.watch-card,
.empty-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.interaction-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
}

.interaction-card.selected {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.interaction-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.interaction-topline h3 {
  margin: 0;
  font-size: 1rem;
}

.severity-pill {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: capitalize;
}

.interaction-card p,
.pathway-card p,
.watch-card p,
.empty-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #4d4868;
  background: var(--pathway-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.pathway-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.pathway-card h3,
.watch-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.pathway-bar {
  display: grid;
  gap: 7px;
}

.pathway-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.pathway-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--pathway));
}

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

.watch-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 132px;
  padding: 14px;
}

.watch-card.caution-card.major {
  border-color: rgba(201, 52, 46, 0.4);
  background: linear-gradient(180deg, #fff7f6, #ffffff);
  box-shadow: inset 4px 0 0 var(--major);
}

.watch-card.caution-card.moderate {
  border-color: rgba(199, 121, 17, 0.4);
  background: linear-gradient(180deg, #fffaf0, #ffffff);
  box-shadow: inset 4px 0 0 var(--moderate);
}

.watch-card strong {
  color: var(--ink);
}

.empty-card {
  padding: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .source-note {
    margin-top: 0;
  }

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

@media (max-width: 720px) {
  .input-panel,
  .workspace {
    padding: 18px;
  }

  .status-bar,
  .section-heading,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .risk-badge {
    min-width: 0;
  }

  .graph-panel {
    grid-template-rows: auto 360px;
  }

  .legend {
    justify-content: flex-start;
  }

  .watch-list {
    grid-template-columns: 1fr;
  }
}
