body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

#map {
    height: 100vh;
    width: 100%;
}

.info {
    padding: 6px 8px;
    font: 14px/16px Arial, Helvetica, sans-serif;
    background: white;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 5px;
}

.info h4 {
    margin: 0 0 5px;
    color: #777;
}

.legend {
    line-height: 18px;
    color: #555;
}

.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.7;
}

.legend-header {
    cursor: pointer;
    user-select: none;
}

.legend-header h4 {
    margin: 0 0 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-toggle {
    font-size: 12px;
    margin-left: 10px;
    transition: transform 0.2s ease;
}

.legend-content {
    transition: all 0.3s ease;
}

.village-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

.village-label span {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #333;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    display: block;
    text-align: center;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    z-index: 1000;
}

.stats {
    margin-top: 10px;
    font-size: 12px;
}

.stats div {
    margin: 2px 0;
}

.popup-content {
    max-height: 300px;
    overflow-y: auto;
}

.popup-content h5 {
    margin: 10px 0 5px 0;
    color: #666;
}

.popup-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.popup-content td {
    padding: 2px 5px;
    border-bottom: 1px solid #eee;
}

.popup-content td:first-child {
    font-weight: bold;
    width: 40%;
}

.credit-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 12px;
    text-decoration: none;
    color: #666;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.credit-button:hover {
    background: white;
    color: #333;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-decoration: none;
}

.controls {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 15px;
    align-items: center;
}

.recall-selector {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #6c757d;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    min-width: 180px;
}

.recall-selector:hover {
    background: white;
    border-color: #495057;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.recall-selector:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

.chart-button {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #007bff;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    color: #007bff;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.chart-button:hover {
    background: #007bff;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.chart-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.chart-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    width: 1000px;
}

.chart-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 20px 0;
}

.chart-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.chart-item h5 {
    margin-bottom: 15px;
    color: #333;
    font-weight: bold;
}

.chart-item canvas {
    max-height: 300px;
}

@media (max-width: 768px) {
    .chart-container {
        grid-template-columns: 1fr;
    }
    
    .chart-content {
        width: 95vw;
        padding: 20px;
        padding-top: 60px;
        margin-top: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .controls {
        flex-direction: column;
        top: 10px;
        gap: 10px;
    }
    
    .recall-selector {
        min-width: unset;
        width: 90vw;
        max-width: 300px;
        font-size: 13px;
        padding: 10px 15px;
    }
    
    .chart-button {
        width: 90vw;
        max-width: 300px;
        font-size: 14px;
        padding: 10px 20px;
    }
    
    .credit-button {
        bottom: 10px;
        left: 10px;
        font-size: 11px;
        padding: 8px 12px;
        max-width: calc(100vw - 40px);
    }
    
    .info {
        position: fixed !important;
        bottom: 70px !important;
        left: 10px !important;
        right: 10px !important;
        max-width: unset !important;
        font-size: 12px;
    }
    
    .info h4 {
        font-size: 14px;
    }
    
    .stats div {
        font-size: 11px;
    }
    
    .chart-closer {
        top: 10px;
        right: 10px;
        font-size: 28px;
        width: 35px;
        height: 35px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 50%;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    .legend {
        font-size: 12px;
    }
    
    .legend i {
        width: 14px;
        height: 14px;
    }
}

.chart-closer {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    z-index: 1;
}

.chart-closer:hover {
    color: #333;
}

.chart-stats {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.chart-stats .stat-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.chart-stats .stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.chart-stats .stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}