/* 지분 연결도: 기존 대시보드의 공용 테마 색을 그대로 사용한다. */
body.ownership-modal-open { overflow: hidden; }

.ownership-dialog {
  width: min(1220px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}
.ownership-dialog[open] { display: flex; flex-direction: column; }
.ownership-dialog [hidden] { display: none !important; }
.ownership-dialog::backdrop { background: rgba(6, 12, 24, 0.66); }
.ownership-dialog button,
.ownership-dialog select { font: inherit; }
.ownership-dialog button { cursor: pointer; }
.ownership-dialog button:focus-visible,
.ownership-dialog select:focus-visible,
.ownership-dialog summary:focus-visible,
.ownership-viewport:focus-visible,
.ownership-open:focus-visible,
.ownership-mini-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.ownership-dialog button:disabled { opacity: 0.4; cursor: default; }

.ownership-header {
  position: relative;
  flex: none;
  padding: 23px 64px 18px 24px;
  border-bottom: 1px solid var(--border);
}
.ownership-kicker {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.ownership-header h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: -0.5px;
}
.ownership-header p {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.ownership-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 22px !important;
  line-height: 1;
}
.ownership-close:hover { border-color: var(--accent); color: var(--text); }

.ownership-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}
.ownership-stock-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 12px;
}
.ownership-stock-control > span { flex: none; }
.ownership-stock-control select {
  width: 230px;
  max-width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.ownership-zoom-controls { display: flex; align-items: center; gap: 5px; }
.ownership-zoom-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
}
.ownership-zoom-controls button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface2);
}
.ownership-zoom-controls output {
  min-width: 43px;
  margin-left: 3px;
  color: var(--text-dim);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ownership-toolbar svg,
.ownership-open svg,
.ownership-mini-link svg {
  display: inline-block;
  width: 15px;
  height: 15px;
  flex: none;
  vertical-align: middle;
}

.ownership-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  flex: 1 1 auto;
  min-height: min(340px, 45vh);
  height: 55vh;
  max-height: 650px;
  overflow: hidden;
}
.ownership-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background-color: var(--surface2);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 20px 20px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ownership-viewport:focus-visible { outline-offset: -4px; }
.ownership-canvas { position: relative; overflow: hidden; margin-inline: auto; }
.ownership-stage { position: relative; transform-origin: top left; }
.ownership-edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.ownership-edge,
.ownership-edge path {
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 1.5;
  opacity: 0.65;
}
.ownership-edge.is-focus,
.ownership-edge.is-focus path { stroke: var(--accent); stroke-width: 2; opacity: 1; }
.ownership-stage.has-exposure .ownership-edge:not(.is-path) { opacity: 0.2; }
.ownership-stage.has-exposure .ownership-node:not(.is-path) { background: var(--surface2); box-shadow: none; }
.ownership-edge.is-path,
.ownership-edge.is-path path { stroke: var(--accent); stroke-width: 2.5; opacity: 1; }
.ownership-edges marker path { fill: var(--text-dim); stroke: none; }
.ownership-edge-label,
.ownership-edge-label text {
  fill: var(--text-dim);
  stroke: var(--surface2);
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
}
.ownership-edge.is-focus .ownership-edge-label,
.ownership-edge.is-path .ownership-edge-label,
.ownership-edge-label.is-focus { fill: var(--accent); }
.ownership-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  width: 188px;
  height: 100px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.035);
}
.ownership-node:hover { border-color: var(--accent); }
.ownership-node.is-base { border-color: var(--accent); border-style: dashed; }
.ownership-node.is-path { border-color: var(--accent); background: var(--surface); }
.ownership-node.is-focus {
  border: 2px solid var(--accent);
  padding: 9px 13px;
  box-shadow: 0 0 0 4px var(--overview-card-active-bg);
}
.ownership-node-role {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.2;
}
.ownership-base-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
}
.ownership-base-dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.ownership-node.is-focus .ownership-node-role { color: var(--accent); }
.ownership-node-name {
  max-width: 100%;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ownership-node-code {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.ownership-node-bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-width: 0;
}
.ownership-node-bottom .ownership-node-code { flex: none; }
.ownership-node-cap {
  min-width: 0;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ownership-node.is-focus .ownership-node-cap { color: var(--accent); }

.ownership-inspector {
  min-width: 0;
  padding: 20px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ownership-target-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--text-dim);
  font-size: 11px;
}
.ownership-target-control select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 28px 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.ownership-focus-name { font-size: 18px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.ownership-focus-code { margin-top: 3px; color: var(--text-dim); font-size: 11px; }
.ownership-metrics {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ownership-metric-label,
.ownership-metrics > span { color: var(--text-dim); font-size: 11px; }
.ownership-metric-value,
.ownership-metrics > strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}
.ownership-metric-meta,
.ownership-metrics > small {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.ownership-inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ownership-inspector-actions .ownership-detail-link { margin-top: 0; }
.ownership-detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 12px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--accent);
  font-size: 12px !important;
  font-weight: 600 !important;
}
.ownership-detail-link:hover { border-color: var(--accent); }
.ownership-exposure {
  padding: 14px;
  border: 1px solid var(--today-border);
  border-radius: 12px;
  background: var(--overview-card-active-bg);
}
.ownership-exposure-kicker {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.ownership-exposure-value {
  margin-top: 6px;
  color: var(--accent);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.ownership-exposure-split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
.ownership-exposure-note { margin-top: 8px; color: var(--text-dim); font-size: 11px; line-height: 1.65; }
.ownership-calculation,
.ownership-data-details {
  min-width: 0;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.65;
}
.ownership-calculation summary,
.ownership-data-details summary {
  width: fit-content;
  max-width: 100%;
  padding: 4px 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.ownership-calculation[open] summary,
.ownership-data-details[open] summary { margin-bottom: 7px; }
.ownership-path-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding-left: 19px; }
.ownership-path-list li { min-width: 0; padding-left: 2px; }
.ownership-path-title { color: var(--text); font-size: 11px; font-weight: 600; line-height: 1.65; overflow-wrap: anywhere; }
.ownership-path-formula { margin-top: 3px; color: var(--accent); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ownership-data-details > p,
.ownership-data-details > div,
.ownership-data-details > ul { margin-top: 7px; overflow-wrap: anywhere; }
.ownership-data-details > ul { padding-left: 16px; }
.ownership-data-details a { color: var(--accent); text-underline-offset: 2px; }
.ownership-connections { margin-top: 18px; }
.ownership-connections > summary {
  padding: 5px 0;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  cursor: pointer;
}
.ownership-connections > summary span {
  margin-left: 5px;
  color: var(--accent);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.ownership-connections[open] > summary { margin-bottom: 6px; }
.ownership-inspector section { margin-top: 22px; }
.ownership-inspector section h3 {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.ownership-relations { display: flex; flex-direction: column; gap: 6px; list-style: none; }
.ownership-relations li { min-width: 0; }
.ownership-relation {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.ownership-relation:hover { border-color: var(--accent); background: var(--surface2); }
.ownership-relation-name { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.ownership-relation-name > strong { flex: none; color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ownership-relation-meta { color: var(--text-dim); font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.ownership-empty { padding: 9px 0; color: var(--text-dim); font-size: 12px; line-height: 1.65; }
.ownership-status { padding: 32px 24px; color: var(--text-dim); font-size: 13px; }
.ownership-status[hidden] { display: none; }
.ownership-footnote {
  flex: none;
  padding: 11px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.ownership-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  gap: 6px;
  min-height: 32px;
  margin-top: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
}
.ownership-open:hover { border-color: var(--accent); background: var(--surface2); }
.card .ownership-open { margin-top: auto; margin-bottom: 0; }
.card .amounts + .ownership-open,
.card .prices + .ownership-open { margin-top: 14px; }
.ownership-mini-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 25px;
  min-height: 25px;
  margin-left: 4px;
  padding: 3px 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  line-height: 1.3;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
}
.ownership-mini-link:hover { background: var(--surface2); }
.price-label { position: relative; padding-right: 28px; line-height: 28px; }
.price-label .ownership-mini-link {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}
.ownership-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ownership-heading h2 { flex: 1; min-width: 0; }
.ownership-heading .ownership-open { flex: none; margin: 0 20px 0 0; }

@media (max-width: 768px) {
  .ownership-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 15px;
  }
  .ownership-header { padding: 17px 54px 14px 16px; }
  .ownership-header h2 { font-size: 20px; }
  .ownership-header p { font-size: 11px; }
  .ownership-close { top: 12px; right: 10px; width: 36px; height: 36px; }
  .ownership-toolbar { align-items: stretch; gap: 9px; padding: 10px 16px; }
  .ownership-stock-control { flex: 1 1 100%; gap: 8px; }
  .ownership-stock-control select { flex: 1; width: auto; }
  .ownership-zoom-controls { justify-content: flex-end; width: 100%; }
  .ownership-zoom-controls button { min-width: 36px; min-height: 36px; }
  .ownership-body {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .ownership-viewport { flex: none; height: 47vh; height: 47dvh; min-height: 300px; max-height: 460px; }
  .ownership-inspector { flex: none; padding: 16px; border-top: 1px solid var(--border); border-left: 0; overflow: visible; }
  .ownership-inspector section { margin-top: 16px; }
  .ownership-relations { display: grid; grid-template-columns: 1fr; }
  .ownership-descendants .ownership-relations { grid-template-columns: 1fr; }
  .ownership-exposure { padding: 13px; }
  .ownership-exposure-value { font-size: 25px; }
  .ownership-metrics { margin-top: 12px; }
  .ownership-footnote { padding: 10px 16px; font-size: 10px; }
  .ownership-heading { flex-wrap: wrap; gap: 0; }
  .ownership-heading .ownership-open { margin: 8px 16px 10px; }
  .ownership-mini-link { min-width: 28px; min-height: 28px; }
}

@media (max-height: 560px) and (min-width: 769px) {
  .ownership-header { padding-top: 14px; padding-bottom: 12px; }
  .ownership-toolbar { padding-top: 8px; padding-bottom: 8px; }
  .ownership-body { min-height: 180px; }
  .ownership-footnote { padding-top: 8px; padding-bottom: 8px; }
}
