:root {
  --sidebar-width: 370px;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: #9acbf7;
  padding: 1em;
  box-sizing: border-box;
  border-right: 1px solid #9ec9ff;
  overflow: hidden; /* body scrolls only */
  display: flex;
  flex-direction: column;
  font-family: Arial, sans-serif;
  color: #034078;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

.sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 6px; /* avoid hidden scrollbar covering content */
}

.section h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0;
  color: #022f40;
  font-weight: 700;
  font-size: 1.1em;
}

/* Collapse button */
.collapse-btn {
  background: #ffffff;
  color: #034078;
  border: 1px solid #9ec9ff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
}
.collapse-btn:hover {
  background: #a6d1ff;
}

/* Collapsed section hides its list and info text */
.section.collapsed ul,
.section.collapsed .info-text {
  display: none;
}

/* Botón simulate con fondo blanco */
.simulate-btn {
  background: #ffffff;
  color: #034078;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.simulate-btn:hover {
  background: #024c9a;
  color: white;
}

/* Lista de capas: fondo blanco por cada capa */
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar ul li {
  background: #ffffff;
  margin-bottom: 0.4em;
  padding: 0.4em 0.8em;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #034078;
  font-size: 0.95em;
  /* Estilo para arrastrar */
  cursor: grab;
  transition: transform 0.2s ease-out;
  min-width: 0;
}

.sidebar ul li:hover {
  transform: translateY(-2px); /* Pequeño levantamiento al pasar el ratón */
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.sidebar ul li.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

/* Indicador visual de drop target */
#simulation-minimized-bar {
  position: fixed;
  left: calc(var(--sidebar-width) + 16px);
  right: 16px;
  bottom: 16px;
  background: #ffffff;
  border: 1px solid #9ec9ff;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.15);
  padding: 10px 12px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 1400;
  font-family: Arial, sans-serif;
  color: #034078;
}

#simulation-minimized-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#simulation-minimized-status {
  flex: 1 1 auto;
  font-size: 0.9em;
  color: #05507a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#simulation-minimized-restore {
  background: #0366d6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

#simulation-minimized-restore:hover {
  background: #024c9a;
}
.sidebar ul li.drop-target {
  border: 2px dashed #024c9a;
  background: #e0f0ff;
}

/* Estilos para grupos de capas */
.sidebar ul li.layer-group {
  background: #f0f8ff;
  border: 2px solid #9ec9ff;
  padding: 0.6em;
  margin-bottom: 0.6em;
  cursor: default;
  display: block;
}

.sidebar ul li.layer-group:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-weight: bold;
  color: #034078;
}

.group-collapse-btn {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-size: 14px;
  user-select: none;
}

.group-name {
  flex: 1;
  cursor: pointer;
}

.ungroup-btn {
  background: #ffffff;
  border: 1px solid #d9534f;
  color: #d9534f;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  font-size: 12px;
}

.ungroup-btn:hover {
  background: #d9534f;
  color: white;
}

.group-layers-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
  border-left: 2px solid #9ec9ff;
  padding-left: 8px;
}

.group-layers-list li.group-item {
  background: #ffffff;
  margin-bottom: 0.3em;
  padding: 0.3em 0.6em;
  font-size: 0.9em;
  border-radius: 3px;
}

.group-layers-list li.group-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}


.sidebar ul li .layer-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  gap: 6px;
}

.layer-top-row > label {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.layer-btn-container {
  flex: 0 0 auto;
}

/* Botón eliminar */
.remove-layer-btn { /* Cambiado de .delete-button a .remove-layer-btn para coincidir con tu JS */
  background: #ffffff;
  border: none;
  color: #d9534f;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.remove-layer-btn:hover {
  background: #d9534f;
  color: white;
  box-shadow: 0 0 5px #d9534f;
}

/* Botón de configuración (settings) */
.settings-layer-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  margin-left: 8px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.7;
}

.settings-layer-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.vector-settings-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin-right: 6px;
  cursor: pointer;
  border-radius: 2px;
  font-size: 13px;
  opacity: 0.85;
}

.vector-settings-trigger:hover {
  opacity: 1;
  background: rgba(3, 102, 214, 0.1);
}

/* Texto informativo */
.info-text {
  color: #054a91;
  font-size: 13px;
  margin: 0.3em 0;
}

hr {
  border: none;
  border-top: 1px solid #9ec9ff;
  margin: 1em 0;
}

/* Botones subir y guardar */
.button-group {
  display: flex;
  gap: 10px;
  padding: 1em 0;
  flex: 0 0 auto;
  margin-top: 12px;
}

.button-group button {
  background: #0366d6;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 0 7px;
  cursor: pointer;
  flex: 1;
  transition: background-color 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.1;
}

.button-group button:hover {
  background: #024c9a;
}

.button-group .btn-emoji {
  font-size: 16px;
}

.button-group .btn-text {
  font-size: 12px;
  font-weight: 700;
}

/* MAPA */
#map {
  position: fixed;
  top: 0;
  left: calc(var(--sidebar-width) + 0px);
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 1;
}

/* BOTÓN VOLVER */
#btn-back-projects {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #034078;
  border-radius: 4px;
  background-color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  color: #034078;
  transition: background-color 0.3s ease;
  font-family: Arial, sans-serif;
}

#btn-back-projects:hover {
  background-color: #a6d1ff;
}

/* COORDENADAS */
#mouse-coordinates {
  position: fixed;
  bottom: 10px;
  left: calc(var(--sidebar-width) + 20px);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 1000;
  color: #034078;
  font-family: Arial, sans-serif;
}

/* --- MODALES --- */
.modal {
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  /* Animación de entrada para el fondo */
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background-color: #ffffff; /* Blanco puro para un look más limpio */
  padding: 30px; /* Más padding para más espacio interior */
  border-radius: 10px; /* Bordes más redondeados */
  width: 400px; /* Un poco más ancho para más espacio */
  max-width: 90%; /* Asegura que no sea demasiado ancho en pantallas pequeñas */
  box-shadow: 0 8px 25px rgba(0,0,0,0.25); /* Sombra más pronunciada y suave */
  position: relative;
  color: #333333; /* Color de texto más suave */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Fuente más moderna */
  text-align: center; /* Centrar el texto en el modal */

  /* Animación de entrada para el contenido del modal */
  animation: slideInFromTop 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Efecto de rebote sutil */
}

/* Estilos para el título del modal (H2) */
.modal-content h2 {
  color: #024c9a; /* Un azul más vibrante */
  margin-bottom: 25px; /* Más espacio debajo del título */
  font-size: 1.8em; /* Tamaño de fuente un poco más grande */
  font-weight: 700;
}

/* Estilos para el párrafo de nombre de archivo */
.modal-content p {
  color: #555555; /* Un gris más suave */
  margin-bottom: 20px;
  font-size: 0.95em;
}

/* Estilos para las etiquetas */
.modal-content label {
  display: block; /* Asegura que la etiqueta esté en su propia línea */
  margin-bottom: 8px; /* Espacio debajo de la etiqueta */
  font-weight: 600; /* Un poco más de peso para la fuente */
  color: #444444; /* Color más oscuro que el texto general */
  text-align: left; /* Alinea la etiqueta a la izquierda */
}

/* Estilos para el selector (dropdown) */
.modal-content select {
  width: calc(100% - 2px); /* Ocupa casi todo el ancho disponible */
  padding: 10px 12px; /* Más padding para una mejor interacción */
  border: 1px solid #c0d9ed; /* Borde más suave */
  border-radius: 6px; /* Bordes redondeados */
  background-color: #f8fbfd; /* Fondo ligeramente diferente para destacar */
  font-size: 1em; /* Tamaño de fuente estándar */
  color: #022f40;
  appearance: none; /* Elimina estilos por defecto del navegador */
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23024c9a'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); /* Icono de flecha personalizado */
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 1em;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.modal-content select:focus {
  border-color: #0366d6; /* Borde azul al enfocar */
  outline: none; /* Elimina el contorno por defecto */
}

/* Estilos para los botones del modal */
.modal-content button {
  padding: 12px 25px; /* Más padding para botones */
  margin-top: 25px; /* Espacio superior */
  border: none;
  border-radius: 8px; /* Bordes más redondeados */
  cursor: pointer;
  background-color: #0366d6; /* Azul primario */
  color: white;
  font-size: 1.1em; /* Texto de botón más grande */
  font-weight: 600;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.modal-content button:hover {
  background-color: #024c9a; /* Azul más oscuro al pasar el ratón */
  transform: translateY(-2px); /* Efecto de levantamiento sutil */
}

/* Cierre modal */
button.close-sim-btn,
button.close-adaptecca,
button.close-button-raster,
button#close-rainfall-aemet-modal,
button#close-rainfall-era5-modal,
button.minimize-sim-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
  appearance: none;
  -webkit-appearance: none;
  font-size: 22px;
  cursor: pointer;
  border: none;
  background: transparent !important;
  box-shadow: none;
  color: #0366d6;
  font-weight: 700;
  line-height: 1;
  transition: color 0.18s ease, transform 0.12s ease;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  z-index: 30005;
}

button.minimize-sim-btn {
  right: 84px; /* sit to the left of the close button */
  font-size: 22px; /* match close button */
  /* line-height: 15; */
  padding: 0;
}

button.close-sim-btn:hover,
button.close-adaptecca:hover,
button.close-button-raster:hover,
button#close-rainfall-aemet-modal:hover,
button#close-rainfall-era5-modal:hover,
button.minimize-sim-btn:hover {
  background: transparent !important;
  box-shadow: none;
  transform: none;
  color: #555; /* Más oscuro al pasar el ratón */
}

#rainfall-aemet-modal .modal-content,
#rainfall-era5-modal .modal-content {
  max-height: 85vh;
  overflow-y: auto;
  padding-top: 44px;
}

/* FORMULARIOS: campo + label horizontal */
.field-group {
  display: flex;
  align-items: center;
  margin-bottom: 1em;
  gap: 12px;
}

.field-group label {
  width: 200px; /* Ancho fijo para las etiquetas del formulario */
  min-width: 120px; /* Ancho mínimo para etiquetas */
  font-weight: 600;
  color: #022f40;
  margin-bottom: 0;
  text-align: right; /* Alinea el texto de la etiqueta a la derecha */
}

.field-group input[type="number"],
.field-group input[type="text"],
.field-group select {
  flex: 1;
  padding: 8px 10px; /* Más padding */
  font-size: 1em; /* Tamaño de fuente estándar */
  border: 1px solid #c0d9ed; /* Borde más suave */
  border-radius: 6px; /* Bordes redondeados */
  color: #022f40;
  background-color: #f8fbfd; /* Fondo ligeramente diferente */
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.field-group input[type="number"]:focus,
.field-group input[type="text"]:focus,
.field-group select:focus {
  border-color: #0366d6;
  box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.2); /* Sombra suave al enfocar */
  outline: none;
}

/* Botón ejecutar simulación */
#submit-simulation-btn {
  margin-top: 25px; /* Más espacio superior para el botón */
  background: #0366d6;
  color: white;
  border: none;
  border-radius: 8px; /* Bordes más redondeados */
  padding: 12px 25px; /* Más padding para que sea más grande */
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#submit-simulation-btn:hover {
  background: #024c9a;
  transform: translateY(-2px);
}

#submit-simulation-btn.disabled {
  opacity: 0.6; /* Un poco más de opacidad */
  pointer-events: none; /* Deshabilita clics completamente */
  cursor: not-allowed;
  transform: none; /* Sin animación hover cuando está deshabilitado */
}

/* --- MODAL SIMULACIÓN AMPLIADO CON PESTAÑAS --- */

#simulation-form-container .modal-content {
  /*width: 650px;*/ /* COMENTADO PARA USAR max-content */
  width: max-content; /* <<<<<<<<<<<<<<<< ESTA ES LA ÚNICA ADICIÓN */
  max-width: 90vw;
  min-width: 700px; /* Ancho mínimo para asegurar visibilidad */
  height: 80vh;
  min-height: 400px; /* Altura mínima para asegurar visibilidad */
  overflow-y: auto;
  padding: 30px 40px;
  border-radius: 10px; /* Ajuste al nuevo radio */
  box-shadow: 0 10px 30px rgba(0, 70, 150, 0.3); /* Sombra más fuerte */
  background-color: #ffffff; /* Ajuste al nuevo color */
  color: #333333; /* Ajuste al nuevo color */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Ajuste a la nueva fuente */
  position: relative;
  display: flex;
  flex-direction: column;
}

#tabs-container {
  display: flex;
    right: 14px; /* Adjusted position */
  margin-bottom: 20px;
  gap: 12px;
  justify-content: center; /* Centra las pestañas */
  flex-wrap: wrap; /* Permite que las pestañas se envuelvan en pantallas pequeñas */
}

#tabs-container button {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
    right: 56px; /* Adjusted position */
  font-size: 1.05em; /* Un poco más grande */
  font-weight: 600;
  color: #666666; /* Gris más suave */
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

#tabs-container button:hover {
  color: #0366d6;
  transform: translateY(-2px); /* Efecto sutil al pasar el ratón */
}

#tabs-container button.active {
  border-bottom-color: #0366d6;
  color: #0366d6;
  font-weight: 700;
}

#tab-contents {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 15px; /* Espacio para scrollbar */
  padding-bottom: 10px; /* Espacio extra al final del contenido */
}

/* Estilos para campos de sedimento dinámicos */
.sediment-group {
  background-color: #f0f7ff; /* Fondo ligeramente azul para agrupar */
  border: 1px solid #d0e7ff;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.sediment-group h4 {
  color: #024c9a;
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.3em;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px dashed #d0e7ff;
  padding-bottom: 10px;
}

---
/* Estilos adicionales para los nuevos elementos del botón de dibujo */

/* Estilos para los botones de control de OpenLayers (aplicable a tu botón '✏️') */
.ol-control button {
    background-color: #f8f8f8;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 1.2em;
    padding: 5px 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ol-control button:hover {
    background-color: #e2e2e2;
}

/**********************************************************************************************************/
#draw-options-container {
  position: absolute;
  top: 10%;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
  width: 300px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  z-index: 2000;
}

#draw-options-container h4 {
  margin: 0 0 12px 0;
  font-weight: 600;
  font-size: 16px;
  color: #333;
  text-align: center;
}

.draw-option-button {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px 12px;
  background-color: #0078d4; /* Azul agradable */
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.25s ease;
  user-select: none;
  box-shadow: 0 2px 5px rgba(0, 120, 212, 0.4);
}

.draw-option-button:hover:not(.cancel) {
  background-color: #005a9e;
}

.draw-option-button.cancel {
  background-color: #e43e3e; /* Rojo para cancelar */
  box-shadow: 0 2px 5px rgba(232, 17, 35, 0.4);
  position: absolute;
  top: 0px;
  right: 10px;
  width: auto;
  min-width: 50px;
  padding: 4px 10px;
  font-size: 13px;
}

.draw-option-button.cancel:hover {
  background-color: #a80000;
}

/* Contenedor del título para alinear el texto y el icono */
#sim-title {
    display: flex;
    justify-content: center; /* Centra el texto y el icono */
    align-items: center;
    gap: 10px; /* Espacio entre el texto del título y el icono */
    margin-bottom: 25px; /* Espacio debajo del título (ajustado para que no se pegue al contenido) */
    font-size: 1.8em;
    font-weight: 700;
    color: #024c9a;
}

/* Estilo para el icono de información en sí */
.info-icon {
    font-size: 0.8em; /* Tamaño del icono un poco más pequeño que el título */
    cursor: pointer;
    color: #0366d6; /* Un color azul para que resalte */
    user-select: none; /* Evita que el usuario seleccione el icono como texto */
    transition: color 0.3s ease;
}

.info-icon:hover {
    color: #024c9a; /* Color más oscuro al pasar el ratón */
}

#simulations-modal .modal-content {
  width: 800px; 
  max-width: 90vw; 
  padding: 30px; /* Mantiene el padding en el modal */
  /* Asegúrate de que este tiene el color de fondo que deseas (e.g., blanco o crema) */
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(2, 76, 154, 0.18);
}

#simulations-container {
  width: 100%; 
  max-height: 700px;
  overflow-y: auto;
  color: #000;
  font-size: 14px;
  padding-right: 6px;
}

#simulations-container ul {
  margin: 0;
  padding: 0;
}

#simulations-container li {
  padding: 0;
  border: none;
  background-color: transparent;
}

.sim-history-list {
  list-style: none;
  display: grid;
  gap: 12px;
}

.sim-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d6e6f7;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.sim-history-main {
  min-width: 0;
  flex: 1;
}

.sim-history-name {
  font-size: 15px;
  font-weight: 700;
  color: #073b78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-history-meta {
  margin-top: 3px;
  font-size: 12px;
  color: #4b6a88;
}

.sim-history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-history-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sim-history-btn-open {
  background-color: #0366d6;
  border-color: #0366d6;
  color: #fff;
}

.sim-history-btn-open:hover {
  background-color: #0255b6;
}

.sim-history-btn-rename {
  background-color: #eef5ff;
  border-color: #bdd8fb;
  color: #194c8a;
}

.sim-history-btn-rename:hover {
  background-color: #deedff;
}

.sim-history-btn-delete {
  background-color: #fff1f0;
  border-color: #f4b8b4;
  color: #a22a21;
}

.sim-history-btn-delete:hover {
  background-color: #ffdedd;
}

@media (max-width: 680px) {
  .sim-history-item {
    flex-direction: column;
    align-items: stretch;
  }

  .sim-history-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

.sim-results-root {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.sim-results-category {
  border: 1px solid #d6e6f7;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.sim-results-category-toggle {
  width: 100%;
  border: none;
  background: linear-gradient(180deg, #f4f9ff 0%, #eaf3ff 100%);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.sim-results-category-title {
  font-size: 14px;
  font-weight: 700;
  color: #08407e;
  text-align: left;
}

.sim-results-category-icon {
  color: #3f5d7e;
  font-size: 14px;
}

.sim-results-file-list {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.sim-results-file-list.is-collapsed {
  display: none;
}

.sim-results-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid #e8eef6;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fcfeff;
}

.sim-results-file-left {
  min-width: 0;
  flex: 1;
}

.sim-results-file-name {
  font-size: 13px;
  font-weight: 600;
  color: #17385f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-results-file-meta {
  margin-top: 3px;
}

.sim-results-file-ext {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #305a85;
  background: #edf4ff;
  border: 1px solid #cfe1f9;
  border-radius: 999px;
  padding: 1px 7px;
}

.sim-results-file-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sim-results-action {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sim-results-action-download {
  color: #fff;
  background: #0b69d0;
  border-color: #0b69d0;
}

.sim-results-action-download:hover {
  background: #095cb6;
}

.sim-results-action-add {
  color: #1f4f83;
  background: #ebf5ff;
  border-color: #c7ddf8;
}

.sim-results-action-add:hover {
  background: #dbeeff;
}

@media (max-width: 680px) {
  .sim-results-file-item {
    flex-direction: column;
    align-items: stretch;
  }

  .sim-results-file-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

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

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

/* Botón de descarga de capa raster */
.layer-download-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
}

.layer-download-btn:hover {
  opacity: 1;
  background: rgba(3, 102, 214, 0.1);
}

/* ====================== */
/* RASTER STYLE SIDEBAR   */
/* ====================== */

#tiff-style-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: #f8fbfd;
  border-left: 2px solid #9ec9ff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 9500;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
}

#tiff-style-panel-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tiff-style-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 2px solid #9ec9ff;
  margin-bottom: 4px;
  gap: 8px;
  min-width: 0;
}

.tiff-style-header h3 {
  margin: 0;
  color: #022f40;
  font-size: 0.95em;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tiff-style-close-btn {
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: #034078;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.2s;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  right: 0;
  z-index: 2;
}

.tiff-style-close-btn:hover {
  color: #d9534f;
}

.tiff-style-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid #dde8f4;
}

.tiff-style-section > label,
.tiff-style-section > [id^="tiff-label"] {
  font-weight: 600;
  color: #022f40;
  font-size: 0.85em;
}

.tiff-original-range-info {
  font-size: 11px;
  color: #666;
  font-style: italic;
  background: #eef4fb;
  padding: 4px 8px;
  border-radius: 4px;
}

.tiff-style-hint {
  font-size: 11px;
  color: #888;
  margin: 0;
  font-style: italic;
}

/* Selects inside style panel */
#tiff-style-panel select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #c0d9ed;
  border-radius: 6px;
  background: #fff;
  color: #022f40;
  font-size: 0.9em;
  cursor: pointer;
}

/* Dual range slider */
.dual-range-wrapper {
  position: relative;
  height: 28px;
  margin: 6px 0 2px 0;
  border-radius: 4px;
  background: linear-gradient(to right, #dde 0%, #0366d6 0%, #0366d6 100%, #dde 100%);
}

.dual-range-input {
  position: absolute;
  width: 100%;
  height: 28px;
  top: 0;
  left: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
}

.dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: all;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0366d6;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: grab;
  margin-top: 5px;
}

.dual-range-input::-moz-range-thumb {
  pointer-events: all;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0366d6;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: grab;
}

.dual-range-input::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
}

.dual-range-input::-moz-range-track {
  background: transparent;
  height: 6px;
}

/* Numeric inputs */
.tiff-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tiff-range-input-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tiff-range-input-group label {
  font-size: 11px;
  font-weight: 600;
  color: #444;
}

.tiff-range-input-group input[type="number"] {
  padding: 5px 7px;
  border: 1px solid #c0d9ed;
  border-radius: 4px;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
  color: #022f40;
  background: #fff;
}

.tiff-range-input-group input[type="number"]:focus {
  border-color: #0366d6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(3,102,214,0.15);
}

.tiff-apply-btn {
  background: #0366d6;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.3s ease;
  margin-top: 4px;
}

.tiff-apply-btn:hover {
  background: #024c9a;
}

/* ========================= */
/* INLINE RASTER LEGEND      */
/* ========================= */

.inline-raster-legend {
  margin-top: 5px;
  padding: 4px 0 2px 0;
  width: 100%;
}

.inline-legend-strip {
  height: 10px;
  width: 100%;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
}

.inline-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #667;
  margin-top: 2px;
  padding: 0 1px;
}

/* Make layer list items columnar for rasters with inline legends */
.sidebar ul li.has-inline-legend {
  flex-direction: column;
  align-items: stretch;
}

.sidebar ul li.has-inline-legend .layer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.legend-trigger {
  flex: 0 0 16px;
  min-width: 16px;
  min-height: 16px;
}

.tiff-sidebar-legend-ref {
  background: #eef4fb;
  border: 1px solid #c7ddf3;
  border-radius: 8px;
  padding: 10px;
}

.tiff-sidebar-legend-title {
  font-weight: 700;
  color: #022f40;
  font-size: 0.85em;
}

.tiff-sidebar-legend-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #034078;
  font-size: 0.82em;
  min-width: 0;
  max-width: 100%;
}

#tiff-selected-layer-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tiff-sidebar-legend-swatch {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border-radius: 3px;
  border: 1px solid #7da5c8;
  background: linear-gradient(to right, #000, #fff);
}

#vector-style-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: #f8fbfd;
  border-left: 2px solid #9ec9ff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 9501;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
}

#vector-style-panel-inner {
  padding: 14px;
  font-family: Arial, sans-serif;
  color: #034078;
}

.vector-style-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.vector-style-header h3 {
  margin: 0;
  font-size: 18px;
  color: #034078;
}

#vector-style-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #034078;
}

.vector-style-section {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vector-style-label {
  font-size: 12px;
  color: #4b6a88;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.vector-style-value {
  font-size: 13px;
  color: #17385f;
  background: #ffffff;
  border: 1px solid #dbe8f8;
  border-radius: 6px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

#vector-style-panel select,
#vector-style-panel input[type="color"] {
  width: 100%;
  border: 1px solid #bdd7f7;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  background: #fff;
  box-sizing: border-box;
}

.vector-style-metadata-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vector-style-metadata-chip {
  border: 1px solid #c9dcf4;
  background: #eef5ff;
  color: #204a7a;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
}

.vector-style-metadata-empty {
  font-size: 12px;
  color: #6a7f96;
}

.vector-entities-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid #dbe8f8;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vector-entity-card {
  border: 1px solid #e4edf9;
  border-radius: 8px;
  padding: 8px;
  background: #fbfdff;
}

.vector-entity-title {
  font-size: 12px;
  font-weight: 700;
  color: #19497d;
  margin-bottom: 6px;
}

.vector-entity-meta-grid {
  display: grid;
  gap: 4px;
}

.vector-entity-meta-item {
  display: grid;
  grid-template-columns: minmax(90px, 35%) 1fr;
  gap: 8px;
  align-items: start;
}

.vector-entity-meta-key {
  font-size: 11px;
  font-weight: 700;
  color: #3f6187;
  overflow-wrap: anywhere;
}

.vector-entity-meta-val {
  font-size: 11px;
  color: #244366;
  overflow-wrap: anywhere;
}

.vector-style-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.upload-matrix-content {
  width: 900px;
  max-width: 95vw;
  text-align: left;
}

#upload-matrix-table-wrap {
  overflow: auto;
  max-height: 55vh;
  border: 1px solid #d6e6f7;
  border-radius: 8px;
}

.upload-matrix-table {
  border-collapse: collapse;
  min-width: 100%;
  width: max-content;
  background: #fff;
}

.upload-matrix-table th,
.upload-matrix-table td {
  border: 1px solid #d6e6f7;
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

.upload-matrix-table th {
  background: #f4f9ff;
  color: #08407e;
  font-weight: 700;
}

.upload-matrix-file-header {
  min-width: 170px;
  max-width: 230px;
  word-break: break-word;
  font-size: 12px;
}

.upload-matrix-section-cell {
  text-align: left;
  font-weight: 600;
  color: #19497d;
  background: #fbfdff;
  min-width: 180px;
}

.upload-matrix-type-chip {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid #c9dcf4;
  border-radius: 999px;
  padding: 2px 6px;
  color: #2a5d95;
  background: #eef5ff;
}

.upload-matrix-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.upload-matrix-cancel {
  background: #6c757d !important;
}

#vector-style-apply {
  border: none;
  border-radius: 6px;
  background: #0366d6;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  width: 100%;
}

#vector-style-apply:hover {
  background: #0255b6;
}
