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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --border-color: #bdc3c7;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    
    /* 업종별 색상 */
    --color-securities: #FF6B6B;
    --color-card: #4ECDC4;
    --color-life-insurance: #95E1D3;
    --color-fire-insurance: #F38181;
    --color-bank: #AA96DA;
    --color-savings-bank: #FCBAD3;
    --color-capital: #FFFFD2;
    --color-mutual-finance: #A8D8EA;
    --color-fintech: #FFD93D;
    
    --overlap-color: #6C5CE7;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
}

.main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* 좌측 토글 패널 */
.toggle-panel {
    background: var(--card-background);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 280px;
    flex-shrink: 0;
}

.toggle-panel h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.toggle-item:hover {
    background-color: #f8f9fa;
}

.toggle-item.active {
    background-color: #e8f5e9;
}

/* 토글 스위치 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.label-text {
    font-size: 1.1em;
    font-weight: 500;
    flex-grow: 1;
}

.color-indicator {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

/* 액션 버튼 */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.btn-action {
    flex: 1;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

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

/* 범례 */
.legend {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.legend h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.legend p {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.legend-box {
    width: 30px;
    height: 20px;
    border: 1px solid #ddd;
    border-radius: 3px;
    display: inline-block;
}

.legend-box.active {
    background-color: #667eea;
}

.legend-box.overlap {
    background: linear-gradient(45deg, #FF6B6B 25%, #4ECDC4 25%, #4ECDC4 50%, #FF6B6B 50%, #FF6B6B 75%, #4ECDC4 75%);
    background-size: 10px 10px;
}

/* 우측 그리드 영역 */
.grid-container {
    flex-grow: 1;
    background: var(--card-background);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.grid-container h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.grid-wrapper {
    position: relative;
    overflow-x: auto;
}

.y-axis-label {
    position: absolute;
    left: -15px;
    top: 50%;
    transform: rotate(-90deg) translateY(-50%);
    transform-origin: left center;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.95em;
    white-space: nowrap;
}

.x-axis-label {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 15px;
    font-size: 0.95em;
}

/* 도메인 그리드 테이블 */
.domain-grid {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.9em;
}

.domain-grid th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #5a67d8;
    white-space: nowrap;
    font-size: 0.9em;
}

.domain-grid th.corner-cell {
    background: #2d3748;
}

/* 그룹 헤더 행 */
.domain-grid .group-header-row {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.domain-grid .group-header-cell {
    color: white;
    font-weight: 700;
    font-size: 1em;
    padding: 10px 15px;
    text-align: left;
    border: 2px solid #d63384;
    letter-spacing: 0.5px;
}

.domain-grid td {
    padding: 20px 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-width: 80px;
}

.domain-grid tbody tr td:first-child {
    font-weight: 600;
    background: #f7fafc;
    text-align: left;
    padding-left: 15px;
    white-space: nowrap;
}

.domain-grid td.active {
    font-weight: 600;
    border: 2px solid #2d3748;
}

.domain-grid td:not(:first-child):hover {
    background-color: #f0f4f8;
    transform: scale(1.02);
}

/* 셀 활성화 상태 */
.domain-grid td.cell-active {
    opacity: 0.85;
}

.domain-grid td.cell-overlap {
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(0, 0, 0, 0.1) 5px,
        rgba(0, 0, 0, 0.1) 10px
    );
    border: 2px solid #2c3e50;
}

/* 통계 패널 */
.stats-panel {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 10px;
    color: white;
}

.stats-panel h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
}

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

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.stat-label {
    display: block;
    font-size: 0.9em;
    margin-bottom: 8px;
    opacity: 0.95;
}

.stat-value {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
}

/* 반응형 디자인 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .toggle-panel {
        width: 100%;
        min-width: auto;
    }
    
    .y-axis-label {
        display: none;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 0.95em;
    }
    
    .domain-grid {
        font-size: 0.75em;
    }
    
    .domain-grid th,
    .domain-grid td {
        padding: 8px 4px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 애니메이션 */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.domain-grid td.cell-active {
    animation: pulse 0.3s ease-out;
}
