body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Roboto', sans-serif;
    background-color: #f4f4f4;
}


.header {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 5px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: auto;
    max-width: 95%;
    min-width: 320px;
    display: flex;
    /* Flex Layout */
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

h1 {
    margin: 0;
    font-size: 0.9rem;
    color: #333;
    font-weight: 700;
    white-space: nowrap;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 0.7rem;
}

/* Legend Styles */
.legend-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    font-size: 0.7rem;
    /* Much smaller */
    white-space: nowrap;
}

.color-box {
    width: 10px;
    /* Smaller box */
    height: 10px;
    display: inline-block;
    margin-right: 4px;
    border: 1px solid #999;
}

/* Controls (Filter) */
.controls-header {
    margin: 0;
    display: flex;
    align-items: center;
    font-size: 0.8rem;
}

.controls-header label {
    font-weight: bold;
    margin-right: 5px;
}

.controls-header select {
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.8rem;
}

.color-box.gray {
    background-color: #cccccc;
}

.color-box.green {
    background-color: #4CAF50;
}

.color-box.gray,
.status-btn.gray {
    background-color: #cccccc !important;
    /* Pendiente */
}

.color-box.green,
.status-btn.green {
    background-color: #4CAF50 !important;
    /* Realizada */
}

.color-box.yellow,
.status-btn.yellow {
    background-color: #81D4FA !important;
    /* Proyecto (Azul Más Claro) */
}

.color-box.dark-yellow,
.status-btn.dark-yellow {
    background-color: #FFF176 !important;
    /* Asignado -> Amarillo Claro */
}

.color-box.light-green,
.status-btn.light-green {
    background-color: #FF9800 !important;
    /* Preparado (WAS Listo) -> Amarillo Obscuro/Naranja */
}

.color-box.orange,
.status-btn.orange {
    background-color: #FF9800 !important;
    /* Legacy */
}

.team-select {
    padding: 2px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.8rem;
    background: #f9f9f9;
    cursor: pointer;
    width: 50px;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Dashboard Styles */
.dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
    /* Prevent sidebar scroll */
}

.dashboard h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: #333;
}

.search-box {
    margin-bottom: 15px;
    flex-shrink: 0;
    /* Keep search box fixed */
}

.search-box input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mun-list {
    flex: 1 1 auto;
    /* Grow/Shrink */
    min-height: 0;
    /* Critical for flex scrolling */
    overflow-y: scroll;
    /* Scrollbar always visible */
    overflow-x: hidden;
    /* No horizontal */
    border-top: 1px solid #eee;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #333 #ddd;
    padding-right: 5px;
    margin-bottom: 10px;
}

/* Chrome/Safari Scrollbar */
.mun-list::-webkit-scrollbar {
    width: 12px;
    /* Thicker for visibility */
    display: block;
}

.mun-list::-webkit-scrollbar-track {
    background: #ddd;
    border-radius: 4px;
}

.mun-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
    border: 2px solid #ddd;
}

.mun-list::-webkit-scrollbar-thumb:hover {
    background: #333;
}

.mun-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mun-item .name {
    font-weight: 500;
}

.mun-item .controls {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    /* Allow wrapping to prevent horizontal overflow */
}

.status-btn {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
}

.status-btn:hover,
.status-btn.active {
    opacity: 1;
    transform: scale(1.1);
    border: 1px solid #666;
}

.status-btn.gray {
    background-color: #cccccc;
}

.status-btn.green {
    background-color: #4CAF50;
}

.status-btn.yellow {
    background-color: #FFF176;
}

.status-btn.dark-yellow {
    background-color: #FBC02D;
}

.status-btn.orange {
    background-color: #FF9800;
}

.actions {
    margin-top: 15px;
    text-align: center;
}

#download-btn {
    padding: 10px 20px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Adjustments for dashboard presence */
body.admin-view #map {
    margin-left: 300px;
    /* Shift map for dashboard */
    width: calc(100% - 300px);
}

body.admin-view .header {
    left: 300px;
    width: calc(100% - 300px);
    transform: none;
    /* Remove translateX to align with new left */
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.close-btn:hover {
    color: #333;
}

#modal-title {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1rem;
}

.stat-row.highlight {
    background-color: #f0f8ff;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
    color: #0066cc;
}

.label {
    color: #666;
}

.value {
    font-weight: 500;
}