* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: aliceblue;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
}

#network {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

#title {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    background: rgba(240, 248, 255, 0.9);
    padding: 6px 16px;
    border-radius: 6px;
    border: 1px solid #ccc;
    white-space: nowrap;
}

#legend {
    position: absolute;
    top: 55px;
    left: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
    min-width: 170px;
}

.legend-title {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 14px;
    color: #333;
}

.legend-section-title {
    font-weight: bold;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    margin-bottom: 2px;
}

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

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.legend-edge {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.legend-line {
    width: 20px;
    height: 3px;
    display: inline-block;
    flex-shrink: 0;
    border-radius: 2px;
}

.legend-line.dashed {
    background: repeating-linear-gradient(
        90deg,
        #1565C0 0px,
        #1565C0 4px,
        transparent 4px,
        transparent 8px
    );
}

.legend-instructions {
    margin-top: 8px;
    font-size: 11px;
    color: #666;
    border-top: 1px solid #ddd;
    padding-top: 6px;
    line-height: 1.4;
}

.loop-btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.loop-btn:hover {
    background: #eef;
}

.loop-btn.active {
    background: #3F51B5;
    color: #fff;
    border-color: #3F51B5;
}

#right-panel {
    position: absolute;
    top: 55px;
    right: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 12px 16px;
    width: 260px;
    font-size: 13px;
    line-height: 1.5;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

#panel-title {
    font-weight: bold;
    font-size: 15px;
    color: #333;
    margin-bottom: 6px;
}

#panel-body {
    color: #555;
}

#panel-body .loop-path {
    margin-top: 8px;
    padding-left: 0;
    list-style: none;
}

#panel-body .loop-path li {
    padding: 3px 0;
    border-bottom: 1px solid #eee;
    font-size: 12px;
}

#panel-body .loop-path li:last-child {
    border-bottom: none;
}

.loop-arrow {
    font-weight: bold;
    margin: 0 4px;
}

.loop-arrow.positive {
    color: #FF7043;
}

.loop-arrow.negative {
    color: #1565C0;
}

.loop-type-label {
    display: inline-block;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    margin-bottom: 4px;
}

.loop-type-label.reinforcing {
    background: rgba(255, 112, 67, 0.15);
    color: #E64A19;
}

.loop-type-label.balancing {
    background: rgba(21, 101, 192, 0.15);
    color: #1565C0;
}
