/* Diabetes and insulin maps share the site's teal palette and controls. */
.dm-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin: 18px 0;
}
.dm-heading > div:first-child {
  flex: 1;
  min-width: 250px;
}
.dm-heading h1 {
  margin: 8px 0;
}
.dm-heading p,
.dm-caption {
  color: var(--muted, #617780);
}
.dm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.dm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  font-size: 0.875rem;
}
.dm-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dm-toolbar output {
  min-width: 44px;
  text-align: center;
}
.dm-viewport {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line, #d8e5e4);
  border-radius: 18px;
  background: #f8fbfa;
  max-height: none;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
}
.dm-space {
  position: relative;
  margin-inline: auto;
  overflow: clip;
}
.dm-canvas {
  position: relative;
  width: 1560px;
  min-height: 100px;
  transform-origin: top left;
}
.dm-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.dm-edges > path {
  fill: none;
  stroke: #83a9a4;
  stroke-width: 1.8;
  marker-end: url(#dm-arrow);
}
.dm-edges marker path {
  fill: #537f79;
}
.dm-edges > path.selected {
  stroke: #086e65;
  stroke-width: 3;
}
.dm-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  height: auto !important;
  max-height: none !important;
  padding: 16px 18px !important;
  border: 1px solid #b9cecb !important;
  border-radius: 12px !important;
  background: #fff !important;
  color: #213d42 !important;
  text-align: center;
  font-family: inherit;
  box-shadow: 0 2px 5px #163e3605;
  white-space: normal !important;
  overflow-wrap: anywhere;
}
.dm-node strong {
  font-size: 1rem;
  line-height: 1.4;
}
.dm-node > span {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #536e74;
}
.dm-node strong,
.dm-node > span,
.dm-node dl {
  flex-shrink: 0;
}
.dm-node i {
  position: absolute;
  right: 7px;
  bottom: 5px;
  font-size: 13px;
  font-style: normal;
  color: #7c9995;
}
.dm-node:hover,
.dm-node.selected {
  background: #edf6f3 !important;
  border-color: #15786e !important;
  box-shadow: 0 0 0 2px #15786e18;
}
.dm-node:focus-visible {
  outline: 3px solid #15786e;
  outline-offset: 3px;
}
.dm-node.goal {
  background: #e1eeea !important;
  border-color: #9bbeb5 !important;
}
.dm-node.warm {
  background: #f1ece5 !important;
  border-color: #c9beae !important;
}
.dm-node.base {
  background: #193f45 !important;
  color: white !important;
}
.dm-node.base > span {
  color: #e3efed;
}
.dm-node.decision {
  border-style: dashed !important;
  background: #f2f7f6 !important;
}
.dm-node dl {
  margin: 0;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  line-height: 1.5;
}
.dm-node dt {
  font-weight: 700;
  border-top: 1px solid #e2eae7;
  padding-top: 9px;
  margin-top: 8px;
}
.dm-node dd {
  margin: 4px 0 0;
  color: #516971;
}
.dm-caption {
  font-size: 0.8125rem;
  line-height: 1.6;
  margin: 15px 0;
}
.dm-dialog {
  max-width: 960px;
}
.dm-dialog dl dt {
  font-weight: 700;
  margin-top: 15px;
}
.dm-dialog dl dd {
  margin: 5px 0 0;
}
.dm-dialog .info {
  margin: 10px 0;
}
.dm-dialog .table-scroll {
  overflow: auto;
}
.dm-dialog table {
  min-width: 680px;
}
.dm-dialog .drug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dm-dialog .drug-table th,
.dm-dialog .drug-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.dm-dialog .drug-table th {
  background: #e1eeea;
}
.dm-dialog .drug-table td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
.dm-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.dm-picker label {
  display: grid;
  gap: 5px;
  flex: 1;
  min-width: 160px;
  font-size: 14px;
}
.dm-picker input,
.dm-picker select {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: inherit;
  width: 100%;
}
.dm-source-note {
  padding: 12px 16px;
  background: #f1f6f6;
  border-left: 3px solid var(--teal);
  font-size: 14px;
  line-height: 1.6;
}
@media (max-width: 700px) {
  .dm-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .dm-heading > div:first-child {
    min-width: 0;
  }
  .dm-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .dm-actions .btn {
    flex: 1;
    min-height: 44px;
  }
  .dm-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .dm-viewport {
    max-height: none;
    border-radius: 12px;
  }
  .dm-heading h1 {
    font-size: 25px;
  }
  .dm-toolbar .btn {
    min-height: 44px;
  }
  .dm-dialog {
    width: calc(100% - 20px);
  }
}

/* Shared top bar: map selectors on the left, clinical actions on the right. */
.dm-workspace {
  display: block;
}
.dm-map-panel {
  min-width: 0;
}
.dm-rail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 12px;
  padding: 12px 0;
}
.dm-map-selector,
.dm-rail .dm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.dm-rail .dm-actions {
  margin-left: auto;
  justify-content: flex-end;
}
.dm-rail .btn {
  min-height: 44px;
  margin: 0;
  white-space: normal;
  line-height: 1.45;
}
.dm-map-selector .btn[aria-pressed='true'] {
  background: #e1eeea;
  color: #145b55;
  border-color: var(--teal, #087e80);
  box-shadow: inset 0 -3px var(--teal, #087e80);
}
.dm-rail .dm-primary {
  background: var(--teal, #087e80);
  border-color: var(--teal, #087e80);
  color: white;
}
.dm-rail .dm-danger {
  background: #b4232c;
  border-color: #b4232c;
  color: white;
}
.dm-rail .dm-danger:hover {
  background: #941c24;
  border-color: #941c24;
}
.dm-rail .dm-danger:active {
  background: #78171d;
  border-color: #78171d;
}
.dm-toolbar {
  justify-content: flex-end;
}
@media (max-width: 700px) {
  .dm-rail {
    gap: 12px;
  }
  .dm-rail .dm-actions {
    width: auto;
    flex: 1 1 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
  .dm-rail .dm-actions .btn {
    flex: 0 1 auto;
  }
  .dm-toolbar {
    align-items: flex-end;
  }
}

.dm-node.danger {
  background: #fff0f0 !important;
  border-color: #d95d64 !important;
  color: #7f1d25 !important;
}
.dm-node.danger > span {
  color: #8f343b;
}
.dm-node.danger:hover,
.dm-node.danger.selected {
  background: #ffe4e5 !important;
  border-color: #b4232c !important;
}
.hta-actions {
  justify-content: flex-end;
  margin-bottom: 0;
}
.hta-actions .dm-actions {
  margin-left: auto;
}
.cm-stage-heading h2 {
  font-size: 1.15rem;
  margin: 12px 0 6px;
}
.cm-stage-heading p {
  margin: 0;
  color: var(--muted);
}
.cm-stage-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.cm-stage-footer .btn:last-child {
  margin-left: auto;
}
.dm-node:has(.dm-node-number) {
  padding: 12px 14px !important;
  gap: 6px;
  text-align: left;
  align-items: stretch;
}
.dm-detail-trigger {
  display: block;
  padding: 0 0 0 40px;
  min-height: 32px;
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dm-number-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 2px 7px;
  border: 1px solid #315b55;
  border-radius: 7px;
  background: #edf6f3;
  color: #214f48;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.dm-number-link:hover {
  background: #315b55;
  color: white;
}
.dm-detail-trigger:focus-visible,
.dm-number-link:focus-visible,
.dm-node-number:focus-visible {
  outline: 3px solid #15786e;
  outline-offset: 3px;
}
.dm-node.dm-active {
  box-shadow:
    0 0 0 3px #15786e,
    0 8px 24px #163e3626;
  border-color: #15786e !important;
}
.dm-node.danger.dm-active {
  box-shadow:
    0 0 0 3px #a32e35,
    0 8px 24px #7f1d2520;
}
.dm-node .dm-node-number {
  position: absolute;
  top: 10px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  margin: 0;
  border-radius: 8px;
  background: #315b55;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border: 0;
  cursor: pointer;
}
.dm-node.danger .dm-node-number {
  background: #a32e35;
  color: #fff !important;
}
.dm-node .dm-branches {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #b6ceca;
  text-align: left;
  width: 100%;
}
.dm-node .dm-branches > span {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.dm-rail > .dm-actions {
  width: 100%;
}
.dm-rail > .dm-actions > [data-cm-open='refer'] {
  margin-left: auto;
}
.dm-node > strong,
.dm-node > span:not(.dm-node-number) {
  width: 100%;
  text-align: left;
}
.dm-node .dm-summary {
  display: grid;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
}
.dm-node .dm-summary > span {
  display: block;
  text-align: left;
}
.clinical-map-dialog .btn,
.clinical-map-dialog .actions a,
.cm-related .btn {
  height: auto;
  min-height: 42px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.cm-edge-label {
  font:
    600 14px system-ui,
    sans-serif;
  fill: #315b55;
  stroke: #f8fbfa;
  stroke-width: 7px;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

/* Non-modal node details keep the map available for selection. */
dialog.dm-context[open] {
  position: fixed;
  inset: auto 20px 20px auto;
  margin: 0;
  width: min(var(--dm-context-width, 440px), calc(100vw - 40px));
  height: auto;
  min-height: 0;
  max-height: 48dvh;
  overflow: auto;
  z-index: 120;
  border: 1px solid var(--border, #c8d9d5);
  border-radius: 16px;
  box-shadow: 0 12px 40px #102a3340;
}
.dm-context header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface, white);
}
.dm-context .flow-body {
  overflow-wrap: anywhere;
}
.dm-viewport {
  scroll-margin-top: 100px;
}
@media (max-width: 700px) {
  dialog.dm-context[open] {
    inset: auto 10px 10px 10px;
    width: auto;
    max-height: 32dvh;
  }
}

.dm-edges > path.dm-incoming {
  stroke: #005c50;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px #ffffff);
}

.dm-viewport {
  cursor: grab;
  touch-action: none;
}
.dm-viewport.dm-dragging,
.dm-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* Persistent, compact map controls; large targets for touch and keyboard. */
.dm-toolbar {
  position: sticky;
  top: 96px;
  z-index: 40;
  width: fit-content;
  max-width: 100%;
  margin: 8px 0 14px auto;
  padding: 6px;
  border: 1px solid var(--line, #d8e5e4);
  border-radius: 14px;
  background: #ffffffed;
  box-shadow: 0 3px 12px #193f4512;
  backdrop-filter: blur(8px);
}
.dm-toolbar > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.dm-toolbar button {
  min-width: 44px;
  min-height: 44px;
}
.dm-toolbar output {
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.dm-viewport:focus-visible {
  outline: 3px solid #15786e;
  outline-offset: 3px;
}
.dm-context header {
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.dm-context header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
}
.dm-context header button {
  flex-shrink: 0;
  min-height: 44px;
}
dialog.dm-context[open] {
  padding: 20px;
}
@media (max-width: 700px) {
  .dm-toolbar {
    top: 84px;
  }
  dialog.dm-context[open] {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .dm-node {
    transition:
      border-color 160ms ease,
      background-color 160ms ease,
      box-shadow 160ms ease;
  }
  dialog.dm-context[open] {
    animation: dm-context-enter 180ms ease-out;
  }
}
@keyframes dm-context-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

main.dm-wide {
  max-width: none;
  padding-inline: clamp(16px, 2vw, 32px);
}
body.dm-fullscreen-open {
  overflow: hidden;
}
main.dm-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100dvh !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 12px 16px 32px !important;
  overflow: auto;
  z-index: 1000;
  background: var(--bg, #f5f8fa);
}
.dm-fullscreen > .back,
.dm-fullscreen .dm-heading,
.dm-fullscreen .dm-rail {
  display: none;
}
.dm-fullscreen .dm-toolbar {
  top: 0;
  margin-top: 0;
}
body.dm-fullscreen-open dialog.dm-context[open] {
  z-index: 1100;
}
.dm-fullscreen .dm-viewport {
  scroll-margin-top: 70px;
}

.dm-scale-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 8px;
  font-size: 0.875rem;
  font-weight: 600;
}
.dm-scale-control input[type='range'] {
  width: clamp(100px, 18vw, 210px);
  min-width: 0;
  min-height: 44px;
  margin: 0;
  accent-color: #15786e;
  cursor: pointer;
}
.dm-scale-control input:focus-visible {
  outline: 2px solid #15786e;
  outline-offset: 2px;
  border-radius: 6px;
}

/* The map is a bounded workspace: scaling never changes the page geometry. */
.dm-frame {
  min-width: 0;
  border: 1px solid var(--line, #d8e5e4);
  border-radius: 16px;
  background: var(--surface, #fff);
  overflow: hidden;
  isolation: isolate;
}
.dm-frame-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line, #d8e5e4);
}
.dm-frame-controls .dm-rail {
  display: flex;
  align-items: center;
  flex: 1 1 420px;
  gap: 8px 16px;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.dm-frame-controls .dm-toolbar {
  position: static;
  flex: 0 1 auto;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  backdrop-filter: none;
  max-width: 100%;
}
.dm-frame-controls .dm-actions,
.dm-frame-controls .dm-map-selector {
  margin: 0;
  justify-content: flex-start;
  width: auto;
  flex: 0 1 auto;
  gap: 8px;
}
.dm-frame-controls .btn {
  min-height: 40px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  padding: 9px 12px;
}
.dm-frame-controls .dm-rail .btn {
  color: var(--ink, #243943);
  background: var(--surface, #fff);
  border: 1px solid var(--line, #d8e5e4);
  box-shadow: none;
}
.dm-frame-controls .dm-rail .dm-primary,
.dm-frame-controls .dm-rail .dm-danger {
  border-left: 3px solid #65a39b;
}
.dm-frame-controls .dm-rail .dm-danger {
  border-left-color: #c9787f;
}
.dm-frame-controls .dm-rail .btn:hover {
  background: #f1f6f6;
  border-color: #a6bdbd;
}
.dm-frame-controls .dm-map-selector .btn[aria-pressed='true'] {
  background: #f4f8f7;
  border-color: #92b7b2;
  box-shadow: inset 0 -2px #438a81;
}
.dm-frame .dm-viewport {
  height: var(--dm-natural-height, 1210px);
  max-height: none;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  overflow-anchor: none;
  background: #f8fbfa;
  contain: layout paint;
}
.dm-frame .dm-space {
  margin-inline: auto;
}
.dm-frame .dm-scale-control {
  padding: 0;
  gap: 8px;
}
.dm-frame .dm-scale-control input[type='range'] {
  width: clamp(100px, 13vw, 180px);
}
.dm-frame-controls .dm-toolbar output {
  min-width: 44px;
}
.dm-fullscreen .dm-frame {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 44px);
}
.dm-fullscreen .dm-frame .dm-viewport {
  flex: 1;
  height: auto;
  min-height: 0;
}
.dm-fullscreen .dm-frame .dm-rail {
  display: flex;
}
.dm-fullscreen .context-links,
.dm-fullscreen .dm-caption,
.dm-fullscreen .cm-stage-heading,
.dm-fullscreen .cm-stage-footer {
  display: none;
}
@media (max-width: 700px) {
  .dm-frame-controls {
    padding: 10px;
    gap: 10px;
  }
  .dm-frame-controls .dm-rail {
    flex-basis: 100%;
  }
  .dm-frame-controls .dm-toolbar {
    flex-basis: 100%;
  }
  .dm-frame-controls .dm-toolbar > div {
    width: 100%;
    gap: 6px;
  }
  .dm-frame-controls .dm-scale-control {
    flex: 1 1 150px;
    min-width: 0;
  }
  .dm-frame .dm-scale-control input[type='range'] {
    flex: 1;
    width: 100px;
  }
  .dm-frame-controls .btn {
    min-height: 44px;
  }
  .dm-frame .dm-viewport {
    height: var(--dm-natural-height, 1210px);
    min-height: 320px;
  }
}
/* Place map tabs on their own row; actions and scale share the next baseline. */
.dm-frame-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}
.dm-frame-controls .dm-rail {
  display: contents;
}
.dm-frame-controls .dm-map-selector {
  grid-column: 1 / -1;
}
.dm-frame-controls .dm-actions {
  grid-column: 1;
  align-self: center;
}
.dm-frame-controls .dm-toolbar {
  grid-column: 2;
  align-self: center;
}
.dm-frame-controls .cm-related {
  grid-column: 1 / -1;
}
.dm-frame .dm-scale-control input[type='range'] {
  width: 120px;
}
.dm-fullscreen .dm-frame .dm-rail {
  display: contents;
}
@media (max-width: 1100px) {
  .dm-frame-controls {
    grid-template-columns: minmax(0, 1fr);
  }
  .dm-frame-controls .dm-toolbar {
    grid-column: 1;
    justify-self: end;
  }
}
.dm-fullscreen .history-navigation {
  display: none;
}
