.tip a {
  color: var(--primary);
  font-weight: 950;
  text-decoration: underline;
}

.node-editor {
  position: fixed;
  z-index: 50;
  width: 300px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 12px;
}

.node-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.node-editor-head b {
  font-size: 12px;
  color: #2e4038;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-editor-body {
  display: grid;
  gap: 8px;
}

.node-editor-body label {
  display: grid;
  gap: 4px;
  color: #54635d;
  font-size: 8px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.node-editor-body input,
.node-editor-body select {
  height: 36px;
  border: 1px solid #cbd8d1;
  border-radius: 9px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 0 9px;
  font-size: 11px;
  font-weight: 750;
}

.node-editor-actions {
  margin-top: 2px;
}

.node-editor-actions .delete-row {
  width: auto;
  height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 950;
}

.item-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.mini-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #eef2f0;
  color: #4a5b53;
}

.mini-toggle svg { width: 14px; height: 14px; }

.filter-field {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 10px 0;
  padding: 0 11px;
  height: 38px;
  border: 1px solid #dbe6e0;
  border-radius: 10px;
  background: #fbfdfc;
  color: #7c8a83;
}

.filter-field svg { width: 14px; height: 14px; flex: 0 0 auto; }

.filter-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  padding: 0;
}

.filter-field input:focus-visible { outline: none; }

.row-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.row-head b {
  font-size: 11px;
  color: #2e4038;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-toggle {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f3f7f5;
  color: #4a5b53;
}

.row-toggle svg { width: 13px; height: 13px; }

.drag-handle {
  flex: 0 0 auto;
  width: 18px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9aa9a1;
  cursor: grab;
  touch-action: none;
}

.drag-handle svg { width: 13px; height: 13px; }
.drag-handle:active { cursor: grabbing; }

.item-row.dragging-row, .item-row-compact.dragging-row { opacity: .35; }

.item-row.drop-before, .item-row-compact.drop-before { box-shadow: inset 0 3px 0 var(--primary); }
.item-row.drop-after, .item-row-compact.drop-after { box-shadow: inset 0 -3px 0 var(--primary); }

.item-row-compact {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid #e2eae6;
  border-radius: 11px;
  background: #ffffff;
}

.item-row-compact .delete-row {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
}

.row-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 950;
  color: #fff;
}

.row-avatar-square { border-radius: 7px; }

.row-avatar-0 { background: #1f7a55; }
.row-avatar-1 { background: #2f5f8f; }
.row-avatar-2 { background: #b99145; }
.row-avatar-3 { background: #8758a5; }
.row-avatar-4 { background: #b85159; }
.row-avatar-5 { background: #2f8f8a; }

.row-avatar-crime { background: #b85159; }
.row-avatar-faccao { background: #8758a5; }
.row-avatar-territorio { background: #2f8f8a; }
.row-avatar-outro { background: #66736d; }

.row-avatar svg { width: 13px; height: 13px; }

.row-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.row-title b {
  font-size: 11px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-title small {
  font-size: 9px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-row, .categoria-row, .vinculo-row {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  align-items: end;
}

.person-row .wide, .categoria-row .wide, .vinculo-row .wide {
  grid-column: span 2;
}

.person-row input[type="file"] {
  height: 36px;
  padding: 7px 8px;
  font-size: 10px;
}

.foto-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 9px;
  background: #fff7e6;
  color: #8a6414;
  font-size: 10px;
  font-weight: 800;
}

.foto-status.has-photo {
  background: var(--primary-tint);
  color: #1d3f72;
}

.person-node { cursor: grab; touch-action: none; }
.person-node.dragging { cursor: grabbing; opacity: .92; }
.person-node text { user-select: none; pointer-events: none; }

.person-photo-ring {
  fill: none;
  stroke-width: 3;
}

.person-avatar-text {
  font-size: 20px;
  font-weight: 950;
  fill: #ffffff;
  text-anchor: middle;
  dominant-baseline: central;
}

.person-name {
  font-size: 13px;
  font-weight: 900;
  fill: #17251f;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.person-tag {
  font-size: 9px;
  font-weight: 800;
  fill: #5c6d66;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.categoria-node rect {
  filter: drop-shadow(0 5px 11px rgba(17, 40, 31, .1));
}

.categoria-label {
  font-size: 12px;
  font-weight: 900;
  fill: #241a2c;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.categoria-tag {
  font-size: 9px;
  font-weight: 800;
  fill: #5c6d66;
  text-anchor: middle;
}

.link-line {
  stroke: #9cafb6;
  stroke-width: 2;
  fill: none;
}

.link-line.tenso { stroke: var(--rose); stroke-dasharray: 5 5; }

.link-label {
  font-size: 9px;
  font-weight: 900;
  fill: #4a5a54;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 4px;
  stroke-linejoin: round;
  text-anchor: middle;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f3f7f5;
  color: #52635b;
  font-size: 9px;
  font-weight: 800;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot-preso { background: #2f5f8f; }
.legend-dot-foragido { background: #b85159; }
.legend-dot-monitorado { background: #b99145; }
.legend-dot-liberdade { background: #1f7a55; }
.legend-dot-outro { background: #66736d; }

.legend-dot-square { border-radius: 4px; }
.legend-dot-crime { background: #b85159; }
.legend-dot-faccao { background: #8758a5; }
.legend-dot-territorio { background: #2f8f8a; }

.tip.flush { margin-top: 0; }

#node-radius, #png-dpi {
  width: 48px !important;
}

#page-orientation-field.is-disabled {
  opacity: .45;
  pointer-events: none;
}

@media (max-width: 720px) {
  .person-row, .categoria-row, .vinculo-row { grid-template-columns: 1fr; }
}

@page {
  size: landscape;
  margin: 12mm;
}

@media print {
  .topbar, .editor, .actions, .code-box, .preview-head, .toast, .tip, .guide-box {
    display: none !important;
  }
  .workspace { display: block; padding: 0; width: 100%; }
  .preview-panel { border: 0; box-shadow: none; padding: 0; }
  .canvas-wrap { border: 0; min-height: 0; overflow: visible; background: none; }
  #chart-preview { min-width: 0; padding: 0; }
  .org-svg { max-width: 100%; }
}
