body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 2vh 2vw;
    background-color: #f5f5f5;
}

/* 팝업 스타일 */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.4rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: scale(1.1);
}

.popup-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.location-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.location-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.edit-section {
    margin-bottom: 20px;
}

.edit-section h4 {
    margin-bottom: 15px;
}

#locationCheckboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}


.popup-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #5a65d8;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* 나만의 편집 팝업 스타일 */
.custom-edit-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.custom-edit-section h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1rem;
}

.section-desc {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.location-list,
.sensor-type-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 5px;
}

.location-list label,
.sensor-type-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.location-list label:hover,
.sensor-type-list label:hover {
    background: #e8f0fe;
}

.location-list input[type="checkbox"],
.sensor-type-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Location Selector Modal Styles */
.location-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-modal-content {
    background-color: #fff;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.location-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.location-modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-modal:hover {
    transform: scale(1.1);
}

.location-search-container {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

#locationSearchInput {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.3s;
}

#locationSearchInput:focus {
    border-color: #667eea;
}

.location-grid {
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.location-card {
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.location-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.location-card.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.location-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
}

.location-card .sensor-count {
    font-size: 0.9em;
    opacity: 0.8;
}

.location-card.hidden {
    display: none;
}

/* 편집 모드 스타일 */
.edit-controls {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid #e0e0e0;
}

.selected-locations {
    margin-bottom: 15px;
}

.selected-locations h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1em;
}

#selectedLocationsList {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 40px;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.selected-location-tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.selected-location-tag .remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: 5px;
}

.edit-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

.btn-small {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
}

.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}


.location-card.multi-selected {
    background: #e8f0fe;
    border-color: #4285f4;
}

/* 저장된 조합 모달 */
#savedViewsModal {
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
}

.saved-views-content {
    background: white;
    border-radius: 10px;
    padding: 20px;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
}

.saved-view-item {
    background: #f8f9fa;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.saved-view-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.saved-view-item h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.saved-view-item .locations {
    color: #666;
    font-size: 0.9em;
}

.saved-view-item .date {
    color: #999;
    font-size: 0.8em;
    margin-top: 5px;
}

.container {
    max-width: 95vw;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 0 1vw;
}

.header {
    background: linear-gradient(135deg, #2E3F6B 0%, #3B4B7C 50%, #4A5B8D 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 120px;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 1200px 300px at 50% 100%, rgba(74, 91, 141, 0.3) 0%, transparent 70%),
        linear-gradient(180deg, rgba(46, 63, 107, 0.1) 0%, rgba(74, 91, 141, 0.05) 100%);
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

.header-content h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-subtitle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.version {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.location-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.location-label {
    font-size: 16px;
    color: white;
    font-weight: 500;
}

.location-dropdown {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    min-width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.location-dropdown:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.location-dropdown option {
    background: #2E3F6B;
    color: white;
    padding: 8px;
}

.custom-edit-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    backdrop-filter: blur(10px);
    margin-left: 12px;
}

.custom-edit-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 하단 저작권 정보 */
.footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e9ecef;
    margin-top: 40px;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.copyright {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 5px;
}

.data-source {
    font-size: 13px;
    color: #adb5bd;
}

.header p {
    margin: 1vh 0 0 0;
    opacity: 0.9;
    font-size: clamp(0.9em, 2.5vw, 1.1em);
}

.content {
    padding: 3vh 2vw;
}

.controls {
    margin-bottom: 3vh;
    text-align: center;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1vh 2vw;
    margin: 0 1vw;
    border-radius: 25px;
    cursor: pointer;
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.treemap-container {
    position: relative;
    margin: 2vh auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    
    /* 데스크톱 기본 설정 */
    width: 55vw;
    height: 70vh;
    
    /* 최대 크기 제한 */
    max-width: 1200px;
    max-height: 800px;
    
    /* 최소 크기 */
    min-width: 300px;
    min-height: 200px;
}

.stage-label {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5vh 1vw;
    border-radius: 4px;
    font-size: clamp(10px, 1.5vw, 12px);
    font-weight: 500; /* bold에서 500으로 변경 */
    z-index: 10;
}

.stage-1-label {
    top: 1vh;
    right: 1vw;
    background: #87CEEB;
    color: #000000;
}

.stage-2-label {
    top: 1vh;
    left: 1vw;
    background: #FFB366;
    color: #000000;
}

.stage-3-label {
    bottom: 1vh;
    left: 1vw;
    background: #D3D3D3;
    color: #000000;
}

.node {
    stroke: #fff;
    stroke-width: 2px;
    transition: all 0.3s ease;
}

.node:hover {
    stroke-width: 3px;
    stroke: #333;
    z-index: 100;
}

.node:hover .node-text {
    font-size: 120% !important;
    opacity: 1 !important;
}

.node:hover rect {
    filter: brightness(1.1);
}

/* .node-text 스타일 주석 처리 - JavaScript의 인라인 스타일 사용
.node-text {
    font-family: 'Arial', sans-serif;
    font-weight: 500;
    fill: #000000 !important;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
} */

/* .node-name 스타일 주석 처리 - JavaScript의 인라인 스타일 사용
.node-name {
    font-size: clamp(8px, 1.2vw, 12px);
    fill: #000000 !important;
    font-weight: 600;
    letter-spacing: 0.3px;
} */

/* .node-value 스타일 주석 처리 - JavaScript의 인라인 스타일 사용
.node-value {
    font-size: clamp(6px, 1vw, 10px);
    fill: #000000 !important;
    font-weight: 500;
    opacity: 0.9;
} */

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1vh 1vw;
    border-radius: 6px;
    font-size: clamp(10px, 1.5vw, 12px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

.legend {
    margin-top: 2vh;
    text-align: center;
}

.legend-item {
    display: inline-block;
    margin: 0 1.5vw;
    font-size: clamp(10px, 1.5vw, 12px);
    color: #666;
}

.legend-color {
    display: inline-block;
    width: clamp(15px, 2vw, 20px);
    height: clamp(15px, 2vw, 20px);
    margin-right: 0.5vw;
    border-radius: 3px;
    vertical-align: middle;
}

.stats {
    background: #f8f9fa;
    padding: 2vh 2vw;
    border-radius: 8px;
    margin-top: 2vh;
}

.stats h3 {
    margin: 0 0 1.5vh 0;
    color: #333;
    font-size: clamp(1em, 2.5vw, 1.2em);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5vh 1.5vw;
}

.stat-item {
    background: white;
    padding: 1.5vh 1.5vw;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: clamp(10px, 1.5vw, 12px);
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: clamp(18px, 3vw, 24px);
    font-weight: bold;
    color: #333;
    margin-top: 0.5vh;
}

.stage-info {
    background: #e8f4fd;
    padding: 1.5vh 1.5vw;
    border-radius: 8px;
    margin-top: 2vh;
}

.stage-info h4 {
    margin: 0 0 1vh 0;
    color: #333;
    font-size: clamp(0.9em, 2vw, 1em);
}

.stage-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1vh 1vw;
    font-size: clamp(10px, 1.5vw, 12px);
}

.stage-detail {
    background: white;
    padding: 0.8vh 0.8vw;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.stage-detail.stage-2 {
    border-left-color: #e67e22;
}

.stage-detail.stage-3 {
    border-left-color: #95a5a6;
}

.stage-details-section {
    margin-top: 2vh;
    padding: 2vh 2vw;
    background: #f0f7ff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stage-details-section h3 {
    margin-bottom: 1.5vh;
    color: #333;
    font-size: clamp(1em, 2.5vw, 1.1em);
}

.stage-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5vh 1.5vw;
}

.stage-detail-card {
    background: white;
    padding: 1.5vh 1.5vw;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stage-detail-card h4 {
    margin: 0 0 1vh 0;
    color: #333;
    font-size: clamp(0.9em, 2vw, 1em);
}

.stage-items {
    font-size: clamp(0.8em, 1.8vw, 0.9em);
    color: #555;
    line-height: 1.5;
}

.stage-items .no-items {
    color: #999;
    font-style: italic;
}

.item-tag {
    display: inline-block;
    background: #e8f4fd;
    color: #333;
    padding: 0.4vh 0.8vw;
    margin: 0.2vh 0.2vw;
    border-radius: 12px;
    font-size: clamp(0.75em, 1.5vw, 0.85em);
    font-weight: 500;
    border: 1px solid #d1e7dd;
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
    .treemap-container {
        width: 90vw;
        height: 50vh;  /* 모바일에서 높이 제한 */
        max-height: 400px;
    }
    
    .header h1 {
        font-size: 1.5em;
    }
    
    .controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn {
        font-size: 12px;
        padding: 8px 12px;
        margin: 4px;
    }
    
    .legend {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .legend-item {
        margin: 0;
        font-size: 11px;
    }
    
    /* 모바일에서 텍스트 크기 조정 */
    .node-name {
        font-size: clamp(9px, 2.5vw, 11px);
    }
    
    .node-value {
        font-size: clamp(7px, 2vw, 9px);
    }
    
    .stage-label {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* 태블릿 반응형 */
@media (min-width: 769px) and (max-width: 1024px) {
    .treemap-container {
        width: 70vw;
        height: 60vh;
        max-height: 600px;
    }
}

/* 가로 모드 모바일 */
@media (max-width: 768px) and (orientation: landscape) {
    .treemap-container {
        width: 70vw;
        height: 70vh;
        max-height: 500px;
    }
}

.stage-detail-card:nth-child(1) .item-tag {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.stage-detail-card:nth-child(2) .item-tag {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.stage-detail-card:nth-child(3) .item-tag {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

/* 위치 검색 스타일 */
.location-search-popup {
    width: 500px;
    max-width: 90vw;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px 45px 12px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.search-input:focus {
    border-color: #3498db;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

.location-results {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

.location-item {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.location-item:last-child {
    border-bottom: none;
}

.location-item:hover {
    background: #f8f9fa;
    transform: translateX(4px);
}

.location-item:active {
    background: #e9ecef;
    transform: translateX(2px);
}

.location-name {
    font-size: 16px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 4px;
}

.location-desc {
    font-size: 14px;
    color: #6c757d;
}

.selected-location {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
    color: #6c757d;
}

.current-location-badge {
    margin-left: 8px;
    padding: 4px 12px;
    background: #3498db;
    color: white;
    border-radius: 20px;
    font-weight: 500;
}

/* 스크롤바 스타일 */
.location-results::-webkit-scrollbar {
    width: 8px;
}

.location-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.location-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.location-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 검색 결과 하이라이트 */
.location-item.highlighted {
    background: #e3f2fd;
}

.location-item.hidden {
    display: none;
} 